I'm doing a flow step who needs to repeat the same step in different moment. It's not repeating same step until we have RepeatStatus.FINISHED
, but after some others steps go to a previous step. We have done a simplified model to try it but it also doesn't work.
Job.xml:
<job id="job1" xmlns="http://www.springframework.org/schema/batch">
<step id="job1Step1" next="decision1">
<tasklet ref="tasklet1" />
</step>
<decision id="decision1" decider="decider1">
<next on="1" to="job1Step1"/>
<next on="2" to="job1Step2"/>
<next on="3" to="job1Step3"/>
</decision>
<step id="job1Step2" next="decision2">
<tasklet ref="tasklet2" />
</step>
<decision id="decision2" decider="decider2">
<next on="1" to="job1Step1"/>
<next on="2" to="job1Step2"/>
<next on="3" to="job1Step3"/>
</decision>
<step id="job1Step3" next="job1Step1">
<tasklet ref="tasklet3" />
</step>
</job>
Beans:
<bean id="decider1" class="Decider1"/>
<bean id="decider2" class="Decider2"/>
<bean id="tasklet1" class="Tasklet1"/>
<bean id="tasklet2" class="Tasklet2"/>
<bean id="tasklet3" class="Tasklet3"/>
Then, there are models of java classes:
Tasklet class model:
public class TaskletN implements Tasklet {
protected static Log log = LogFactory.getLog(TaskletN.class);
@Override
public RepeatStatus execute(StepContribution stepCont, ChunkContext chunkContext) throws Exception {
log.info("Passo per TASKLET_N");
return null;
}
}
Decider class model:
public class DeciderM implements JobExecutionDecider {
protected static Log log = LogFactory.getLog(DeciderM.class);
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
String prova = "M+1";
log.info("Estic a DECIDER_M i vaig al STEP: " + prova);
return new FlowExecutionStatus(prova);
}
}
And, that's the problem. First time it's alright but second and other times it goes to deciders directly instead of steps.
Passo per TASKLET_1
Estic a DECIDER_1 i vaig al STEP: 2
Passo per TASKLET_2
Estic a DECIDER_2 i vaig al STEP: 3
Passo per TASKLET_3
Estic a DECIDER_1 i vaig al STEP: 2
Estic a DECIDER_2 i vaig al STEP: 3
Estic a DECIDER_1 i vaig al STEP: 2
Estic a DECIDER_2 i vaig al STEP: 3
Estic a DECIDER_1 i vaig al STEP: 2
... (bug)