[jboss-svn-commits] JBL Code SVN: r18117 - 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
Fri Jan 25 10:52:27 EST 2008


Author: mark.little at jboss.com
Date: 2008-01-25 10:52:26 -0500 (Fri, 25 Jan 2008)
New Revision: 18117

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
Log:
missing from http://jira.jboss.com/jira/browse/JBESB-1283

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-01-25 15:52:03 UTC (rev 18116)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java	2008-01-25 15:52:26 UTC (rev 18117)
@@ -114,7 +114,8 @@
 
 	/**
 	 * package the ESB message in a java.io.Serializable, and write it.
-	 * Delivery occurs within its own transaction.
+	 * Delivery occurs within its own transaction if there is no
+	 * global transaction active.
 	 * 
 	 * @param message
 	 *            Message - the message to deliverAsync
@@ -146,6 +147,30 @@
 			throw new CourierException("Problems with message header ",e);
 		}
 
+		try
+		{
+        		TransactionStrategy txStrategy = TransactionStrategy.getStrategy();
+        		Object txHandle = ((txStrategy == null) ? null : txStrategy.getTransaction());
+        		boolean isActive = ((txStrategy == null) ? false : 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);
+		}
+		
 		if (null == _conn)
 		{
 			try
@@ -170,7 +195,10 @@
 				PS.setLong(iCol++, System.currentTimeMillis());
 
 				_conn.execUpdWait(PS, 3);
-				_conn.commit();
+				
+				if (!transactional)
+				    _conn.commit();
+				
 				return true;
 			}
 			catch (SQLException e)
@@ -179,6 +207,7 @@
 				{
 					try
 					{
+					    if (!transactional)
 						_conn.rollback();
 					}
 					catch (Exception roll)




More information about the jboss-svn-commits mailing list