2

我想实现这个用例,我有 3 个流程,

<split id="split1" task-executor="taskExecutor">
    <flow>
        <step id="step1" parent="s1" next="step2"/>
        <step id="step2" parent="s2"/>
    </flow>
    <flow>
        <step id="step3" parent="s3"/>
    </flow>
    <flow>
        <step id="step4" parent="s4"/>
    </flow>
    <flow>
        <step id="step5" parent="s5"/>
    </flow>
</split>


<split id="split2" task-executor="taskExecutor">
    <flow>
        <step id="step6" parent="s6"/>
        <step id="step7" parent="s7"/>
    </flow>
    <flow>
        <step id="step8" parent="s8"/>
    </flow>
</split>

<split id="split3" task-executor="taskExecutor">
    <flow>
        <step id="step9" parent="s9"/>
        <step id="step10" parent="s10"/>
        <split id="split3_1" task-executor="taskExecutor">
             <flow>
                 <step id="step11" parent="s11"/>
             </flow>
            <flow>
                  <step id="step12" parent="s12"/>
             </flow>
        </split>
    </flow>
</split>

在 split1 中,有 4 个流,它们应该并行运行。一旦 step2 和 step3 完成,它应该触发 split2 运行,不应等待 split1 中的 step4 和 step5。

同理,如果step4和step5都完成了,就应该触发split3的执行,而不需要等待step2和step3完成。

也可以在流中添加步骤和拆分,例如在上面的 split3 中,我希望 step9 和 step10 强制运行,然后并行运行 step11 和 step12。

如何配置此用例?拆分可以嵌套吗?

4

1 回答 1

2

我会首先尝试以下方法:

<split id="split1" task-executor="taskExecutor">
    <flow>
        <split next="split2">
            <flow>
                <step id="step1" parent="s1" next="step2"/>
                <step id="step2" parent="s2"/>
            </flow>
            <flow>
                <step id="step3" parent="s3"/>
            </flow>
        </split>

        <split id="split2" task-executor="taskExecutor">
            <flow>
                <step id="step6" parent="s6"/>
                <step id="step7" parent="s7"/>
            </flow>
            <flow>
                <step id="step8" parent="s8"/>
            </flow>
        </split>
    </flow>

    <flow>
        <split next="split3" task-executor="taskExecutor">
            <flow>
                <step id="step4" parent="s4"/>
            </flow>
            <flow>
                <step id="step5" parent="s5"/>
            </flow>
        </split>

        <split id="split3" task-executor="taskExecutor">
            <flow>
                <step id="step9" parent="s9"/>
                <step id="step10" parent="s10"/>
            </flow>
            <flow>
                <step id="step11" parent="s11"/>
            </flow>
        </split>
    </flow>
</split>

但确保Spring Batch 版本在 2.1.5 之后

于 2014-04-08T15:01:13.910 回答