spring-projects/spring-batch

Add ability to start a job flow definition with a decider

fmbenhassine opened this issue · 1 comments

Discussed in #4359

Originally posted by acktsap April 12, 2023
In xml based job configuration, we can set decider first like this.

<job id="decisionJob1" >
    <decision id="decider1" decider="stepFlowDecider">
        <end on="EXIT" exit-code="COMPLETED"/>
        <next on="*" to="job1Step1" />
    </decision>

    <step id="job1Step1">
        <tasklet ref="createFileTasklet"/>
    </step>
</job>

But when using code based job configuration, no way to start with decider. JobBuilder only provides start methods taking Step, Flow only.

/**
* Create a new job builder that will execute a step or sequence of steps.
* @param step a step to execute
* @return a {@link SimpleJobBuilder}
*/
public SimpleJobBuilder start(Step step) {
return new SimpleJobBuilder(this).start(step);
}
/**
* Create a new job builder that will execute a flow.
* @param flow a flow to execute
* @return a {@link SimpleJobBuilder}
*/
public JobFlowBuilder start(Flow flow) {
return new FlowJobBuilder(this).start(flow);
}
/**
* Create a new job builder that will execute a step or sequence of steps.
* @param step a step to execute
* @return a {@link SimpleJobBuilder}
*/
public JobFlowBuilder flow(Step step) {
return new FlowJobBuilder(this).start(step);
}

It there any way to set decider first on code based job configuration?


References:

Hi! @fmbenhassine. I've created a draft PR about this issue. Please feel free to check it anytime.