Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch goes to the next step even after Exception is thrown. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

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

    Comment

    Working...
    X