Announcement Announcement Module
No announcement yet.
Suppress exception propagation and "outer" transaction rollback Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Suppress exception propagation and "outer" transaction rollback


    I am having issues suppressing errors in my Gateway error flow. Instead of just rolling back the inner tx, I get "Transaction rolled back because it has been marked as rollback-only" and everything is rolled back.

    Flow overview:

    Poller -> Start Outer Tx (Propagation REQUIRED) -> getList -> Slitter -> StartInnerTx(propagation REQUIRES_NEW) ->
    ->DoStuff -> StopInnerTx -> aggregator -> StopOuterTx

    Exception occurring in "DoStuff" does not only rollback the inner tx but also causes "Transaction rolled back because it has been marked as rollback-only".

    GW configuration:
    	<si:service-activator input-channel="" output-channel="nullChannel"
    		ref="outerGW" method="sendInTx" />
    	<si:gateway id="outerGW"
    		default-request-channel="toSplitter" default-reply-channel="" />
    	<si:service-activator input-channel="" output-channel="aggregateSplittedMessages"
    		ref="innerGW" method="sendInNewTx" />
    	<si:gateway id="innerGW"
    		error-channel="" />
    TransactionalGateway interface looks like this:
    public interface TransactionalGateway {
    	public Message<?> sendInTx(Message<?> msg);
    	public Message<?> sendInNewTx(Message<?> msg);
    The inner GW error handling flow only tries to create a success response. No reply channel set in the xml.
    	<si:transformer input-channel=""
    	ref="errorTransformer" method="transformErrorToFailedMessage"  />
    I have tried a lot of different error transformation code as I am unsure which header values that should be set on the outgoing message. It either results in the gateway hanging as an incorrect reply header is set or I get the "transaction marked as rollback only"-exception.

    Here is one example of error transformation code I tried:
    return message.getPayload().getFailedMessage();
    Any ideas how the error flow for an inner gateway should be configured to avoid exception to propagate upwards?
    The REQUIRES_NEW transaction configuration seems to be ok. At least the logs says that the inner tx is rolled back and closed and then that the suspended outer transaction is resumed.

    All ideas are welcome

  • #2
    The error handling needs to be on the first gateway.

    If you trap the error on the second gateway, the inner tx (and the outer) will commit.


    • #3
      That said, given that you have splitter/aggregator in the outer portion, you probably need a third gateway, after the splitter, and put the error handling on that.