Announcement Announcement Module
Collapse
No announcement yet.
How to configure NESTED transactions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to configure NESTED transactions

    I am trying to configure a Logical Unit of Work for the RestartSample. I have modified RestartFunctionalTests so that there is only one invokation of runJob() . The end game is to rollback ALL updates in the Step on the BatchCriticalException i.e. atomic operation = whole step complete.

    I have configured the processor to use NESTED transaction propogation via Spring AOP (listed below), however when I run the RestartSample only a partial rollback is observered i.e. some records are commited. I have tried commenting out commit interval but no change.

    I it possible to configure Spring Batch to use NESTED transaction? If so how does this interact with commit interval settings? Are they conficting requirements?



    <aop:config>
    <aop:advisor pointcut="execution(* org.springframework.batch.sample.item..*Processor+ .*(..))"
    advice-ref="txAdvice2" />
    </aop:config>
    <tx:advice id="txAdvice2" transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="*" propagation="NESTED" />
    </tx:attributes>
    </tx:advice>

  • #2
    If I understand corrcectly you want a single transaction for the whole step? I'm not sure why NESTED transactions at the processor level would help with that, so if I am missing something give us an update.

    To extend the transaction boundary to the whole step, basically means one chunk per step, so the completion policy per chunk needs to be modiied. You can set the commitInterval to Integer.MAX_VALUE on the StepConfiguration, or you can use a custom chunkOperations with a DefaultResultCompletionPolicy.

    Another option might be to start a transaction declaratively at a much higher level than you have chosen (I haven't tried this but it should work) - e.g. StepExecutor.process().

    Comment

    Working...
    X