Reputation: 116
I am trying the below job configuration for spring batch, but it doesn't seem to executing the steps in the order that I need. What am I doing wrong with the configuration?
Spring batch version : 4.3.6
Instead of above, its executing - step1 -> step3 -> step2..
public Job dataFetchJob() {
return jobBuilderFactory
.get("dataFetchJob")
.incrementer(new RunIdIncrementer())
.start(step1())
.next(decider())
.on(PROCESS_EVENTS)
.to(step2())
.from(decider())
.on(NO_EVENTS)
.to(step3(fileReader(), fileProcessor(), fileWriter()))
.next(step2())
.next(step3(fileReader(), fileProcessor(), fileWriter()))
.next(step4(indexReader(), indexProcessor(), indexWriter()))
.end()
.listener(dataListener())
.build();
}
Upvotes: 0
Views: 510
Reputation: 116
I sorted it out. We have to use "from" to start the flow from the branch. Below is the way I have configured the job now and it works as expected.
public Job dataFetchJob() {
return jobBuilderFactory
.get("dataFetchJob")
.incrementer(new RunIdIncrementer())
.start(step1())
.next(decider())
.on(PROCESS_EVENTS)
.to(step2())
.from(decider())
.on(NO_EVENTS)
.to(step3(fileReader(), fileProcessor(), fileWriter()))
.from(step3(fileReader(), fileProcessor(), fileWriter()))
.next(step4(indexReader(), indexProcessor(), indexWriter()))
.from(step2())
.next(step3(fileReader(), fileProcessor(), fileWriter()))
.next(step4(indexReader(), indexProcessor(), indexWriter()))
.end()
.listener(dataListener())
.build();
}
Upvotes: 1