[Jboss-cvs] JBossAS SVN: r57039 - branches/Branch_4_0/messaging/src/main/org/jboss/mq

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 21 01:02:36 EDT 2006


Author: adrian at jboss.org
Date: 2006-09-21 01:02:30 -0400 (Thu, 21 Sep 2006)
New Revision: 57039

Modified:
   branches/Branch_4_0/messaging/src/main/org/jboss/mq/SpyMessageConsumer.java
Log:
[JBAS-3634] - Transacted acknowlegement should be inside the
delivery lock for a message listener.

Modified: branches/Branch_4_0/messaging/src/main/org/jboss/mq/SpyMessageConsumer.java
===================================================================
--- branches/Branch_4_0/messaging/src/main/org/jboss/mq/SpyMessageConsumer.java	2006-09-21 05:02:20 UTC (rev 57038)
+++ branches/Branch_4_0/messaging/src/main/org/jboss/mq/SpyMessageConsumer.java	2006-09-21 05:02:30 UTC (rev 57039)
@@ -647,17 +647,6 @@
             if (mes instanceof SpyEncapsulatedMessage)
                message = ((SpyEncapsulatedMessage) mes).getMessage();
 
-            if (session.transacted)
-            {
-               // REVIEW: for an XASession without a transaction this will ack the message
-               // before it has been processed. Plain message listeners
-               // are not supported in a j2ee environment, but what if somebody is trying 
-               // to be clever?
-               if (trace)
-                  log.trace("run() acknowledging message in tx mes=" + mes.getJMSMessageID() + " " + this); 
-               session.connection.spyXAResourceManager.ackMessage(session.getCurrentTransactionId(), mes);
-            }
-
             // Try to obtain the session delivery lock
             // This avoids concurrent delivery to message listeners in the same session as per spec
             boolean gotDeliveryLock = false;
@@ -689,14 +678,28 @@
                //is 0. :)
                try
                {
-                  prepareDelivery((SpyMessage) message);
-                  session.addUnacknowlegedMessage((SpyMessage) message);
-                  thisListener.onMessage(message);
+                  if (session.transacted)
+                  {
+                     // REVIEW: for an XASession without a transaction this will ack the message
+                     // before it has been processed. Plain message listeners
+                     // are not supported in a j2ee environment, but what if somebody is trying 
+                     // to be clever?
+                     if (trace)
+                        log.trace("run() acknowledging message in tx mes=" + mes.getJMSMessageID() + " " + this); 
+                     session.connection.spyXAResourceManager.ackMessage(session.getCurrentTransactionId(), mes);
+                  }
+
+                  try
+                  {
+                     prepareDelivery((SpyMessage) message);
+                     session.addUnacknowlegedMessage((SpyMessage) message);
+                     thisListener.onMessage(message);
+                  }
+                  catch (Throwable t)
+                  {
+                     log.warn("Message listener " + thisListener + " threw a throwable.", t);
+                  }
                }
-               catch (Throwable t)
-               {
-                  log.warn("Message listener " + thisListener + " threw a throwable.", t);
-               }
                finally
                {
                   session.releaseDeliveryLock();




More information about the jboss-cvs-commits mailing list