Sep 19th, 2012, 10:26 AM
Spring Batch goes to the next step even after Exception is thrown.
I have a Spring Batch job with 6 steps. For testing purposes, I sometimes throw an exception at the end of the 4th step in the step listener's afterProcess() method. However, the job does not step, but instead the 5th and the 6th steps still execute. Is this the default behavior? If so, how can I ensure that the job stops when I throw the exception?
Sep 19th, 2012, 11:58 AM
Exceptions thrown from a StepExecutionListener.afterStep() have no effect on the execution, they will only be logged. You can return ExitStatus.FAILED from the listener though, which will fail the job.