Announcement Announcement Module
Collapse
No announcement yet.
FlowStep not evaluating status/exit-code Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FlowStep not evaluating status/exit-code

    Hi Lads,
    I try to fix some issue in our batch processes and I lost a hope

    This is mostly related to F&R and restartable job.

    We need to create one of the steps to be goup of two sub-steps. Let's assume we have: stepA->stepB->stepB1->stepB2->stepC
    stepA - TaskletStep
    stepB - FlowStep
    stepB1,stepB2 - sub-steps of stepB, both are TaskletSteps
    stepC - TaskletStep
    Why we going to group steps? Because B1 must be run only if B2.status!=COMPLETED. B1 (is some cleanup before B2). If B2 will pass we do not want to start B1 any more. B1 of course is marked as allow-if-complete (so can be executed many times, e.g. on restart job because B2 failed).

    Scenario which fails:
    -------------------
    1. stepB2 will fail
    In this scenaro stepB2 will be marked as FAILED but this status is not propagated to stepB status (parent step status) and job is keep going
    What I want to achieve is to fail a job (especialy stepB) if any of stepB1 and stepB2 will fail. Than recovery mechanism will pickap that job on restart.

    Configuration of my job looks like this:
    Code:
    	<batch:job id="simpleJob" job-repository="jobRepository" restartable="true">
    	
    		<batch:step id="stepA">
    			<batch:tasklet>
    				<beans:bean class="somet.package.SimpleTaskletImplementation"/>
    			</batch:tasklet>
    			<batch:fail on="FAILED"/>
    			<batch:next on="COMPLETED" to="stepB"/>
    		</batch:step>
    
    		<batch:step id="stepB">
    			<batch:flow parent="stepBFlow"/>
    			<batch:fail on="FAILED"/>
    			<batch:next on="COMPLETED" to="stepC"/>
    		</batch:step>
    		
    		<batch:step id="stepC">
    			<batch:tasklet>
    				<beans:bean class="somet.package.SimpleTaskletImplementation"/>
    			</batch:tasklet>
    		</batch:step>
    	</batch:job>
    
    	<batch:flow id="stepBFlow">
    		<batch:step id="stepB1">
    			<batch:tasklet allow-start-if-complete="true">
    				<beans:bean class="somet.package.SimpleTaskletImplementation"/>
    			</batch:tasklet>
    			<batch:fail on="FAILED"/>
    			<batch:next on="COMPLETED" to="stepB2"/>
    		</batch:step>
    		<batch:step id="stepB2">
    			<batch:tasklet>
    				<beans:bean class="somet.package.SimpleTaskletImplementation"/>
    			</batch:tasklet>
    			<batch:fail on="FAILED"/>
    		</batch:step>
    	</batch:flow>
    Here is a log:
    Code:
    2156 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.step.AbstractStep  - Step execution complete: StepExecution: id=3, name=stepB2, status=FAILED, exitStatus=FAILED, readCount=0, fil
    terCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=1
    2156 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.job.flow.support.SimpleFlow  - Completed state=stepB.stepB2 with status=FAILED
    2156 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.step.AbstractStep  - Step execution success: id=1
    2171 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.step.AbstractStep  - Step execution complete: StepExecution: id=1, name=stepB, status=COMPLETED, exitStatus=COMPLETED, readCount=0
    , filterCount=0, writeCount=0 readSkipCount=0, writeSkipCount=0, processSkipCount=0, commitCount=0, rollbackCount=0
    2171 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.job.flow.support.SimpleFlow  - Completed state=singleThreadJob.stepB with status=COMPLETED
    2171 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.batch.core.job.flow.support.SimpleFlow  - Handling state=singleThreadJob.stepC
    2171 [SimpleAsyncTaskExecutor-1] INFO  org.springframework.batch.core.job.SimpleStepHandler  - Executing step: [stepC]
    As you see above:
    name=stepB2, status=FAILED
    and than:
    name=stepB, status=COMPLETED

    I tried to debug a bit but I didn't found any place where FlowStep will populate SimpleFlow status to it's own status. Maybe it's the problem.

    Anyway, I waiting for any feedback.

    BTW: There is an information in documenatation on-line for Spring Batch (Chapter 5) that 'step' tag has 'flow' attribute. Sorry but I didn't found this definition in 2.1 schema. the job was faild on context load than as not valid against of spring batch schema. However there is an logic in Custom Namespace Parsers to support it. Only problem is that attribute is not defined in schema.

    Ok, looking for any answer.
    Jul

  • #2
    Originally posted by Jul View Post
    Hi Lads,
    I tried to debug a bit but I didn't found any place where FlowStep will populate SimpleFlow status to it's own status. Maybe it's the problem.
    Sounds like a bug. Can you open a JIRA? A workaround would be to use a JobStep or your own version of FlowStep (which would make using the xml DSL difficult), or you could simply define the steps inline in your main job flow.

    BTW: There is an information in documenatation on-line for Spring Batch (Chapter 5) that 'step' tag has 'flow' attribute. Sorry but I didn't found this definition in 2.1 schema. the job was faild on context load than as not valid against of spring batch schema. However there is an logic in Custom Namespace Parsers to support it. Only problem is that attribute is not defined in schema.
    That must be a bug (surprising there is no test for it). Can you raise a JIRA?
    Last edited by Dave Syer; Aug 22nd, 2010, 03:08 AM. Reason: spelling

    Comment


    • #3
      https://jira.springsource.org/browse/BATCH-1620
      https://jira.springsource.org/browse/BATCH-1621

      Comment

      Working...
      X