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

  • Suppress exception propagation and "outer" transaction rollback

    Hi!

    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


    Problem:
    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:
    Code:
    	<si:service-activator input-channel="startOuterTX.in" output-channel="nullChannel"
    		ref="outerGW" method="sendInTx" />
    	<si:gateway id="outerGW"
    		service-interface="com.example.si.gateway.TransactionalGateway" 
    		default-request-channel="toSplitter" default-reply-channel="stopOuterTX.in" />
    
    
    	<si:service-activator input-channel="startInnerTx.in" output-channel="aggregateSplittedMessages"
    		ref="innerGW" method="sendInNewTx" />
    	<si:gateway id="innerGW"
    		service-interface="com.example.si.gateway.TransactionalGateway" 
    		default-request-channel="doStuff" 
    		error-channel="innerGwErrorChannel.in" />
    TransactionalGateway interface looks like this:
    Code:
    public interface TransactionalGateway {
    		
    	@Transactional
    	public Message<?> sendInTx(Message<?> msg);
    	
    	@Transactional(propagation=Propagation.REQUIRES_NEW)
    	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.
    Code:
    	<si:transformer input-channel="innerGwErrorChannel.in"
    	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:
    Code:
    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.

    Comment


    • #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.

      Comment

      Working...
      X