我正在使用 Spring Batch,我的步骤配置如下:
@Bean
public Step testStep(
JdbcCursorItemReader<TestStep> testStageDataReader,
TestStepProcessor testStepProcessor,
CompositeItemWriter<Writer> testWriter,
PlatformTransactionManager transactionManager,
JobRepository jobRepository) {
return stepBuilderFactory
.get("TESTING")
.<>chunk(100)
.reader(testStageDataReader)
.processor(testStepProcessor)
.writer(testWriter)
.faultTolerant()
.skip(DataIntegrityViolationException.class)
.skipLimit(1)
.listener(new SkipTestListener())
.transactionManager(transactionManager)
.repository(jobRepository)
.build();
}
我的复合项目作家
@Bean
public CompositeItemWriter<Writer> testWriter(
Writer1 writer1,
Writer2 writer2,
Writer3 writer3)
throws Exception {
List<ItemWriter<? super Writer>> writers = new ArrayList<>();
writers.add(writer1);
writers.add(writer2);
writers.add(writer3);
CompositeItemWriter<Writer> writers = new CompositeItemWriter<>();
workingWellDailyMemberAggWriter.setDelegates(writers);
workingWellDailyMemberAggWriter.afterPropertiesSet();
return writers;
}
现在,如果 writer1 上存在 DataIntegrityViolationException,则会在我进行日志记录的地方调用我的跳过侦听器,然后控制进入下一步
我正在寻找一种将控制权转移到当前被跳过的下一个作家的方式