I am working on a Spring Batch job with the following workflow:
Start
Step: Fetch the list of IDs to export via an SQL query.
While there are data in the list, perform the following steps:
- Step: Fetch data for the next ID via an SQL query
- Step: Compress the fetched data
End
I tried to create a flow containing my two tasks to loop over.
public Flow myFlow(){
FlowBuilder<SimpleFlow> flowBuilder = new FlowBuilder<>("processFlow");
flowBuilder.start(getDataStep());
flowBuilder.next(compressDataStep());
flowBuilder.end();
return flowBuilder.build();
}
Then use a FlowJob to integrate into the Flow, but it doesn't work :
public FlowJobBuilder jobBuilder() {
JobBuilder jobBuilder = new JobBuilder(getJobDescription().getJobName(), jobRepository);
FlowJobBuilder sjb = new FlowJobBuilder(jobBuilder);
MyDecider decider = new MyDecider();
sjb.start(startStep())
.next(myFlow())
.next(decider).on("COMPLETED").to(endStep())
.from(decider).on("REPEAT").to(myFlow())
.end()
.build();
return sjb;
}
Do you have a way to loop over a group of Steps in Spring Batch until a condition is met?