我已经创建了多个作业,并且我在一个循环中运行多个作业,我要求按顺序运行这些作业,但是所有步骤的项目阅读器都在运行,然后所有作业的项目编写器都在按顺序运行,是否有任何解决方案,以便当作业的项目阅读器和项目编写器完成,然后控制转到另一个作业。
示例代码如下:
public void jobprocess() throws Exception {
List<Job> jobList = BatchJob.fetchAllJobs();
for(Job job:jobList){
jobLauncher.run(job, params);
}
}
public List<Job> fetchAllJobs() throws Exception {
List<Object> list = service.findAll();
List<Job> jobBuilderList = new ArrayList<>();
int i = 0;
for(Object obj:list){
Step step = stepBuilderFactory.get("step"+i)
.<Student, Student>chunk(500)
.reader(ListItemReaderV2(obj))
.processor(Processor)
.writer(Writer)
.build();
jobBuilderList.add(jobBuilderFactory.get("job"+i)
.incrementer(new RunIdIncrementer())
.listener(this)
.start(step)
.build());
i++;
}
return jobBuilderList;
}