배치작업(Job)을 위한 XML 작성

배치의 단위 스텝은 ItemReader, ItemProcessor, ItemWriter로 구성되고 배치작업은 하나 이상의 스텝이 플로우 형태로 구성된다. 외부에서 실행될 수 있는 배치의 최소단위는 배치작업(Job)이므로 사용자는 배치 작업의 실행을 위해 "Job"을 다음처럼 XML에 기술하여 정의한다.

(1) XML 작성

배치 어플리케이션의 META-INF 에 배치작업(Job) 명의 이름으로 XML 파일을 생성한다.

다음 예는 위에 작성한 배치를 실행할 수 있도록 작성된 배치작업(Job)의 XML 설정이다.

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:batch="http://www.springframework.org/schema/batch"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:batch-int="http://www.springframework.org/schema/batch-integration"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
                           http://www.springframework.org/schema/batch-integration http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">

    <!--
        * BatchJob  : DB TO DB Sample
        * BatchStep :
            - sample-db-to-fixed-001 : DB TO DB process
     -->
    <job id="sample-db-to-db" xmlns="http://www.springframework.org/schema/batch">
        <step id="sample-db-to-fixed-001" parent="parentStep">
            <tasklet>
                <chunk reader="MSmpDBToDBBtch" processor="MSmpDBToDBBtch" writer="MSmpDBToDBBtch"/>
            </tasklet>
        </step>
    </job>
</beans>

다음은 위의 과정을 예로 배치 작업(Job) XML을 작성하는 방법에 대한 기술 내용이다.

1. 명명규칙에 따라 "job id" 즉, 배치 작업(Job) ID를  지정한다.

2. 첫 번째 Step을 정의하고 명명 규칙에 따라 "Step Id"를 지정한다. 현재 사용중인 예제에서는 하나의 스텝만을 가지는 것으로 배치작업(Job)을 구성한다.

3. Step에서 수행할 실제 작업을 "tasklet"으로 정의한다.

4. 구간별로 처리결과를 커밋 하기 위해 "chunk" 를 이용하여 "reader", "processor", "writer" 항목에 위의 과정에서 작성한 빈(Bean) 이름을 지정한다.
SWLab Bankware Global
  • 전체
  • BXM
  • BXCM
  • BXCP
  • BXI
제품 선택 시 더 정확한 매뉴얼 가이드를 제공해드립니다.

Copyright© Bankwareglobal All Rights Reserved.