[英]Spring Batch decider without duplication
I have a case where I have a user input lets call it RunningMode. 在某些情况下,我有一个用户输入,可以将其称为RunningMode。 The input can have 3 possible states: STATE1, STATE2, STATE1_AND_STATE2.
输入可以具有3种可能的状态:STATE1,STATE2,STATE1_AND_STATE2。 The logic to implement is as follows if STATE1 is set then stepA should be executed if STATE2 is set then stepB should be executed and finally if STATE1_AND_STATE2 is set then I should run in parallel stepA and stepB.
要实现的逻辑如下:如果设置了STATE1,则应执行stepA;如果设置了STATE2,则应执行stepB;最后,如果设置了STATE1_AND_STATE2,则我应该并行执行步骤A和步骤B。
I know how to solve this in an ugly way like this: 我知道如何以这种丑陋的方式解决此问题:
<batch:decision id="makeWorkFlowDecision" decider="myDecider">
<batch:next on="STATE1" to="stepA" />
<batch:next on="STATE2" to="stepB" />
<batch:next on="STATE1_AND_STATE2" to="stepC" />
</batch:decision>
<batch:split id="stepA" task-executor="taskExecutor">
<!-- content of stepA -->
</batch:split>
<batch:split id="stepB" task-executor="taskExecutor">
<!-- content of stepB -->
</batch:split>
<batch:split id="stepC" task-executor="taskExecutor">
<!-- content of stepA -->
<!-- content of stepB -->
</batch:split>
Like you can see there is duplication in stepC. 就像您看到的,stepC中有重复项。 I repeat content of stepA and stepB.
我重复步骤A和步骤B的内容。 Plus as far as I know in stepC stepA and stepB won't run in parallel.
另外,据我在stepC中所知,stepA和stepB不会并行运行。 Content of stepA and stepB consists of 2 flow blocks each in which I define steps.
步骤A和步骤B的内容由2个流程块组成,每个流程块我都定义了步骤。 Is there a way to have conditional next on stepA ?
有没有办法在stepA上有条件下一步?
Below is an example of what Luca is describing: 以下是Luca描述的示例:
<flow id="flowA">
<!-- stepA related steps here -->
</flow>
<flow id="flowB">
<!-- stepB related steps here -->
</flow>
<batch:split id="stepA" task-executor="taskExecutor">
<flow parent="flowA"/>
</batch:split>
<batch:split id="stepB" task-executor="taskExecutor">
<flow parent="flowB"/>
</batch:split>
<batch:split id="stepC" task-executor="taskExecutor">
<flow ref="flowA"/>
<flow ref="flowB"/>
</batch:split>
SB (as Spring is general) allow you to define abstract step . SB(与Spring一样)允许您定义抽象步骤 。
You can define abstract stepA
and stepB
and split using parent
property (check split-flow official documentation for example). 您可以定义抽象
stepA
和stepB
并使用parent
属性进行拆分 (例如,查看拆分流官方文档 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.