I'm using the Spring Batch (2.2.6.RELEASE) FlowBuilder.SplitBuilder
to declare a flow in a Java Config class, which executes 3 subflows in parallel:
@Bean
public SimpleFlow mainFlow() {
return new FlowBuilder<SimpleFlow>("Main Flow")
.start(flow1())
.split(new SimpleAsyncTaskExecutor())
.add(flow2(), flow3())
.build();
}
This syntax comes from spring-batch FlowBuilder.SplitBuilder
javadoc .
But then, flow1
is never executed; only flow2
and flow3
are executed.
It looks like a bug to me... What do you think?
A junit test can be found in class ParallelFlowsJobConfigTest
on this github repository: https://github.com/galak75/spring-batch-labs
This worked for me:
@Bean
public SimpleFlow mainFlow() {
SimpleFlow splitFlow = new FlowBuilder<SimpleFlow>("Split Flow")
.split(new SimpleAsyncTaskExecutor())
.add(flow2(), flow3())
.build();
return new FlowBuilder<SimpleFlow>("Main Flow")
.start(flow1())
.next(splitFlow)
.end();
}
The important detail is the "next(...)" and the fact that slit should be in its own sub-flow.
由BATCH-2346解决,在Spring Batch 3.0.4版本中提供。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.