我正在尝试将一个弹出批处理作业移植到基于java-config的作业中,该作业在xml中定义。 这是我的job-configuration-file的片段:
<decision id="decision" decider="someDecider">
<next on="continue" to="stepCont" />
<next on="timeout" to="stepTimeout" />
<end on="COMPLETED" />
</decision>
<step id="stepCont" next="stepReport">
... do something
</step>
<step id="stepReport" next="decision">
... create report
</step>
<step id="stepTimeout">
...
</step>
有没有办法用spring-java-config创建这样的循环?
我开始了:
.get("myJob")
.start(someStepBefore())
.next(someDecider).on("timeout").to(stepTimeout())
.from(someDecider).on("continue").to(stepCont())
.from(someDecider).on("COMPLETED").end().build()
.build();
必须如此:
.get("myJob")
.start(someStepBefore())
.next(someDecider).on("timeout").to(stepTimeout())
.from(someDecider).on("continue").to(stepCont()).next(someDecider)...
.from(someDecider).on("COMPLETED").end().build()
.build();
我的工作就像loopFlowSample。如果没有xml,我怎么能意识到呢?
答案 0 :(得分:2)
这个怎么样:
FlowBuilder<Flow> flowBuilder = new FlowBuilder<Flow>("flow1");
Flow flow = flowBuilder
.start(importPersonStep)
.next(loopDecider)
.on("CONTINUE")
.to(importPersonStep)
.from(loopDecider)
.on("COMPLETED")
.end()
.build();
return jobs.get("importUserJob")
.incrementer(new RunIdIncrementer())
.start(flow)
.end()
.build();
答案 1 :(得分:0)
我真的很晚,但是我没有找到正确的例子,这个问题一直出现在我的Google搜索中。
这是最新的春季批处理的工作示例。
return jobs.get("myJob")
.start(someStepBefore)
.next(stepReport)
.next(someDecider).on("timeout").to(stepTimeout)
.from(someDecider).on("continue").to(stepCont)
.from(someDecider).on("COMPLETED").end()
.from(stepCont).next(someDecider).on("timeout").to(stepTimeout)
.from(stepCont).from(someDecider).on("continue").to(stepCont)
.from(stepCont).from(someDecider).on("COMPLETED").end()
.end()
.build();