Coverage Report - org.mule.endpoint.outbound.OutboundTxRollbackMessageProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
OutboundTxRollbackMessageProcessor
0%
0/11
0%
0/6
3.5
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.endpoint.outbound;
 8  
 
 9  
 import org.mule.api.MuleEvent;
 10  
 import org.mule.api.MuleException;
 11  
 import org.mule.api.transaction.Transaction;
 12  
 import org.mule.api.transaction.TransactionException;
 13  
 import org.mule.processor.AbstractInterceptingMessageProcessor;
 14  
 import org.mule.transaction.TransactionCoordination;
 15  
 
 16  
 /**
 17  
  * MessageProcessor implementation that stops outbound flow is the current
 18  
  * transaction has been rolled back.
 19  
  */
 20  0
 public class OutboundTxRollbackMessageProcessor extends AbstractInterceptingMessageProcessor
 21  
 {
 22  
     public MuleEvent process(MuleEvent event) throws MuleException
 23  
     {
 24  
         // No point continuing if the service has rolledback the transaction
 25  0
         if (isTransactionRollback())
 26  
         {
 27  0
             return event;
 28  
         }
 29  
         else
 30  
         {
 31  0
             return processNext(event);
 32  
         }
 33  
     }
 34  
 
 35  
     /**
 36  
      * Checks to see if the current transaction has been rolled back
 37  
      */
 38  
     protected boolean isTransactionRollback()
 39  
     {
 40  
         try
 41  
         {
 42  0
             Transaction tx = TransactionCoordination.getInstance().getTransaction();
 43  0
             if (tx != null && tx.isRollbackOnly())
 44  
             {
 45  0
                 return true;
 46  
             }
 47  
         }
 48  0
         catch (TransactionException e)
 49  
         {
 50  
             // TODO MULE-863: What should we really do?
 51  0
             logger.warn(e.getMessage());
 52  0
         }
 53  0
         return false;
 54  
     }
 55  
 }