spring batch

Edit

사례

예제

JavaConfig

http://blog.codecentric.de/en/2013/06/spring-batch-2-2-javaconfig-part-1-a-comparison-to-xml/

Transaction

Architecture

Monitoring

Spring Batch Metric

JSR 352

핵심 commit

Spring Batch 6.0 개선

Spring Batch 6.0

배치 처리 일반

Spring batch article

공식자료

Spring batch와 Quartz

주요용어

version

버전 RC (Release Candidate) - 베타 버전(Beta Version) 보다 1단계 개선된 버전. 일반적으로 개발 도중의 제품은 알파 버전→베타 버전→제품 버전으로 진행되는데, 운용 체계 등 대규모 소프트웨어에 대해서 다양한 환경에서의 시험을 위해 베타 버전과 제품 버전 사이의 과정에서 추가로 수행되는 버전들이다. 그 제품을 도입하는 사용자에게 광범위하게 배포해, 실제 환경에서의 시험을 실시하고, 필요하면 RC1→RC2→RC3식으로 버전을 거친 후 최종 제품 버전으로 진행한다.

주목할 만한 기능

XStream쓸 때

marshal -> marshalStaxResult -> marshalXmlEventWriter -> marshalSaxHandlers

NoStartEndDocumentStreamWriter

Spring batch XML

<dependency>
    <groupId>org.springframework.ws</groupId>
    <artifactId>spring-ws-core</artifactId>
    <version>1.5.4</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<bean id="regisonMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller">
    <property name="aliases">
        <map>
            <entry key="item" value="com.nhncorp.moca.etl.batch.domain.RegionSido" />
            <entry key="regionGugun" value="com.nhncorp.moca.etl.batch.domain.RegionGugun" />
            <entry key="sidoCode" value="java.lang.String" />
        </map>
    </property>
    <property name="implicitCollection">
        <map>
            <entry key="regionGugunList" value="com.nhncorp.moca.etl.batch.domain.RegionSido" />
        </map>
    </property>
</bean>

2.0 변화

JobRepository 관련

2.0.0

프로젝트 소개정보

Spring batch 국내자료

Spring Batch Admin

Spring Batch Admin 모듈 설치

Springsource에서 제공하는 Spring batch Admin 모듈 올리기

스프링배치 어드민 프로젝트는 Spring Batch로 만들어진 Job들의 실행이력을 조회하고 수동실행할 수 있는 기능을 제공하는 프로젝트입니다. 스프링배치에서는 Job과 Step의 실행이력 정보를 메타데이터 테이블에 저장을 하도록 되어 있습니다. 그런 메타정보가 저장되는 테이블의 레이아웃은 아래와 같습니다.

meta-data-erd

기존에 사용하고 있던 어플리케이션에서 스프링배치 어드민 모듈을 올릴 때는 아래와 같은 버전 업그레이드 작업을 해줘아합니다.

Spring 3.0.2 upgrade

Spring Batch 2.1.1 upgrade

Spring Batch Admin 추가

pom.xml에 Dependency와 Repository 선언에 추가

<dependency>
    <groupId>org.springframework.batch</groupId>
    <artifactId>spring-batch-admin-manager</artifactId>
    <version>1.0.0.CI-SNAPSHOT</version>
</dependency>
<repository>
    <id>spring-snapshots</id>
    <name>Spring Maven Snapshot Repository</name>
    <url>http://s3.amazonaws.com/maven.springframework.org/snapshot</url>
</repository>

초간단 Batch Admin 모듈

Spring Batch Scalability

Project

Grid gain

Spring Batch retry

  1. RetryTemplate 설정(java config or xml)
@Bean
public RetryOperations deadLockRetry(){
    RetryTemplate template = new RetryTemplate();

    Map<Class<? extends Throwable>, Boolean> exceptions = new HashMap<Class<? extends Throwable>, Boolean>();
    exceptions.put(DeadlockLoserDataAccessException.class, true);
    SimpleRetryPolicy policy = new SimpleRetryPolicy(3,exceptions);
    template.setRetryPolicy(policy);
    return template;
}
  1. AOP 설정
<bean id="retryAdvice"
     class="org.springframework.batch.retry.interceptor.RetryOperationsInterceptor">
  <property name="retryOperations" ref="deadLockRetry">

<aop:config>
  <aop:advisor pointcut="execution(execution(* com.nhncorp..클래스명.execute(..))" advice-ref="retryAdvice" order="-1"/>
</aop:config>

JobRepository DeadLock

Transaction밖에서 retry 하라...

Children