Oct 5th, 2007, 09:38 AM
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:advisor pointcut="execution(* org.springframework.batch.sample.item..*Processor+ .*(..))"
<tx:advice id="txAdvice2" transaction-manager="transactionManager">
<tx:method name="*" propagation="NESTED" />
Oct 5th, 2007, 04:46 PM
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().