jobexecutiondecider在使用simpleasynctaskexecutor的spring批处理拆分流中的使用

u91tlkcl  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(225)

我想用4个步骤配置一个spring批处理作业。步骤2和步骤3相互独立。所以我想并行执行。根据执行参数,可以跳过这两个步骤中的任何一个或两个步骤。检查以下流程:批处理流程详细信息
java配置如下:

@Bean
public Job sampleBatchJob()
    throws Exception {

final Flow step1Flow = new FlowBuilder<SimpleFlow>("step1Flow")
        .from(step1Tasklet()).end();

final Flow step2Flow = new FlowBuilder<SimpleFlow>("step2Flow")
        .from(new step2FlowDecider()).on("EXECUTE").to(step2MasterStep())
        .from(new step2FlowDecider()).on("SKIP").end(ExitStatus.COMPLETED.getExitCode())
        .build();
final Flow step3Flow = new FlowBuilder<SimpleFlow>("step3Flow")
        .from(new step3FlowDecider()).on("EXECUTE").to(step3MasterStep())
        .from(new step3FlowDecider()).on("SKIP").end(ExitStatus.COMPLETED.getExitCode())
        .build();

final Flow splitFlow = new FlowBuilder<Flow>("splitFlow")
        .split(new SimpleAsyncTaskExecutor())
        .add(step2Flow, step3Flow)
        .build();

return jobBuilderFactory().get("sampleBatchJob")
        .start(step1Flow)
        .next(splitFlow)
        .next(step4MasterStep())
        .end()
        .build();
}

step2flowdecider的示例代码:

public class Step2FlowDecider
    implements JobExecutionDecider {
@Override
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {

    if (StringUtils.equals("Y", batchParameter.executeStep2())) {
        return new FlowExecutionStatus("EXECUTE");
    }
    return new FlowExecutionStatus("SKIP");
}

}
在这种配置下,当我尝试执行批处理时,它失败了,没有任何详细的错误日志。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题