This is a simple example of a Spring Batch job running in parallel, leveraging the Multi-Threaded step with synchronized reader strategy.
mvn install
- execute
experiments.sync.App
An example of output we get from executing App:
As we can see, parallel execution is much, much faster than the async version.
It's super easy. There are only 2 simple steps:
<bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
<batch:tasklet
task-executor="taskExecutor"
throttle-limit="20">
<batch:chunk
reader="basicItemReader"
processor="compositeProcessor"
writer="basicItemWriter"
commit-interval="10">
</batch:chunk>
</batch:tasklet>
@Override
public synchronized Item read() throws ItemReaderException {
return items.poll();
}