[jboss-svn-commits] JBL Code SVN: r13920 - labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 31 17:08:32 EDT 2007


Author: kurt.stam at jboss.com
Date: 2007-07-31 17:08:32 -0400 (Tue, 31 Jul 2007)
New Revision: 13920

Modified:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java
Log:
JBESB-710, Adding a deliverOne and close() method to handle closing resources like ConnectionPools

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java	2007-07-31 19:22:39 UTC (rev 13919)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/ServiceInvoker.java	2007-07-31 21:08:32 UTC (rev 13920)
@@ -22,8 +22,11 @@
 import java.util.Date;
 import java.util.List;
 
+import javax.jms.JMSException;
+
 import org.apache.log4j.Logger;
 import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPoolContainer;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.addressing.MalformedEPRException;
@@ -137,18 +140,49 @@
     
     public Message deliver (Message message) throws MessageDeliverException, RegistryException
     {
-	if (message == null)
-	    throw new IllegalArgumentException();
-	
-	if (message.getHeader().getCall().getReplyTo() != null)
-	    return deliverSync(message, _timeout);
-	else
-	{
-	    deliverAsync(message);
-	    
-	    return null;
-	}
+    	if (message == null)
+    	    throw new IllegalArgumentException();
+    	
+    	if (message.getHeader().getCall().getReplyTo() != null)
+    	    return deliverSync(message, _timeout);
+    	else
+    	{
+    	    deliverAsync(message);
+    	    
+    	    return null;
+    	}
     }
+    /**
+     * Method to deliver *one* message, which allocates resources before sending the message and
+     * deallocates resources after the invocation. 
+     * 
+     * @param message Message to be send
+     * @return message (if the invo
+     * @throws MessageDeliverException
+     * @throws RegistryException
+     */
+    public Message deliverOne (Message message) throws MessageDeliverException, RegistryException
+    {
+        try {
+            deliver(message);
+        } finally {
+            //cleanup allocated resources.
+            close();
+        }
+        return message;
+    }
+    
+    /**
+     * Release allocated resources, such as connection pools. This is only of interest when you run
+     * in standalone mode, in other cases the container will call it for you.
+     */
+    public void close(){
+        try {
+            JmsConnectionPoolContainer.removeAllPools();
+        } catch (JMSException e) {
+            logger.error("Could not release resources " + e.getMessage(), e);
+        }
+    }
 
     /**
      * Synchronously deliver the supplied message to the target service associated with this invoker instance.




More information about the jboss-svn-commits mailing list