Bowen
Bowen

Reputation: 165

Skip a step when restart a job in spring batch

currently i am working on a task using spring batch.

there is a job which contains 3 steps: step1, step2, step3.

The first execution: step1, step2, step3.

If step2 is fail, we will restart the job.

but the second time, we want the job skip step2, that means: step1, step3.

Does anyone have a solution with skip a specific step when restart a job?

Upvotes: 1

Views: 1671

Answers (1)

Luca Basso Ricci
Luca Basso Ricci

Reputation: 18403

You can use JobRepository interface to query about a step (there is a JobRepository.getStepExecutionCount() method); with a JobExecutionDecider you can flow to step2 or step3 based upon JobRepository.getStepExecutionCount() result

Upvotes: 1

Related Questions