spring batch 2.1.6을 기준으로 설명한다.


 <description>Example job to get you started. It provides a
  skeleton for a typical batch application.</description>
  <job id="job_mssql" xmlns="http://www.springframework.org/schema/batch">
  <step id="step1" parent="simpleStep">
   <tasklet>
    <chunk reader="reader" writer="writer" retry-policy="batchRetryPolicy" > 
    </chunk>
   </tasklet>
  </step>
 </job>

 <bean id="reader" class="org.springframework.sample.batch.example.ExampleItemReader"/>
 <bean id="writer" class="org.springframework.sample.batch.example.ExampleItemWriter" />
 <bean id="retryListener" class="org.springframework.sample.batch.example.RetryListenerSupport" />
 
 <bean id="simpleStep"
  class="org.springframework.batch.core.step.item.SimpleStepFactoryBean"
  abstract="true">
  <property name="transactionManager" ref="transactionManager" />
  <property name="jobRepository" ref="jobRepository" />
  <property name="startLimit" value="100" />
  <property name="commitInterval" value="1" />
 </bean>
  
 <bean id="batchRetryPolicy" class="org.springframework.batch.retry.policy.ExceptionClassifierRetryPolicy">
  <property name="policyMap"> 
   <map>
    <entry key="org.springframework.dao.DataAccessResourceFailureException">
     <bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
      <property name="maxAttempts" value="20" /> 
     </bean>
    </entry>
    <entry key="org.springframework.dao.DeadlockLoserDataAccessException">
     <bean class="org.springframework.batch.retry.policy.SimpleRetryPolicy">
      <property name="maxAttempts" value="20" />
     </bean>
    </entry>
   </map>
  </property>
 </bean> 
     <bean id="batchRetryTemplate" class="org.springframework.batch.retry.support.RetryTemplate">
      <property name="retryPolicy" ref="batchRetryPolicy"></property>         
     </bean> 
        
    <bean id="batchRetryAdvice" class="org.springframework.batch.retry.interceptor.RetryOperationsInterceptor">
     <property name="retryOperations" ref="batchRetryTemplate"></property>
    </bean> 
             
   <aop:config>                 
     <aop:pointcut id="launching" expression="execution(* org.springframework.batch.core.repository.JobRepository.createJobExecution(..))"/>
     <aop:advisor pointcut-ref="launching" advice-ref="batchRetryAdvice" order="-1"/>
   </aop:config>

Posted by '김용환'
,