I am using Spring Batch 3.0.3, configured with annotation to create a batch job that repeats the step an undetermined number of times.
My first step will be to read into the memory a list of elements used during the repeating step. I would like the repeating steps to be repeated in this vacancy list.
How can I set up my work to perform the same step x times? I saw examples in the xml step, indicating the next step to run. I think I could point out two steps to each other in an infinite loop until the list is repeated. Will this work and is there a way to do this with annotations? Below is my main configuration file with some code that didn't work.
@ComponentScan(excludeFilters = @Filter(IgnoreDuringScan.class))
@EnableAutoConfiguration
@EnableBatchProcessing
@Loggable
public class BatchCrudConfiguration
{
@Bean
public Job batchCRUDJob(JobBuilderFactory jobBuilderFactory, Step[] processSheetSteps)
{
JobBuilder jobBuilder = jobBuilderFactory.get("batchCRUDJob").incrementer(new RunIdIncrementer());
FlowBuilder<FlowJobBuilder> jobFlowBuilder = jobBuilder.flow(processSheetSteps[0]);
for (int i = 1; i < processSheetSteps.length; i++)
{
jobFlowBuilder = jobFlowBuilder.next(processSheetSteps[i]);
}
return jobFlowBuilder.end().build();
}
@Bean
public Step[] processSheetSteps(
StepBuilderFactory stepBuilderFactory,
RawDataReader[] readers,
DelegatingWriter writer,
DelegatingProcessor processor,
@Value("${batchcrud.chunkSize}") int chunkSize)
{
int numberOfReaders = readers.length;
Step[] steps = new Step[numberOfReaders];
for (int i = 0; i < numberOfReaders; i++)
{
steps[i] = stepBuilderFactory.get("processSheet" + i + "Step").<RawData, DataItem>
chunk(chunkSize).reader(readers[i]).processor(processor).writer(writer).build();
}
return steps;
}