2

I made a projet with Spring Batch few month ago.

This project is working fine and is including an implementation of 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");
    }
}

This has working fini with just Spring Batch.

Now I have to use it with Spring Boot Batch. All the process is working fine until the decider step. Where I return the good FlowExecutionStatus, but I don't know why, the job is completed with a "FAILED" status.

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}]

Someone have an idea why isn't working?

Thanks!

D. Cesar
  • 41
  • 1
  • 5
  • Are you sure code executed as 'condition' is working fine without errors? – Luca Basso Ricci Jan 19 '17 at 16:33
  • Yes, as you can see on the first logs line, the status is "status=AGAIN". And in debug mode I pass on the condition. In the SilpmeFlow class of Spring-Batch I can see the evolution of the state and the FAILED appears after the state COMPLETED of the decider. – D. Cesar Jan 19 '17 at 16:39

1 Answers1

1

I found a solution.

I'm using the decider to make a loop on my Job.

I was using this :

@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();
}

And work's with this :

@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();
}

But I don't know why. Maybe, Spring-boot-batch-starter update my batch version and break that?

someone knows something.

D. Cesar
  • 41
  • 1
  • 5
  • Hi, I am having a similar problem now, and not able to figure. How did you invoke .next() method after .end() method? – Gayatri Oct 11 '19 at 18:22
  • Could you please guide me here - https://stackoverflow.com/questions/64678776/the-method-nextstep-is-undefined-for-the-type-flowjobbuilder ? – PAA Nov 04 '20 at 11:19