I have a spring Batch Chunk based job with (Custom Reader, Custom Processor, Custom Writer Any thread should follow this order). If i start 10 threads they should run in parallel doing their own sequence of reading,processing,writing in order.
Thread 1-->In order: Read, process, write
Thread 2-->In order: Read, process, write...etc
How to implement this behavior. Currently i have code working in single thread model as below. (I think. Not sure). I want commit-interval in batch:chunk as '1' only (Because i need to read file line by line).
<!-- Reader bean for our simple Text file -->
<bean id="productReader" class="com.mycompany.batching.reader.productItemReader"
scope="step">
<property name="userId" value="#{jobParameters['userId']}" />
<property name="dataId" value="#{jobParameters['dataId']}" />
</bean>
<!-- Processor for the data red from text file -->
<bean id="productProcessor" class="com.mycompany.batching.processor.productItemProcessor">
</bean>
<!-- Persisting data to database -->
<bean id="productWriter" class="com.mycompany.batching.writer.productItemWriter">
</bean>
<batch:job id="simpleProductImportJob" xmlns="http://www.springframework.org/schema/batch">
<batch:step id="importFileStep">
<batch:tasklet>
<batch:chunk reader="productReader" processor="productProcessor"
writer="productWriter" commit-interval="1" />
</batch:tasklet>
</batch:step>
</batch:job>
How to make this multi threaded.?