[jboss-svn-commits] JBL Code SVN: r18304 - labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Feb 4 17:55:28 EST 2008


Author: mark.little at jboss.com
Date: 2008-02-04 17:55:28 -0500 (Mon, 04 Feb 2008)
New Revision: 18304

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
Log:
Added more transaction checking.

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2008-02-04 21:02:35 UTC (rev 18303)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/JmsCourier.java	2008-02-04 22:55:28 UTC (rev 18304)
@@ -148,33 +148,7 @@
 	
         if(jmsSession == null) {
             synchronized(this) {
-        	try
-        	{
-                	TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
-        		Object txHandle = txStrategy.getTransaction();
-        		boolean isActive = txStrategy.isActive();
-        		
-        		transactional = (txHandle != null);
-        		
-        		/*
-        		 * Make sure the current transaction is still active! If we
-        		 * have previously slept, then the timeout may be longer than that
-        		 * associated with the transaction.
-        		 */
-        		
-        		/*
-        		 * MessageAwareListener will catch exceptions and roll back the transaction.
-        		 */
-        		
-        		if (transactional && !isActive)
-        		{
-        			throw new CourierException("Associated transaction is no longer active!");
-        		}
-        	}
-        	catch (TransactionStrategyException ex)
-        	{
-        	    throw new CourierException(ex);
-        	}
+        	checkTransaction();
         	
                 if(jmsSession == null) {
                     String sType;
@@ -265,30 +239,6 @@
         if (null == message) {
             return false;
         }
-
-        try
-	{
-        	TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
-		Object txHandle = txStrategy.getTransaction();
-		boolean isActive = txStrategy.isActive();
-		
-		transactional = (txHandle != null);
-		
-		/*
-		 * Make sure the current transaction is still active! If we
-		 * have previously slept, then the timeout may be longer than that
-		 * associated with the transaction.
-		 */
-		
-		if (transactional && !isActive)
-		{
-			throw new CourierException("Associated transaction is no longer active!");
-		}
-	}
-	catch (TransactionStrategyException ex)
-	{
-	    throw new CourierException(ex);
-	}
 	
 	reset();
 	
@@ -309,6 +259,8 @@
                     }
                 }
 
+                checkTransaction();
+                
                 sendMessage(message);
                 if ( jmsSession.getTransacted() && !transactional )
 	                jmsSession.commit();
@@ -379,6 +331,8 @@
 
         reset();
 	
+        checkTransaction();
+        
         if (_messageProducer == null) {
             synchronized(this) {
                 if (_messageProducer == null) {
@@ -443,6 +397,15 @@
 	
         if (jmsConnectionPool == null) {
             synchronized(this) {
+        	try
+        	{
+        	    checkTransaction();
+        	}
+        	catch (CourierException ex)
+        	{
+        	    throw new ConnectionException(ex);
+        	}
+        	
                 if(jmsConnectionPool == null) {
                     String sFactoryClass;
                     String sType;
@@ -519,6 +482,33 @@
 	}
     }
     
+    private void checkTransaction () throws CourierException
+    {
+	try
+	{
+        	TransactionStrategy txStrategy = TransactionStrategy.getTransactionStrategy(true);
+		Object txHandle = txStrategy.getTransaction();
+		boolean isActive = txStrategy.isActive();
+		
+		transactional = (txHandle != null);
+		
+		/*
+		 * Make sure the current transaction is still active! If we
+		 * have previously slept, then the timeout may be longer than that
+		 * associated with the transaction.
+		 */
+		
+		if (transactional && !isActive)
+		{
+			throw new CourierException("Associated transaction is no longer active!");
+		}
+	}
+	catch (TransactionStrategyException ex)
+	{
+	    throw new CourierException(ex);
+	}
+    }
+    
     public Message pickup(long millis) throws CourierException, CourierTimeoutException {
         javax.jms.Message jmsMessage = pickupPayload(millis);
 
@@ -544,6 +534,8 @@
 
         javax.jms.Message jmsMessage = null;
         while (null != _messageConsumer) {
+            checkTransaction();
+            
             try {
                 jmsMessage = _messageConsumer.receive(millis);
                 break;




More information about the jboss-svn-commits mailing list