Reputation: 4649
I am using spring batch
for processing
large data
.
My problem is I have two different Tasklet
that are executing
one after another
. I can not run it parallel as second tasklet has some dependency one first Tasklet
. In order to save the time I would like to start next Tasklet
immediately after the first few items
has been processed
by previous tasklet
. As Spring Batch
uses a Chunk Oriented
processing style. Can ItemWriter
of one Tasklet
, pass chunk of already processed items to another Tasklet
's ItemReader
or ItemProcessor
or ItemWriter
for next processing? But while the another tasklet
is working on the chunk
, previous tasklet
should NOT
wait and it should continue iteration
over next
chunk
.
Upvotes: 0
Views: 465
Reputation: 3868
Based on your description and additional information above, I would simply leverage a CompositeItemWriter
to accomplish this.
The list of items will first be written by WriterOne and then be passed to and written by WriterTwo.
<bean id="compositeWriter"
class="org.springframework.batch.item.support.CompositeItemWriter">
<property name="delegates">
<list>
<ref bean="writerOne" />
<ref bean="writerTwo" />
</list>
</property>
</bean>
<bean id="writerOne" ... />
<bean id="writerTwo" ... />
Upvotes: 1