在 Spring Batch 中使用此配置
当 DataNotFoundException 步骤块执行 3 次时,这是我配置的并且是预期的。
但是当发生跳过中指定的其他异常时,它会跳过但执行两次后为什么?
即使我删除重试并发生 retryLimit 跳过但重复该块,我也不知道为什么?
Spring Boot版本3.1.5
Spring云版本2022.0.4
@JobScope
@Bean
public Step batchUpdateStep(JobRepository jobRepository, PlatformTransactionManager transactionManager,
@Qualifier("batchUpdateItemWriter")
ItemWriter<UpdateRequest> batchUpdateItemWriter,
@Qualifier("batchUpdateItemProcessor")
ItemProcessor<UpdateDto, UpdateRequest> batchUpdateItemProcessor) {
return new StepBuilder("batch-update-step", jobRepository)
.<UpdateDto, UpdateRequest>chunk(batchUpdateChunkSize, transactionManager)
.reader(batchUpdateItemReader(null))
.processor(batchUpdateItemProcessor)
.writer(batchUpdateItemWriter)
.faultTolerant().skipLimit(Integer.MAX_VALUE)
.skip(Exception.class)
.noSkip(DataNotFoundException.class)
.retryLimit(3)
.retry(DataNotFoundException.class)
.listener(getBatchUpdateStepListener())
.listener(getBatchUpdateSkipListener(null, null))
.listener(batchUpdateProcessListener(null, null))
.build();
}
您是否尝试以与
noRetry
相同的方式添加 noSkip
?
该方法的 Javadoc :
明确要求从重试中排除异常(和子类)。