如何使用spring batch parallel step split flow配置上述用例?

时间:2014-04-08 09:58:48

标签: java spring spring-batch spring-batch-admin

我想实现这个用例,我有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。

同样,如果步骤4和步骤5完成,它应该触发split3的执行,而不等待step2和step3完成。

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

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

1 个答案:

答案 0 :(得分: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 version is after 2.1.5