Spring Batch Step Conditional Flow (Java Config)
<job id="job">
<step id="stepA" parent="s1">
<next on="*" to="stepB" />
<next on="FAILED" to="stepC" />
</step>
<step id="stepB" parent="s2" next="stepC">
<next on="*" to="stepD" />
<next on="FAILED" to="stepC" />
</step>
<step id="stepC" parent="s3" />
<step id="stepD" parent="s4" />
</job>
- java Config
public Job job(Tasklet01 tasklet01, Tasklet02 tasklet02, Tasklet03 tasklet03, Tasklet04 tasklet04,) {
return JobBuilderFactory.get("jobNmae")
.start(stepA(tasklet01))
.on("FAILED").to(StepC(tasklet03))
.from(StepA(tasklet01))
.next(StepB(tasklet02))
.on("FAILED").to(StepC(tasklet03))
.from(StepB(tasklet02))
.next(StepD(tasklet04))
.end()
.build();
- You can control ExitSatus which is used on(“HERE”) using spring batch Context for example :
I wrote the below code in Tasklet.
chunkContext.getStepContext().getStepExecution().setStatus(BatchStatus.FAILED);"
hope this help you!
Awesome thanks i was looking for this, this way is so much better and cleaner than if else approach. i'm facing a test framework for two applications very similar but in some points or process they differ
답글삭제so i can add extra steps or distinct steps whether if it's one app or another