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