Spring batch generating reports -
i generate summary report @ end of batch execution.
for ex: have itemprocessor receives accountid.
for every accountid: marketplaceid's every marketplaceid: call real time availability
at end of batch execution need provide nice summary in file shows,
- number of accounts processed
- number of marketplaceids each accoutid
- number of marketplaceids failed real time availability
- time took processing 1 accountid
question
- where persist intermediate results ie. different count on each iteration
- how counts next step summary file writer
would great if provide directions.
thanks.
write tasklet prepare nice summery , put tasklet last step in job
<step id="summeryfile" > <tasklet ref="summaryfilepreparationtasklet"/> </step>
and bean configuration is
<bean id="summaryfilepreparationtasklet" class="com.baji.batch.summarypreparationfile">
and class file is
package com.baji.batch; import org.springframework.batch.core.stepcontribution; import org.springframework.batch.core.scope.context.chunkcontext; import org.springframework.batch.core.step.tasklet.tasklet; import org.springframework.batch.repeat.repeatstatus; /** * @author * bhaji shaik * may 30, 2015 */ public class summarypreparationfile implements tasklet { @autowired private holder holder; @override public repeatstatus execute(stepcontribution arg0, chunkcontext chunkcontext) throws exception { holder.getresults1(); //write own code prepare neat summary preparation file return null; } }
holder class
import org.springframework.stereotype.component; @component public class holder { private list<integer> results1; private list<integer> results2; //setter , getter methods }
Comments
Post a Comment