how to abort a spring batch job if any chunk fails
<p>I have a spring batch application which reads the data from master table and moves all the records which are older that 90 days to an archive table.</p>

<p>the application context file is as 
    "</p>

<pre><code>&lt;context:property-placeholder location="classpath:batch.properties" /&gt;

&lt;context:component-scan base-package="com.prax.batch" /&gt;

&lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" &gt;
    &lt;property name="url" value="${batch.jdbc.url}"/&gt;
    &lt;property name="driverClassName" value="${batch.jdbc.driver}"/&gt;
    &lt;property name="username" value="${batch.jdbc.user}"/&gt;
    &lt;property name="password" value="${batch.jdbc.password}"/&gt;
&lt;/bean&gt;

&lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
    &lt;property name="dataSource" ref="dataSource"/&gt;
&lt;/bean&gt;

&lt;bean id="jobReposotoryTransactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/&gt;

&lt;bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher"&gt;
    &lt;property name="jobRepository" ref="jobRepository"&gt;&lt;/property&gt;
&lt;/bean&gt;

&lt;!-- &lt;jdbc:initialize-database data-source="dataSource"&gt;
    &lt;jdbc:script location="${batch.schema.script}" /&gt;
&lt;/jdbc:initialize-database&gt; --&gt;

&lt;!-- &lt;batch:job-repository id="jobRepository" transaction-manager="jobReposotoryTransactionManager"&gt;&lt;/batch:job-repository&gt; --&gt;

&lt;bean id="jobRepository" class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean" &gt;
    &lt;property name="transactionManager" ref="jobReposotoryTransactionManager"/&gt;
&lt;/bean&gt;

&lt;import resource="classpath:/META-INF/spring/module-context.xml" /&gt;



&lt;/beans&gt;
</code></pre>

<p>and  job context file is as </p>

<pre><code>&lt;batch:job id="fqtvArchiveJob"&gt;
    &lt;batch:step id="readWriteDeleteStep"&gt;
        &lt;batch:tasklet transaction-manager="transactionManager"
            start-limit="10"&gt;
            &lt;batch:chunk reader="fqtvreader" writer="fqtvcompositewriter"
                commit-interval="1000" /&gt;
        &lt;/batch:tasklet&gt;
    &lt;/batch:step&gt;
&lt;/batch:job&gt;


&lt;bean id="fqtvreader"
    class="org.springframework.batch.item.database.JdbcCursorItemReader"&gt;
    &lt;property name="rowMapper" ref="fqtvrowmapper" /&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="sql" value="${batch.reader.sql}" /&gt;
    &lt;property name="maxRows" value="0"/&gt;
    &lt;property name="fetchSize" value="0" /&gt;
&lt;/bean&gt;

&lt;bean id="fqtvinsertwriter"
    class="org.springframework.batch.item.database.JdbcBatchItemWriter"&gt;
    &lt;property name="assertUpdates" value="true" /&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="itemPreparedStatementSetter" ref="fqtvpreparedstatementsetter" /&gt;
    &lt;property name="sql" value="${batch.writer.insert.sql}" /&gt;
&lt;/bean&gt;

&lt;bean id="fqtvdeletewriter"
    class="org.springframework.batch.item.database.JdbcBatchItemWriter"&gt;
    &lt;property name="assertUpdates" value="true" /&gt;
    &lt;property name="dataSource" ref="dataSource" /&gt;
    &lt;property name="itemPreparedStatementSetter" ref="deletestatementsetter" /&gt;
    &lt;property name="sql" value="${batch.writer.delete.sql}" /&gt;
&lt;/bean&gt;

&lt;bean id="fqtvcompositewriter"
    class="org.springframework.batch.item.support.CompositeItemWriter"&gt;
    &lt;property name="delegates"&gt;
        &lt;list&gt;
            &lt;ref local="fqtvinsertwriter"/&gt;
            &lt;ref local="fqtvdeletewriter"/&gt;
        &lt;/list&gt;
    &lt;/property&gt;
&lt;/bean&gt;

&lt;bean id="fqtvrowmapper" class="com.prax.job.util.FqtvRowMapper"          /&gt;

&lt;bean id="fqtvpreparedstatementsetter"
    class="com.prax.job.util.FqtvPreparedStatementSetter" /&gt;

&lt;bean id="deletestatementsetter"
    class="com.prax.job.util.FqtvDeleteStatementSetter" /&gt;

&lt;/beans&gt;
</code></pre>

<p>I have the requirement that if archiving of any item fails, the batch should stop and not archive any more record and send the mail notification to the users.</p>