From: Roland Häder Date: Tue, 17 May 2016 15:10:12 +0000 (+0200) Subject: added method sendMessage() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1f200bd0e0461cdd67848d63365de8e1c507f29a;p=jcore-utils.git added method sendMessage() --- diff --git a/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java b/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java index 9e82877..302daeb 100644 --- a/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java +++ b/src/org/mxchange/jcoreee/database/BaseDatabaseBean.java @@ -18,6 +18,9 @@ package org.mxchange.jcoreee.database; import java.io.Serializable; import java.text.MessageFormat; +import javax.jms.JMSException; +import javax.jms.MessageProducer; +import javax.jms.ObjectMessage; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; @@ -84,4 +87,23 @@ public abstract class BaseDatabaseBean implements Serializable { return this.loggerBeanLocal; } + /** + * Sends given message to configured queue + *

+ * @param message Message to send + * @param messageProducer Message producer + *

+ * @throws JMSException if something went wrong + */ + protected void sendMessage (final ObjectMessage message, final MessageProducer messageProducer) throws JMSException { + // The parameter should be valid + if (null == message) { + // Throw NPE + throw new NullPointerException("message is null"); //NOI18N + } + + // Send it + messageProducer.send(message); + } + }