Hi,
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.Code:<job id="settlementReportJob" xmlns="http://www.springframework.org/schema/batch"> <step id="createFilesStep"> <tasklet transaction-manager="jpaTransactionManager"> <chunk reader="ReportDataLoader" processor="ReportDataProcessor" writer="ReportBuilder" commit-interval="-1" /> </tasklet> </step> </job> <bean id="ReportDataLoader" class="org.springframework.batch.item.database.JpaPagingItemReader" scope="step"> <property name="entityManagerFactory" ref="AS400entityManagerFactory"/> <property name="queryString" value="select a from Sdjphy01 a order by customer"/> </bean>


Reply With Quote