Announcement Announcement Module
Collapse
No announcement yet.
Conditional Flow on partitioned steps Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Conditional Flow on partitioned steps

    I'm having some troubles applying some conditional flow to a partitioned step. I have a listener applied to my master step which is being processed correctly and from this listener I am able to determine the correct process flow. However my end, fail and next tags are being ignored. I'm not sure I've got them in the correct place, but they are in the only place that seems appropriate.

    I have this step (within a larger set of steps):
    Code:
    <step id="ftpUrlProcessUploadStep" parent="ftpUrlLogUploadStep:master" >
        <end on="COMPLETED" />
        <fail on="FAILED" exit-code="Step failed"/>
        <next on="*" to="ftpProcessUploadStep" />
    </step>
    and on my master step I have:
    Code:
    <bean name="ftpUrlLogUploadStep:master" class="org.springframework.batch.core.partition.support.PartitionStep">
        <property name="partitionHandler" ref="ftpUrlLogUploadPartitionHandler"/>
        <property name="stepExecutionSplitter" ref="ftpUrlLogUploadExecutionSplitter"/>
        <property name="jobRepository" ref="jobRepository" />
        <property name="stepExecutionListeners">
            <list>
                <ref bean="ftpProcessUploadStepListener" />
            </list>
        </property>
    </bean>
    <step id="ftpUrlLogUploadStep" xmlns="http://www.springframework.org/schema/batch">
        <tasklet ref="ftpUrlLogUploadRemoteTasklet" />
    </step>
    
    <bean id="ftpProcessUploadStepListener" class="com.mit.deta.lattice.batch.job.common.StepExecutionListener"/>
    In my listener I am returning either of these status depending on what I need to do:
    Code:
    ExitStatus.COMPLETED
    ExitStatus.FAILED
    new ExitStatus("CONTINUE")
    My question is are my end, fail and next tags in the correct place? If not where are they supposed to go? It doesn't matter what I return from my listener the step always follows the same flow.

  • #2
    you probably need to put the listener on the actual step and not the step materializing the partition.

    Comment


    • #3
      I had tried this but it's not really what I'm after. I can't add it to the main ftpUrlProcessUploadStep as it has no tasklet tags and I can't add a listener to the step tags (yet), then if I add it to the ftpUrlLogUploadStep this is the individual step that is created for each partition. What I'm trying to do is check the result of the step after the partitions are aggregated and Batch has set the ExitStatus for the step as a whole.

      In the bigger picture we have the problem where sometimes we hit the partition step and have nothing to process resulting in an exception IllegalArgumentException: Cannot aggregate empty or null executions: []. In our case this is legitimate and we wan't to continue. We have a workaround where we are extending the DefaultStepExecutionAggregator but I was hoping to have a solution that didn't involve us having to extend classes and potentially have more to maintain.

      Guess we'll have to wait for v3.0 where listener supports is being added to partitioned steps.

      Comment


      • #4
        Right. my mistake. You need to put the listener on the partition step. You don't need to wait for 3.0. We had the same need and requested the addition. You could use an abstract step and set a parent on your partition step and it will work.

        My colleague has posted a working example over here:
        http://forum.springsource.org/showthread.php?t=84587

        HTH,
        S.

        Comment

        Working...
        X