调试 Spring Batch 应用程序
Debuging SpringBatch application
我在作业中定义了四个步骤,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();
}
}
JobExecution says completed
如果您可以访问作业执行并能够检查其状态,那么您可以使用 JobExecution#getStepExecutions
获取所有步骤执行并检查每个步骤的状态。
我在作业中定义了四个步骤,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();
}
}
JobExecution says completed
如果您可以访问作业执行并能够检查其状态,那么您可以使用 JobExecution#getStepExecutions
获取所有步骤执行并检查每个步骤的状态。