Spring batch 调试SpringBatch应用程序

Spring batch 调试SpringBatch应用程序,spring-batch,spring-batch-job-monitoring,Spring Batch,Spring Batch Job Monitoring,我在job中定义了四个步骤,JobExecution表示已完成,但我想确保所有步骤都被调用并正确执行了 我们有什么方法可以调试每个步骤吗? 通过定义端点从RestController调用批处理作业 在配置文件下方找到 @Configuration @Log4j2 public class PickUpBatchConfig { @Autowired public JobBuilderFactory jobBuilderFactory; @Autowired p

我在job中定义了四个步骤,JobExecution表示已完成,但我想确保所有步骤都被调用并正确执行了

我们有什么方法可以调试每个步骤吗?

通过定义端点从RestController调用批处理作业

配置文件下方找到

@Configuration
@Log4j2
public class PickUpBatchConfig {

    @Autowired
    public JobBuilderFactory jobBuilderFactory;

    @Autowired
    public StepBuilderFactory stepBuilderFactory;


    @Bean
    public Job pickupJob() {
        return this.jobBuilderFactory.get("pickupJob")
            .listener(new JobResultListener())
            .start(a())
            .next(b())
            .next(c())
            .next(d())
            .build();
    }

    @Bean
    public Step a() {
        System.out.println("PickUpBatchConfig.a");
        return this.stepBuilderFactory.get("step1")
            .Responsechunk(0)
            .reader(new One())//dummy ,does nothing in step1
            .processor(new Two())
            .writer(new Three())
            .build();
    }

    @Bean
    public Step b() {
        System.out.println("PickUpBatchConfig.b");
        return this.stepBuilderFactory.get("step2")
            .Responsechunk(0)
            .reader(new Four())// Need to implement
            .processor(new Five())
            .writer(new Six())
            .build();
    }

    @Bean
    public Step c() {
        System.out.println("PickUpBatchConfig.c");
        return this.stepBuilderFactory.get("step3")
            .Responsechunk(0)
            .reader(new Seven())//need to implement
            .processor(new Eight())
            .writer(new nine())
            .build();
    }

    @Bean
    public Step d() {
        System.out.println("PickUpBatchConfig.d");
        return this.stepBuilderFactory.get("step4")
            .Responsechunk(0)
            .reader(new Ten())
            .processor(new Elevan())
            .writer(new Twelve())
            .build();

    }


}
作业执行已完成


如果您能够访问作业执行并能够检查其状态,那么您可以使用
jobsecution#getStepExecutions
获取所有步骤执行情况,并检查每个步骤的状态。

是的,我可以使用getStepExecutions谢谢,如何确保我的所有阅读器,处理器和写入程序在每个步骤中都会被调用?对于每个步骤执行,您可以使用
StepExecution#getReadCount
StepExecution#getWriteCount
,获得读取计数、写入计数等。如果假设StepExecution中的readcount=0和writeCount=0,我们可以得出什么结论请检查此部分: