Spring 批量跳过正在发生,但为什么重复该块?

问题描述 投票:0回答:1

在 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();
    }
java spring spring-boot spring-batch
1个回答
0
投票

您是否尝试以与

noRetry
相同的方式添加
noSkip

该方法的 Javadoc :

明确要求从重试中排除异常(和子类)。

© www.soinside.com 2019 - 2024. All rights reserved.