[jboss-cvs] jboss-jms/src/main/org/jboss/jms/server/endpoint ...

Timothy Fox tim.fox at jboss.com
Thu Jul 20 10:04:02 EDT 2006


  User: timfox  
  Date: 06/07/20 10:04:02

  Modified:    src/main/org/jboss/jms/server/endpoint  
                        ServerConnectionEndpoint.java
                        ServerConsumerEndpoint.java
  Log:
  http://jira.jboss.com/jira/browse/JBMESSAGING-440
  
  Revision  Changes    Path
  1.47      +14 -62    jboss-jms/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerConnectionEndpoint.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -b -r1.46 -r1.47
  --- ServerConnectionEndpoint.java	19 Jul 2006 16:21:15 -0000	1.46
  +++ ServerConnectionEndpoint.java	20 Jul 2006 14:04:02 -0000	1.47
  @@ -70,9 +70,9 @@
    * 
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  - * @version <tt>$Revision: 1.46 $</tt>
  + * @version <tt>$Revision: 1.47 $</tt>
    *
  - * $Id: ServerConnectionEndpoint.java,v 1.46 2006/07/19 16:21:15 timfox Exp $
  + * $Id: ServerConnectionEndpoint.java,v 1.47 2006/07/20 14:04:02 timfox Exp $
    */
   public class ServerConnectionEndpoint implements ConnectionEndpoint
   {
  @@ -400,45 +400,15 @@
                     try
                     {
                        tx.rollback();
  -                  }
  -                  catch (Exception e)
  -                  {
  -                     log.error("Failed to rollback tx", e);
  -                  }
  -               }
                  throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
               }
  -         }
  -         else if (request.getRequestType() == TransactionRequest.ONE_PHASE_ROLLBACK_REQUEST)
  -         {
  -            if (trace) { log.trace("one phase rollback request received"); }
  -                    
  -            Transaction tx = null;
  -            try
  -            {             
  -               //Nothing to do on rollback
  -//               tx = tr.createTransaction();
  -//               processTransaction(request.getState(), tx);
  -//               tx.rollback();
  -            }
  -            catch (Throwable t)
  -            {
  -               //FIXME - Is there any point trying to roll back here?
  -               log.error("Exception occured", t);
  -               if (tx != null)
  -               {                  
  -                  try
  -                  {
  -                     tx.rollback();
  -                  }
                     catch (Exception e)
                     {
                        log.error("Failed to rollback tx", e);
  +                     throw new MessagingJMSException("Failed to rollback tx after commit failure", e);
                     }
                  }
  -               throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
               }
  -            
            }
            else if (request.getRequestType() == TransactionRequest.TWO_PHASE_PREPARE_REQUEST)
            {                        
  @@ -459,13 +429,14 @@
                     try
                     {
                        tx.rollback();
  +                     throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
                     }
                     catch (Exception e)
                     {
                        log.error("Failed to rollback tx", e);
  +                     throw new MessagingJMSException("Failed to rollback transaction after failure in prepare", e);
                     }
                  }
  -               throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
               }
            }
            else if (request.getRequestType() == TransactionRequest.TWO_PHASE_COMMIT_REQUEST)
  @@ -482,18 +453,9 @@
               catch (Throwable t)
               {
                  log.error("Exception occured", t);
  -               if (tx != null)
  -               {                  
  -                  try
  -                  {
  -                     tx.rollback();
  -                  }
  -                  catch (Exception e)
  -                  {
  -                     log.error("Failed to rollback tx", e);
  -                  }
  -               }
  -               throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
  +               //For 2PC commit we don't rollback if failure occurs - this allows the transaction manager
  +               //to try again if the problem was transitory
  +               throw new MessagingJMSException("Failed to commit transaction", t);
               }
            }
            else if (request.getRequestType() == TransactionRequest.TWO_PHASE_ROLLBACK_REQUEST)
  @@ -510,18 +472,8 @@
               catch (Throwable t)
               {
                  log.error("Exception occured", t);
  -               if (tx != null)
  -               {                  
  -                  try
  -                  {
  -                     tx.rollback();
  -                  }
  -                  catch (Exception e)
  -                  {
  -                     log.error("Failed to rollback tx", e);
  -                  }
  -               }
  -               throw new MessagingTransactionRolledBackException("Transaction was rolled back.", t);
  +               
  +               throw new MessagingJMSException("Failed to rollback transaction", t);
               }
            }      
                    
  
  
  
  1.45      +17 -12    jboss-jms/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServerConsumerEndpoint.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-jms/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -b -r1.44 -r1.45
  --- ServerConsumerEndpoint.java	17 Jul 2006 17:14:46 -0000	1.44
  +++ ServerConsumerEndpoint.java	20 Jul 2006 14:04:02 -0000	1.45
  @@ -67,9 +67,9 @@
    *
    * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
    * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  - * @version <tt>$Revision: 1.44 $</tt>
  + * @version <tt>$Revision: 1.45 $</tt>
    *
  - * $Id: ServerConsumerEndpoint.java,v 1.44 2006/07/17 17:14:46 timfox Exp $
  + * $Id: ServerConsumerEndpoint.java,v 1.45 2006/07/20 14:04:02 timfox Exp $
    */
   public class ServerConsumerEndpoint implements Receiver, Filter, ConsumerEndpoint
   {
  @@ -97,8 +97,6 @@
   
      private Selector messageSelector;
      
  -   private DeliveryCallback deliveryCallback;
  -
      private JBossDestination destination;
      
      private List toDeliver;
  @@ -546,10 +544,13 @@
         {
            d = (SingleReceiverDelivery)deliveries.get(new Long(messageID));
         }
  +      
  +      DeliveryCallback deliveryCallback = (DeliveryCallback)tx.getKeyedCallback(this);
  +            
         if (deliveryCallback == null)
         {
            deliveryCallback = new DeliveryCallback();
  -         tx.addCallback(deliveryCallback);
  +         tx.addKeyedCallback(deliveryCallback, this);
         }
         deliveryCallback.addMessageID(messageID);
            
  @@ -848,6 +849,12 @@
         }
      }
      
  +   /**
  +    * 
  +    * The purpose of this class is to remove deliveries from the delivery list on commit
  +    * Each transaction has once instance of this per SCE
  +    *
  +    */
      private class DeliveryCallback implements TxCallback
      {
         List delList = new ArrayList();
  @@ -872,7 +879,7 @@
            //NOOP
         }
         
  -      public void afterCommit(boolean onePhase) throws TransactionException
  +      public synchronized void afterCommit(boolean onePhase) throws TransactionException
         {
            // Remove the deliveries from the delivery map.
            Iterator iter = delList.iterator();
  @@ -885,16 +892,14 @@
                  throw new TransactionException("Failed to remove delivery " + messageID);
               }
            }
  -
  -         deliveryCallback = null;
         }
         
         public void afterRollback(boolean onePhase) throws TransactionException
         {                   
  -         //Do nothing
  +         //NOOP
         }
         
  -      void addMessageID(long messageID)
  +      synchronized void addMessageID(long messageID)
         {
            delList.add(new Long(messageID));
         }
  
  
  



More information about the jboss-cvs-commits mailing list