I would like to generate a summary report at the end of my batch execution.
For ex: I have an ItemProcessor which receives accountId.
for every accountId:
get MarketplaceId's
for every marketplaceId:
call real time availability
At the end of batch execution I need to provide a nice summary in a file that shows,
Question
Would be really great if you provide any directions.
Thanks.
write a tasklet to prepare a nice summery and put that tasklet as last step in the 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 your own code to Prepare a neat summary preparation File
return null;
}
}
Holder Class is
import org.springframework.stereotype.Component;
@Component
public class Holder {
private List<Integer> results1;
private List<Integer> results2;
//Setter and getter methods
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With