I have a Sprint batch with the job as
<batch:job id="data-send" parent="baseJob">
<batch:listeners merge="true">
<batch:listener ref="someJobExecutionListener"/>
</batch:listeners>
<batch:step id="data-send.step01">
<batch:tasklet transaction-manager="jobTransactionManager" ref="dataSendTasklet"/>
</batch:step>
</batch:job>
The tasklet pseudo code is
@Component
public class DataSendTasklet implements Tasklet {
@Override
public RepeatStatus execute((final StepContribution contribution, final ChunkContext chunkContext) throws Exception {
List<SomeObject> objectList = dbGetOperation();
objectList.stream().forEach(o -> someDataSendOperation(o));
log("ReadCount: "+objectList.size());
return RepeatStatus.FINISHED;
}
Currently, I am logging the read count by calculating the objectList's size and If I had to log the processed records and error records I would have to keep track of a variable inside the someDataSendOperation method. Is there any Spring off-the-shelf functionality to handle the read, write and error counts in this scenario?