2016-12-22 10 views
0

春バッチのいくつかの条件に応じて、ステップを実行したり、スキップして次のステップに進むことは可能ですか? など。バッチ・ジョブには5つのステップがあり、各ステップ実行の前に、データベース内の列の値に応じてスキップするかどうかをチェックする必要があります。 リスナーまたは実行時にステップ実行を制御できる他の方法のいずれかを使用して、汎用ロジックを作成する必要がありますか?春バッチの制御ステップレベル実行

実行時に次の属性を設定する必要があります。サンプルXML:

<batch:step id="step1" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step2" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step3" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step4" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:decision id="stepdecision" decider="decider"> 
     <batch:next on="next" to="#{jobExecutionContext[nextStep]}" /> 
    </batch:decision> 

</batch:job> 

<bean id="decider" class="com.bmo.apms.batch.StepFlowDecider"> 
</bean> 
<bean id="tasklet1" class="com.bmo.apms.batch.TestTasklet" /> 

しかし、それは例外がスローされます。 設定の問題を:要素は、[STEP2]到達不能です|

私は春は実行時に次の属性をバインドすることはできません。 アドバイスをお願いします。

+0

http://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/job/flow/JobExecutionDecider.html –

答えて

0

これを達成し、次のステップを見つける決定者を作成しました。 すべてのステップの次の属性は、実行時に実際のステップにそれを転送する決定子です。

<batch:decision id="stepdecision" decider="decider"> 
     <batch:next on="step1" to="step1" /> 
     <batch:next on="step2" to="step2" /> 
     <batch:next on="step3" to="step3" /> 
     <batch:next on="step4" to="step4" /> 
     <batch:end on="end" /> 
    </batch:decision> 


<batch:next on="step3" to="step3" /> 
     <batch:next on="step4" to="step4" /> 
     <batch:end on="end" /> 
    </batch:decision> 

    <batch:step id="step1" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step2" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step3" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 

    <batch:step id="step4" next="stepdecision"> 
     <batch:tasklet ref="tasklet1" /> 
    </batch:step> 
0

実行時に次の値を設定しないでください。実行時にDeciderが返す内容を設定します。それが決定者の全ポイントです。

関連する問題