Announcement Announcement Module
Collapse
No announcement yet.
Problems with handling ExitStatus.FAILED coming from a parallel executed Tasklet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with handling ExitStatus.FAILED coming from a parallel executed Tasklet

    Hello,
    the job has parallel executions and I get problems with an exception in one of the parallel executed Tasklets. The 'non-parallel-step' works fine. If an exception is thrown, the ExitStatus is FAILED and an email is sent. Right the way it is declared (see below).

    The same implementation does not work for the parallel steps, e.g. inventory-step. If I do not mention next on="FAILED" the error message of the framework is:
    Caused by: org.springframework.batch.core.job.flow.FlowExecut ionException: Next state not found in flow=processing-flow.0 for state=processing-flow.0.inventory-step with exit status=FAILED
    .

    If I declare it the same way as 'non-parallel-step' I get:
    java.lang.IllegalArgumentException: Missing state for [StateTransition: [state=processing-flow.0.inventory-step, pattern=FAILED, next=processing-flow.0.send-email]]
    when the VM starts and it fails starting completely.

    Code:
       <batch:job id="case-b-job">
            <batch:step id="non-parallel-step">
                <batch:tasklet ref="nonParallelTasklet" transaction-manager="jobRepositoryTransactionManager"/>
                <batch:next on="CONTINUABLE" to="non-parallel-step"/>
                <batch:next on="COMPLETED" to="processing-flow"/>
                <batch:next on="FAILED" to="send-email"/>
            </batch:step>
            <!-- parallel executions -->
            <batch:split id="processing-flow" task-executor="taskExecutor">
                <batch:flow>
                    <batch:step id="inventory-step">
                        <batch:tasklet ref="inventoryTasklet" transaction-manager="jobRepositoryTransactionManager"/>
                        <batch:next on="CONTINUABLE" to="inventory-step"/>
                        <batch:end on="FINISHED"/>
                        <!--<batch:next on="FAILED" to="send-email"/>-->
                    </batch:step>
                </batch:flow>
                <batch:flow>
                    <batch:step id="amorgos-step">
                        <batch:tasklet ref="amorgosTasklet" transaction-manager="jobRepositoryTransactionManager"/>
                        <batch:next on="CONTINUABLE" to="amorgos-step"/>
                        <batch:end on="FINISHED"/>
                        <!--<batch:next on="FAILED" to="send-email"/>-->
                    </batch:step>
                </batch:flow>
                <batch:next on="*" to="send-email"/>
                <batch:end on="COMPLETED"/>
            </batch:split>
    
            <batch:step id="send-email">
                <batch:tasklet ref="emailTasklet" transaction-manager="jobRepositoryTransactionManager"/>
                <batch:fail on="*" exit-code="FAILED"/>
            </batch:step>
        </batch:job>
    How can I neatly and working configure an exception case in parallel execution with Tasklets?

    Thanks in advance,
    kieran

  • #2
    Hi,

    I don't use <batch:split> however, I believe your use case is to send email on success/failure. Is that correct?

    If your answer to my question is "Yes" then you should be able to use JobExecutionListener to monitor the job status and send email notification in one go after the job is either COMPLETED/FAILED. Also, if you don't want to wait for the job to complete and instead want to send emails after each step then you should be able to use StepExecutionListener.

    Comment


    • #3
      Yes, email is sent in error case. And this should be configurable in the job declaration. Using a listener would mean to code it, wouldn't it?

      Any other ideas out there???

      Comment

      Working...
      X