I am reading the spring batch documentation and stuck on following part:
There are provided following example:
@Bean
public Job job() {
Flow flow1 = new FlowBuilder<SimpleFlow>("flow1")
.start(step1())
.next(step2())
.build();
Flow flow2 = new FlowBuilder<SimpleFlow>("flow2")
.start(step3())
.build();
return this.jobBuilderFactory.get("job")
.start(flow1)
.split(new SimpleAsyncTaskExecutor())
.add(flow2)
.next(step4())
.end()
.build();
}
But it is not explained what is happening.
as far I understand flow1 and flow2 are executed in parallel but what about step4 ?
step4()is executed linearly afterflow1andflow2returned.Look at the
FlowBuilder.SplitBuilder.add()javadoc :It returns the parent builder and not the current
SplitBuilderobject.So it is not included in the flow split and so is executed sequentially.
To run the 3 flows in parallel :