首页 文章

使用JobExecutionDecider和spring boot batch

提问于
浏览
1

几个月前我用Spring Batch制作了一个projet .

这个项目工作正常,包括JobExecutionDecider的实现

public class BatchDecider implements JobExecutionDecider {
private static final Logger log = LoggerFactory.getLogger(BatchDecider.class);

@Autowired
ConfigurationServiceWs config;

public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {

    if (codition) {

        return new FlowExecutionStatus("AGAIN");
    } else {

        return new FlowExecutionStatus("FINISH");
    }
}

这只是Spring Batch的工作方式 .

现在我必须将它与Spring Boot Batch一起使用 . 所有过程都正常工作,直到决策步骤 . 我返回好的FlowExecutionStatus,但我不知道为什么,作业以“FAILED”状态完成 .

2017-01-19 17:11:35.347 DEBUG 23056 --- [nio-8081-exec-1] o.s.b.core.job.flow.support.SimpleFlow   : Completed state=Global Job.decision0 with status=AGAIN
2017-01-19 17:11:39.074 DEBUG 23056 --- [nio-8081-exec-1] o.s.b.core.job.flow.support.SimpleFlow   : Handling state=Global Job.FAILED
2017-01-19 17:11:41.002 DEBUG 23056 --- [nio-8081-exec-1] o.s.b.core.job.flow.support.SimpleFlow   : Completed state=Global Job.FAILED with status=FAILED
2017-01-19 17:11:43.170 DEBUG 23056 --- [nio-8081-exec-1] o.s.batch.core.job.AbstractJob           : Job execution complete: JobExecution: id=0, version=1, startTime=Thu Jan 19 17:11:12 CET 2017, endTime=null, lastUpdated=Thu Jan 19 17:11:12 CET 2017, status=FAILED, exitStatus=exitCode=FAILED;exitDescription=, job=[JobInstance: id=0, version=0, Job=[Global Job]], jobParameters=[{time=1484842272108}]

有人知道为什么不工作?

谢谢!

1 回答

  • 1

    我找到了解决方案 .

    我正在使用决策程序在我的Job上创建一个循环 .

    我在用这个:

    @Bean(name = "myJob")
    public Job importUserJob() {
        return jobBuilderFactory.get("Global Job")
                .incrementer(new RunIdIncrementer())
                .flow(getListeDocMiseADispo())
                .next(decider).on("FINISH").end()
    
                .next(boucle())
                .next(decider).on("AGAIN").to(boucle())
    
                .end()
                .build();
    }
    

    与此同时工作:

    @Bean(name = "myJob")
    public Job importUserJob() {
        return jobBuilderFactory.get("Global Job")
                .incrementer(new RunIdIncrementer())
                .flow(getListeDocMiseADispo())
                .next(decider).on("AGAIN").to(boucle())
                .next(decider).on("FINISH").end()
    
                .next(boucle())
                .next(decider).on("AGAIN").to(boucle())
    
                .end()
                .build();
    }
    

    但我不知道为什么 . 也许,Spring-boot-batch-starter更新我的批处理版本并打破它?

    有人知道的事情 .

相关问题