[jboss-svn-commits] JBL Code SVN: r9911 - labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 2 16:30:31 EST 2007
Author: kurt.stam at jboss.com
Date: 2007-03-02 16:30:31 -0500 (Fri, 02 Mar 2007)
New Revision: 9911
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyQueues.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyTopics.java
Log:
Closing the connections. Note that these notfiers need refactoring in my opinion.
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyQueues.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyQueues.java 2007-03-02 21:28:35 UTC (rev 9910)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyQueues.java 2007-03-02 21:30:31 UTC (rev 9911)
@@ -32,6 +32,7 @@
import javax.jms.QueueSession;
import javax.naming.NamingException;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
@@ -45,11 +46,13 @@
* <p>
* Author: Heuristica - Buenos Aires - Argentina
* </p>
+ * KS: It is silly we open and close the jms connection with eash request.
*
* @version 1.0
*/
public class NotifyQueues extends NotifyJMS
{
+ private Logger log = Logger.getLogger(this.getClass());
/**
* Connection Factory JNDI name.
*/
@@ -97,7 +100,18 @@
{
throw new ConfigurationException(ex);
}
- } // __________________________________
+ }
+ /**
+ * Closes the connections
+ */
+ private void cleanup() {
+ try {
+ m_oSess.close();
+ m_oConn.close();
+ } catch (JMSException jmse) {
+ log.error("Could not close JMS resource. ", jmse);
+ }
+ }
/**
* Get the {@link QueueConnectionFactory} to be used for this instance. <p/>
@@ -111,9 +125,13 @@
{
// REVIEW: The connection factory name is hardcoded and is the same as
// that of the topic connection factory.
+ // KS: Yes this should come from the configuration, the Queue maybe located on a different server.
return (QueueConnectionFactory) m_oCtx.lookup(CONNECTION_FACTORY);
}
+ /**
+ * Send a message to all the configured queues.
+ */
protected void sendToAll (Message p_oMsg)
{
for (int i1 = 0; i1 < m_oaMssProd.length; i1++)
@@ -125,8 +143,10 @@
}
catch (Exception e)
{
+ log.error("Could not send message " + p_oMsg, e);
}
}
- } // __________________________________
+ cleanup();
+ }
-} // ____________________________________________________________________________
+}
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyTopics.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyTopics.java 2007-03-02 21:28:35 UTC (rev 9910)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/notification/NotifyTopics.java 2007-03-02 21:30:31 UTC (rev 9911)
@@ -32,12 +32,18 @@
import javax.jms.TopicSession;
import javax.naming.NamingException;
+import org.apache.log4j.Logger;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.helpers.ConfigTree;
-
+/**
+ *
+ * KS: It is silly we open and close the jms connection with eash request.
+ *
+ */
public class NotifyTopics extends NotifyJMS
{
-
+ private Logger log = Logger.getLogger(this.getClass());
+
public static final String CONNECTION_FACTORY = "ConnectionFactory";
public static final String CHILD_TOPIC = "topic";
@@ -91,6 +97,14 @@
} // __________________________________
+ private void cleanup() {
+ try {
+ m_oSess.close();
+ m_oConn.close();
+ } catch (JMSException jmse) {
+ log.error("Could not close JMS resource. ", jmse);
+ }
+ }
protected void sendToAll (Message p_oMsg)
{
for (int i1 = 0; i1 < m_oaMssProd.length; i1++)
@@ -105,6 +119,7 @@
{
}
}
+ cleanup();
} // __________________________________
} // ____________________________________________________________________________
More information about the jboss-svn-commits
mailing list