1
我正在做一個流程步驟,需要在不同的時刻重複相同的步驟。直到我們有RepeatStatus.FINISHED,它不會重複同一步驟,但是在其他步驟之後執行上一步。我們已經完成了一個簡化的模型來嘗試它,但它也不起作用。在Spring批處理中創建迭代流程步驟
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>
豆類:
<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"/>
然後,還有Java類的模型:
任務蕾類模型:
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;
}
}
決勝局類型號:
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);
}
}
而這就是問題所在。第一次沒事了,但第二次和其他時候,直接決定是步驟。
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)