创建一个';分步环路';使用SpringJava配置
我正在尝试将一个用xml定义的spring批处理作业移植到一个基于java配置的作业。 这是我的作业配置文件的一个片段:创建一个';分步环路';使用SpringJava配置,java,spring,spring-batch,spring-java-config,Java,Spring,Spring Batch,Spring Java Config,我正在尝试将一个用xml定义的spring批处理作业移植到一个基于java配置的作业。 这是我的作业配置文件的一个片段: <decision id="decision" decider="someDecider"> <next on="continue" to="stepCont" /> <next on="timeout" to="stepTimeout" /> <end on="COMPLETED" /> </decision>
<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>
它必须是这样的:
.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();
我的工作就像我的工作一样。没有xml我怎么能实现它呢?这个怎么样:
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();
FlowBuilder FlowBuilder=新的FlowBuilder(“flow1”);
流量=流量生成器
.start(导入personstep)
.next(循环决策器)
.关于(“继续”)
.to(导入personstep)
.from(loopDecider)
.关于(“已完成”)
(完)
.build();
return jobs.get(“importUserJob”)
.incrementer(新的RunIdIncrementer())
.启动(流量)
(完)
.build();
我知道得很晚,但我没有找到正确的例子,这个问题一直出现在我的谷歌搜索中
下面是一个使用最新spring批处理的工作示例
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();
这不管用。它没有实现循环。根据我读到的内容,你必须动态创建步骤并将它们添加到流程中以重复执行它们。你能在这里指导吗-?我不确定,但这对我不起作用。
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();