Spring batch 从上次异常重新启动Spring批处理

Spring batch 从上次异常重新启动Spring批处理,spring-batch,Spring Batch,我想在批处理终止后重新启动它 当特定异常引发时,我停止批处理: public class IntegrationItemProcessorExceptionHandler implements ExceptionHandler { private static final Logger LOG = LoggerFactory.getLogger(IntegrationItemProcessorExceptionHandler.class); @Override pub

我想在批处理终止后重新启动它 当特定异常引发时,我停止批处理:

public class IntegrationItemProcessorExceptionHandler implements ExceptionHandler {

    private static final Logger LOG = LoggerFactory.getLogger(IntegrationItemProcessorExceptionHandler.class);

    @Override
    public void handleException(RepeatContext context, Throwable throwable) throws Throwable {
        LOG.error("handleException", throwable);
        if (throwable instanceof CustomResponseException) {
            context.setTerminateOnly();
        }
    }   
}
输入是我用FlatFileItemReader读取的json

@Bean
public ItemReader<UserDto> reader() {
    FlatFileItemReader<UserDto> reader = new FlatFileItemReader<MerchantDTO>();
    reader.setResource(new ClassPathResource("user.json"));
    reader.setRecordSeparatorPolicy(new CustomJsonRecordSeparatorPolicy());
    reader.setLineMapper(new CustomLineMapper());
    return reader;  
}
@Bean
公共项目阅读器(){
FlatFileItemReader=新的FlatFileItemReader();
setResource(新类路径资源(“user.json”);
setRecordSeparatorPolicy(新CustomJsonRecordSeparatorPolicy());
setLineMapper(新的CustomLineMapper());
返回读取器;
}
如果ItemProcessor抛出CustomResponseException,我将停止批处理。 之后,我想重新启动批处理,但在同一行我停止了它

我需要什么才能有这样的行为

和我的工作配置:

@Bean
public Job importUserJob(JobBuilderFactory jobs, Step s1) {
    return jobs.get("integrationJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1)
            .end()
            .build();
}

@Bean
public Step step1(StepBuilderFactory stepBuilderFactory) {
    return stepBuilderFactory.get("step1")
            .<UserDTO, User>chunk(10)
            .reader(reader())
            .processor(processor())
            .writer(writer())
            .listener(new IntegrationItemProcessorListener())
            .exceptionHandler(new IntegrationItemProcessorExceptionHandler())
            .build();
}
@Bean
公共作业导入作业(JobBuilderFactory作业,步骤s1){
返回作业。获取(“集成作业”)
.incrementer(新的RunIdIncrementer())
.流量(s1)
(完)
.build();
}
@豆子
公共步骤step1(StepBuilderFactory StepBuilderFactory){
返回stepBuilderFactory.get(“step1”)
.chunk(10)
.reader(reader())
.processor(处理器())
.writer(writer())
.listener(新集成TemprocessorListener())
.exceptionHandler(新的IntegrationTemprocessorExceptionHandler())
.build();
}

我想步骤从最后提交的块重新启动。块是最小的单位功。使用块大小为1I try it:将块更改为1,开始批处理,片刻后由于异常停止。然后我重新启动应用程序(SpringBoot),它从一开始就读取json文件