[jboss-cvs] JBoss Messaging SVN: r8353 - in branches/JBMESSAGING_1876/src/main/org/jboss/jms: tx and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 20 08:14:11 EDT 2011


Author: gaohoward
Date: 2011-06-20 08:14:10 -0400 (Mon, 20 Jun 2011)
New Revision: 8353

Modified:
   branches/JBMESSAGING_1876/src/main/org/jboss/jms/client/container/ClientConsumer.java
   branches/JBMESSAGING_1876/src/main/org/jboss/jms/tx/ResourceManager.java
Log:
fix issues



Modified: branches/JBMESSAGING_1876/src/main/org/jboss/jms/client/container/ClientConsumer.java
===================================================================
--- branches/JBMESSAGING_1876/src/main/org/jboss/jms/client/container/ClientConsumer.java	2011-06-19 03:21:25 UTC (rev 8352)
+++ branches/JBMESSAGING_1876/src/main/org/jboss/jms/client/container/ClientConsumer.java	2011-06-20 12:14:10 UTC (rev 8353)
@@ -660,7 +660,7 @@
                      catch (TimeoutException e)
                      {
                         log.warn("Timed out waiting for post message processing " + m + " within time " + timeLeft);
-                        ignore = false;
+                        ignore = true;
                         sessionDelegate.processMessageTimeout();
                      }
                   }

Modified: branches/JBMESSAGING_1876/src/main/org/jboss/jms/tx/ResourceManager.java
===================================================================
--- branches/JBMESSAGING_1876/src/main/org/jboss/jms/tx/ResourceManager.java	2011-06-19 03:21:25 UTC (rev 8352)
+++ branches/JBMESSAGING_1876/src/main/org/jboss/jms/tx/ResourceManager.java	2011-06-20 12:14:10 UTC (rev 8353)
@@ -336,7 +336,13 @@
       if (state == null)
       { 
          throw new MessagingXAException(XAException.XAER_NOTA, "Cannot find transaction with xid:" + xid);
-      } 
+      }
+
+      if (state.isRollbackOnly())
+      {
+         this.rollback(xid, state, connection);
+         throw new MessagingXAException(XAException.XA_RBROLLBACK, "Transaction marked rollback only, xid: " + xid);
+      }
       
       TransactionRequest request =
          new TransactionRequest(TransactionRequest.TWO_PHASE_PREPARE_REQUEST, xid, state);
@@ -358,10 +364,10 @@
       
       if (trace) { log.trace("got tx: " + tx + " state " + tx.getState()); }
       
-      
-      if ((tx != null) && tx.isRollbackOnly())
+      //roll back for onePhase only. for 2pc, rollback only is processed in prepare
+      if ((tx != null) && tx.isRollbackOnly() && onePhase)
       {
-         this.rollback(xid, connection);
+         this.rollback(xid, tx, connection);
          throw new MessagingXAException(XAException.XA_RBROLLBACK, "Transaction marked rollback only, xid: " + xid);
       }
           
@@ -421,6 +427,16 @@
          throw new java.lang.IllegalStateException("Cannot find xid to remove " + xid);
       }
       
+      this.rollback(xid, tx, connection);
+   }
+   
+   private void rollback(Xid xid, ClientTransaction tx, ConnectionDelegate connection) throws XAException
+   {
+      if (tx == null)
+      {
+         throw new java.lang.IllegalStateException("Cannot find xid to remove " + xid);
+      }
+      
       //It's possible we don't actually have the prepared tx here locally - this
       //may happen if we have recovered from failure and the transaction manager
       //is calling rollback on the transaction as part of the recovery process.
@@ -428,12 +444,9 @@
       TransactionRequest request = null;
       
       //don't need the messages
-      if (tx != null)
-      {
-         tx.clearMessages();
-      }
+      tx.clearMessages();
              
-      if ((tx == null) || tx.getState() == ClientTransaction.TX_PREPARED)
+      if (tx.getState() == ClientTransaction.TX_PREPARED)
       {
          //2PC rollback
          
@@ -446,13 +459,9 @@
       else
       {
          //For one phase rollback there is nothing to do on the server 
-         
-         if (tx == null)
-         {     
-            throw new MessagingXAException(XAException.XAER_NOTA, "Cannot find transaction with xid:" + xid);
-         }
+         if (trace) { log.trace("It is a one phase roll back, tx: " + tx); }
       }
-                  
+
       //we redeliver the messages
       //locally to their original consumers if they are still open or cancel them to the server
       //if the original consumers have closed
@@ -461,20 +470,14 @@
       
       try
       {
-         if (tx != null)
-         {
-            redeliverMessages(tx);
-            
-            tx.setState(ClientTransaction.TX_ROLLEDBACK);  
-         }
-         
+         redeliverMessages(tx);
+         tx.setState(ClientTransaction.TX_ROLLEDBACK);  
       }
       catch (JMSException e)
       {
          log.error("Failed to redeliver", e);
       }                               
-   }
-  
+   }  
    
    Xid joinTx(Xid xid) throws XAException
    {



More information about the jboss-cvs-commits mailing list