Announcement Announcement Module
Collapse
No announcement yet.
Conditional Step execution Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conditional Step execution

    I have a job with e.g. steps 1 to 10 in a sequnetial execution.

    Based on a JobParameter (mmExport=true) enterd on the command line I want to either execute all the steps or END after e.g step 6.

    I looked at using a Decider but that won't work becuase it is not inside a step so I can't give it a scope="step"
    but I need a scope="step" in order to do something like
    <bean id="deciderMM" class="de.quirin.siron.job.MMDecider" scope="step">
    <property name="exportMM" value="#{jobParameters['export.mm']}"/>
    </bean>

    Is there any elegant way to do this in Spring Batch?

  • #2
    You are correct that the decision construct is not executed within the scope of a step so using the step scope is of no use here (that actually sounds like a good opportunity for refactoring). That being said, you could use a tasklet step to inject your property and either end or next based on that value. While not quite as elegant as you were looking for, it's the best we have right now.

    Comment


    • #3
      Yes I already did what you suggested but it's not really elegant to have to add a Tasklet to make the decision.

      Giving the Decider a scope of "step" would definitely be a good idea. But maybe an alternative would be to add something like
      <end if="#{!jobParameters['export.mm']}"/> might make it easier to control long sequences of steps based on command line parameters and removes the need for a Decider.

      Comment

      Working...
      X