I'm studing SpringBatch, I have a problem during the boot Spring call ItemWriter before ItemProcessor. Why?
public class PollingReader implements ItemReader<File> {
@BeforeStep
public void beforeStep(StepExecution stepExecution) throws NotDirectoryException {..}
@AfterStep
public ExitStatus afterStep(StepExecution stepExecution) {..}
}
public class PollingWriter implements ItemWriter<File> {
@BeforeStep
public void beforeStep(StepExecution stepExecution) {..}
@AfterStep
public ExitStatus afterStep(StepExecution stepExecution) {..}
..
}
public class PollingProcessor implements ItemProcessor<File, File> {
@BeforeStep
public void beforeStep(StepExecution stepExecution) {..}
@AfterStep
public ExitStatus afterStep(StepExecution stepExecution) {..}
}
And the method of the @AfterStep ItemProcessor is called before of the method @AfterStep ItemWriter.
I expected this cycle call for @BeforeStep:
but I have this result:
and for @AfterStep I expected:
but I have this result:
Thanks:)
Your objects are polymorphic: they are both item reader/processor/writer and StepExecutionListener
s (as proxies, to be more precise). When Spring Batch runs StepExecutionListeners before/after a step, it does not see them as reader/processor/writer, and the order of their execution is not necessarily the same as they are called in a chunk-oriented step (in fact, the order is undefined in that case).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.