[英]From boot Spring Batch application @BeforeStep method of the ItemWriter calling before of @BeforeStep method of the ItemProcessor
我正在研究SpringBatch,在启动Spring在ItemProcessor之前调用ItemWriter时出现问题。 为什么?
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) {..}
}
并且@AfterStep ItemProcessor 的方法在方法@AfterStep ItemWriter 之前被调用。
我预计这个循环调用@BeforeStep:
但我有这个结果:
对于@AfterStep,我期望:
但我有这个结果:
谢谢:)
您的对象是多态的:它们既是项目读取器/处理器/写入器,又是StepExecutionListener
(更准确地说是代理)。 当 Spring Batch 在一个 step 之前/之后运行 StepExecutionListeners 时,它不会将它们视为 reader/processor/writer,并且它们的执行顺序不一定与在面向 chunk 的 step 中调用它们的顺序相同(实际上,顺序在这种情况下是未定义的)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.