1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
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 | |
|
18 | |
|
19 | |
|
20 | 0 | public class OutboundTxRollbackMessageProcessor extends AbstractInterceptingMessageProcessor |
21 | |
{ |
22 | |
public MuleEvent process(MuleEvent event) throws MuleException |
23 | |
{ |
24 | |
|
25 | 0 | if (isTransactionRollback()) |
26 | |
{ |
27 | 0 | return event; |
28 | |
} |
29 | |
else |
30 | |
{ |
31 | 0 | return processNext(event); |
32 | |
} |
33 | |
} |
34 | |
|
35 | |
|
36 | |
|
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 | |
|
51 | 0 | logger.warn(e.getMessage()); |
52 | 0 | } |
53 | 0 | return false; |
54 | |
} |
55 | |
} |