我已经扩展了FlowJob类,并按如下方式设置了流程:
final Flow subflow1 = new FlowBuilder<Flow>("subflow1")
.start(new StepBuilder("SubFlow1-step")
.chunk(1000)
.reader(reader)
.writer(writer)
.repository(jobRepository)
.transactionManager(txManager).build())
.end();
final Flow subflow2 = new FlowBuilder<Flow>("subflow2")
.start(new StepBuilder("SubFlow2-step")
.chunk(1000)
.reader(reader)
.writer(writer)
.taskExecutor(new SimpleAsyncTaskExecutor())
.repository(jobRepository)
.transactionManager(txManager).build())
.end();
setFlow(new FlowBuilder<Flow>("Flow")
.start(new StepBuilder("Flow-step1")
.chunk(10000)
.reader(reader)
.writer(writer)
.repository(jobRepository)
.transactionManager(txManager).build())
.next(new StepBuilder("Flow-step2")
.tasklet(processor)
.repository(jobRepository)
.transactionManager(txManager).build())
.split(new SimpleAsyncTaskExecutor())
.add(subflow1, subflow2)
.end());
如您所见,我想做的事情如下:
当我运行我的工作时,步骤1和2正确执行,然后作业终止。
有什么想法吗?
编辑:关于SO Spring-batch flow / split after a step的相关问题。
答案 0 :(得分:2)
我相信有关于此的错误记录。目前,解决方法是使用拆分创建流,并将流添加到作业,如下所示:
@Bean
public Job splitJob(@Qualifier("foo") Flow foo, @Qualifier("foo") Flow bar) {
FlowBuilder<Flow> flowBuilder = new FlowBuilder<>("split");
Flow flow = flowBuilder.split(new SimpleAsyncTaskExecutor())
.add(foo, bar)
.end();
return jobBuilderFactory.get("splitJob")
.start(myStep1())
.next(myStep2())
.on("COMPLETED").to(flow)
.end()
.build();
}