I have a spring-batch xml-based configuration that should be migrated to annotation-based configuration.
but I can't find any solution to define a chunk into the tasklet definition.
There are my xml and code base decleration:
<step id="files2Memory">
<tasklet>
<chunk reader="pointFileReader" processor="pointFileProcessor"
writer="pointFileWriter" commit-interval="50000"/>
</tasklet>
</step>
public Step files2Memory() {
return stepBuilders.get("files2Memory")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
return null;
}
})
.chunk(50000)
.reader(new PointFileReader())
.writer(new PointFileWriter())
.processor(new PointFileProcessor())
.build();
}
Best Regards
Mark PointFileReader and PointFileWriter PointFileProcessor with @Component, use @Scope("step") if required. Make Sure component scan cover them.
In you batch config file autowried the above.
If one of the PointFileReader and PointFileWriter PointFileProcessor can not be specif as PointFileReader and PointFileWriter PointFileProcessorPointFileReader and PointFileWriter @Component you can defined them as @Beans and replace fields with method call
e.g.