java – Spring Batch SplitBuilder不执行启动流程
作者:互联网
我正在使用Spring Batch(2.2.6.RELEASE)FlowBuilder.SplitBuilder来声明Java Config类中的流,该类并行执行3个子流:
@Bean
public SimpleFlow mainFlow() {
return new FlowBuilder<SimpleFlow>("Main Flow")
.start(flow1())
.split(new SimpleAsyncTaskExecutor())
.add(flow2(), flow3())
.build();
}
此语法来自spring-batch FlowBuilder.SplitBuilder
javadoc.
但是,flow1永远不会被执行;只执行flow2和flow3.
对我来说这看起来像个小虫……你怎么看?
可以在此github存储库上的ParallelFlowsJobConfigTest类中找到junit测试:https://github.com/galak75/spring-batch-labs
解决方法:
这对我有用:
@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();
}
重要的细节是“下一个(…)”以及狭缝应该在其自己的子流中的事实.
标签:java,spring,spring-batch,spring-java-config 来源: https://codeday.me/bug/20190629/1321958.html