Mar 26th, 2011, 09:44 AM
My job.xml contain a step with reader, processor and Writer. If any business exception occurs, then current chunk should rollback and pick the next chunk to process.
Can I use RepeatTemplate?
If the answer is yes, then how to configure the RepeatTemplate for my case?
<job id="Batch_ControllerJob" restartable="true"
<chunk reader="pricesLoadItemReader" processor="pricesLoadItemProcessor"
<include class="batch.core.exception.PricesLoadNoRollbackEx ception" />
Mar 26th, 2011, 03:43 PM
In think, in your case skippable-exception-classes best match your goal. See Configuring Skip Logic.
Mar 28th, 2011, 12:00 AM
Thanks for your reply.
skippable-exception-classes will rollback the current transaction?
In the processor I am throwing the business exception, if that exception is configured in the skippable-exception-classes it will rollback?
In my case, according to the business exception either I need to rollback the current transaction or without rollback I need to continue with the next chunk.
Mar 28th, 2011, 03:08 AM
there's no rollback if a skippable exception is thrown from the reader. There's a rollback if a skippable exception is thrown from the processor or writer. This is the default behavior.
Mar 28th, 2011, 03:20 AM
Thanks for your reply arno.
Originally Posted by arno
Can I configure ,
1. All rollback business exceptions in the skippable-exception-classes ?
2. All Non rollback business exceptions in the no-rollback-exception-classes?
Mar 28th, 2011, 08:45 AM
Perhaps the following will give you a hint:
Originally Posted by arun4
A skippable exception should be also listed as no-rollback exception (otherwise it does not make sense).
Mar 28th, 2011, 09:07 AM
Actually, I would say that is not the normal best practice (and it isn't the default behaviour). By default I would expect that if there is an exception you want to rollback, and that's what the framework assumes too. The skip listener will be called in the next transaction (if it is successful) - maybe that's what confuses people?
Originally Posted by dma_k
Mar 28th, 2011, 09:31 AM
Really glad to see your reply. Thanks.
Analayzing the issue in two perspectives:
1) Generating a business exception + roll back (according to business)
2) Generating a business exception + (no roll back)
In both of these scenarios, the batch should continue with the next chunk.
How will spring see these business exceptions and roll backing issues?
what are the configurations to be done to execute the above stated business?
Can u also highlight, if there are any sample jobs (with roll back + non roll back + next chunk processing) present?
Mar 30th, 2011, 12:59 AM
I guess you need to mark both kinds of business exceptions skippable and mark only one with no-rollback (using the appropriate XML tags, see reference documentation).
If you really want to be sure about the behavior, you can also write an integration test with mock or stub reader/processor/writer and check the metadata for the number of rollbacks.