moondaisy
moondaisy

Reputation: 4491

Java EE Batch Processing: Stop executing steps when one fails

I'm using Batch Processing, and I assumed that if a step fails then the next wouldn't be executed but that doesn't seem to be the case. So how can I get that behaviour?

This is part of my batch file:

<?xml version="1.0" encoding="UTF-8"?>
<job id="review-job" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/jobXML_1_0.xsd" version="1.0">
    <step id="step0" next="step1" >
        <batchlet ref="startProcessBatchlet">
            <properties>
                <property name="nextQueue" value="jms/step1" />
            </properties>
        </batchlet>
    </step>
    <step id="step1" next="step2"  >
        <batchlet ref="validClientBatchlet">
            <properties>
                <property name="myQueue" value="jms/step1" />
                <property name="nextQueue" value="jms/step2" />
            </properties>
        </batchlet>
    </step>
</job>

If any step fails it should stop executing and mark the batch as failed.

Upvotes: 1

Views: 927

Answers (1)

user8341239
user8341239

Reputation: 43

JSR 352 has end on clause if the job needs to fail on step failure.

Add the below statement to the jsl definition. <end on="FAILED"/>

Thanks, Sandy

Upvotes: 1

Related Questions