concept multithreade step in category spring

This is an excerpt from Manning's book Spring Batch in Action.
Make sure you check the documentation of the readers and writers you use before configuring a step for multithreading. Most of the built-in Spring Batch readers and writers aren’t thread-safe and therefore are unsafe for use in a multithreaded step. If the Javadoc for a class doesn’t document thread safety, you need to look at the implementation to determine thread safety and make sure the code is stateless. You can still work with thread-safe (stateless) readers and writers; see the Spring Batch parallelJobs example, which demonstrates using a progress indicator for reading items from a database.
Configuring a multithreaded step in Spring Batch is simple because it involves only specifying a task executor for the step’s tasklet. Spring Batch then automatically enables multithreading for the step and uses the task executor to process chunks.
Listing 13.2. Configuring a multithreaded step
<batch:job id="importProductsMultiThreadedJob"> <batch:step id="readWriteProductsMultiThreadedStep"> <batch:tasklet task-executor="taskExecutor"> <batch:chunk reader="reader" writer="writer" commit-interval="10"/> </batch:tasklet> </batch:step> </batch:job> <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="5"/> <property name="maxPoolSize" value="5"/> </bean>
The following listing uses the throttle-limit attribute to configure a multithreaded step.