I have a simple 3-step flow:
public Job myJob() {
Step extract = extractorStep();
Step process = filesProcessStep();
Step cleanup = cleanupStep();
return jobBuilderFactory.get("my-job")
.flow(echo("Starting job"))
.next(extract)
.next(process)
.next(cleanup)
.next(echo("Ending job"))
.end()
.build();
}
Now I want to add error processing using ExitStatus from StepExecutionListener.afterStep(). Any error should forward flow to cleanup step. So I changed to the code below:
public Job myJob() {
Step extract = extractorStep();
Step process = filesProcessStep();
Step cleanup = cleanupStep();
return jobBuilderFactory.get("my-job")
.start(echo("Starting batch job"))
.next(extract).on(ExitStatus.FAILED.getExitCode()).to(cleanup)
.from(extract).on("*").to(process)
.next(process).on(ExitStatus.FAILED.getExitCode()).to(cleanup)
.from(process).on("*").to(cleanup)
.next(echo("End batch job"))
.end()
.build();
}
Now I have an infinite loop to the cleanup step. I would like some help to correct this flow.