spring batch 2.1.6을 기준으로 설명한다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<description>Example job to get you started. It provides a
skeleton for a typical batch application.</description>
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>
<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>
<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>
'general java' 카테고리의 다른 글
Spring Batch retry 예제들 (0) | 2011.04.06 |
---|---|
[Spring Batch] CommandlineJobRunner 병렬 실행 TestCase (0) | 2011.03.22 |
[Spring Batch] retry-policy가 존재하면, 반드시 retry-limit이 존재해야 한다. (0) | 2011.03.17 |
[Spring Batch] Oracle DB-Job실행중 ORA-08177 발생 (0) | 2011.02.25 |
spring framework 소스 및 jar maven 파일 다운받기 (0) | 2011.02.07 |