Spring Batch默认事务功能不适用于存储过程

时间:2019-07-04 09:35:12

标签: spring spring-boot spring-batch

我在Spring批处理中具有编写器简单批处理作业和读取器-处理器配置。在处理器中,我调用存储过程进行一些数据库更新, 正常流程工作正常,但是只要执行存储过程后发生任何异常,更新记录就不会回滚。

@配置 公共课程StudentJobConfig {

@Bean
ItemReader<Student> studentReader() {
    // reads data from database
}

@Bean
ItemProcessor<Student, Student> studentProcessor() {
    // execute the stored procedure 
}


@Bean
Step studentStep(ItemReader<Student> studentReader,
                         ItemProcessor<Student, Student> studentProcessor,
                         StepBuilderFactory stepBuilderFactory) {
    return stepBuilderFactory.get("StudentStep")
            .<Student, Student>chunk(1)
            .reader(studentReader)
            .processor(studentProcessor)
            .build();
}

@Bean
Job inMemoryStudentJob(JobBuilderFactory jobBuilderFactory,
                       @Qualifier("studentStep") Step studentStep) {
    return jobBuilderFactory.get("StudentJob")
            .incrementer(new RunIdIncrementer())
            .flow(studentStep)
            .end()
            .build();
}

}

0 个答案:

没有答案
相关问题