Spring Batch skip exception for ItemWriter

后端 未结 2 1359
栀梦
栀梦 2020-11-29 09:54

I\'m trying to use Spring Batch 2.2.5 with Java config. Here is the config that I have:

@Configuration
@EnableBatchProcessing
public class JobConfiguration {         


        
2条回答
  •  春和景丽
    2020-11-29 10:11

    At the end, this is what is working for me - if I want to use itemwriter, with no reprocessing of the same item:

     @Bean
        @Autowired
        public Step procesingStep() {
               CompositeItemProcessor compositeProcessor = new CompositeItemProcessor();
               compositeProcessor.setDelegates(Lists.newArrayList(
                       documentPackageFileValidationProcessor(),
                       documentPackageFileExtractionProcessor(),
                       documentMetadataFileTransformer()
               ));
            return stepBuilder.get("procesingStep")
                    .chunk(1)
                    .reader(documentPackageFileReader())
                    .processor(compositeProcessor)
                    .writer(documentMetadataFileMigrator())
                    .faultTolerant()
                    .skip(DocumentImportException.class)
                    .noRetry(DocumentImportException.class)
                    .noRollback(DocumentImportException.class)
                    .skipLimit(10)
                    .listener(skipListener())
                    .listener(documentPackageReadyForProcessingListener())
                    .listener(stepExecutionListener())
                    .build();
        }
    

    Note that I have specified 'noRetry' and 'noRollback'.

提交回复
热议问题