I know the way chunk based processing works is that it reads a specified amount in the ItemReader, passes this to ItemProcessor who then works on this list one by one and then passes the list to ItemWriter. I was just wondering if there was a way to call ItemWriter from Item Processor before the chunk is completed or irrespective of chunk size.
Basically in the code below I want to call the ReportBuilder bean (ItemWriter) when I see a new Customer (notice how I am ordering by this field in the Reader). So when Processor sees a new value for this field it should write out the data it has built so far. This way each separate Customer will be a separate report.
Thanks in advance for any help.
<job id="settlementReportJob" xmlns="http://www.springframework.org/schema/batch">
<chunk reader="ReportDataLoader" processor="ReportDataProcessor"
writer="ReportBuilder" commit-interval="-1" />
<property name="entityManagerFactory" ref="AS400entityManagerFactory"/>
<property name="queryString" value="select a from Sdjphy01 a order by customer"/>