我有一個Tasklet
,並希望計算處理的項目。然後共同StepExecutionListener
應該能夠讀取afterStep()
那些加工項目計數:如何在春季批次中計算Tasket中的項目?
@Bean
public Step myStep() {
return stepBuilderFactory.get("Step2")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
int items = dao.deleteItems(); //how to pass these items to a StepExecutionListener?
return RepeatStatus.FINISHED;
}
})
.build();
@Component
public class MyListener extends StepExecutionListenerSupport {
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
long items = stepExecution.getWriteCount();
return super.afterStep(stepExecution);
}
}
我如何能得到處理的項目到微進程中的stepExecution
?
This [Tutorial](http://docs.spring.io/spring-batch/trunk/reference/html/patterns.html#passingDataToFutureSteps)可能會對您有所幫助。 – Braj