공통 Job Configuration Xml 처리

배치 실행 시 배치 Job Xml에서 공통화 혹은 필수 처리 등을 공통 Job Configuration Xml 파일 (JobConfig.xml) 을 구성하여 처리 할 수 있다.

1. 공통 Job Configuration Xml 생성 (JobConfig.xml)

Job Configuration Xml은 일반 적인 배치 Job Xml과 구성 방법이 동일하다. 아래의 예는 일반적으로 Job Configuration 을 생성하는 기본 Template이다.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:batch="http://www.bankwareglobal.com/schema/batchex"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.bankwareglobal.com/schema/batchex www.bankwareglobal.com/bxm/batchex/spring-batch-ex.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


    <!-- ============================== -->
    <!-- Batch Job Configuration Xml    -->
    <!-- ============================== -->

</beans>

2. 공통 Job Configuration Xml Import 처리

'공통 Job Configuration Xml 생성' 을 통하여 생성한 공통 Job Configuration Xml 파일을 사용하려면 배치 Job Xml에서 import 처리를 하여야 한다. Import 처리하는 방법은 아래의 예 처럼 2가지가 있다.

공통 Job Configuration Xml 를 추가하는 경우, 모든 배치 Job Xml 파일에 Import하는 설정을 추가해야 한다.

2.1. classpatch 설정 처리

Job Configuration Xml 파일()을 배치 Customizing 라이브러리 혹은 Job Configuration Xml 파일을 직접 classpath 를 설정한 경우에 처리

  • 라이브러리에 있는 Job Configuration Xml 파일을 추가한 경우

        <import resource="classpath:bxm/batch/customizing/resource/JobConfig.xml"/>
  • Job Configuration xml 파일을 직접 classpath를 설정한 경우

        <import resource="classpath:JobConfig.xml"/>

2.2. 디렉토리 설정 처리

실행하고 있는 배치 Job Xml 파일이 있는 디렉토리를 기준으로 처리

    <import resource="JobConfig.xml" />

3. 공통 Job Configuration Xml 추가 예

공통 Job Configuration Xml에 추가할 수 있는 방법은 여러 가지가 있다. 다음은 Job Configuration Xml에 추가하는 대표적인 몇 가지 예를 설명한 것이다. Job Configuration Xml 설정 시 아래의 예를 참고하여 작성 할 수 있도록 한다.

3.1. 파일 처리 공통화

BXM 배치 프레임워크 에서 OMM을 이용하여 파일 처리를 하기 위하여 파일 Read를 처리하는 "FixedFileReader", “DelimitedFileReader” 와 파일 Write를 처리하는 "FixedFileWriter", "DelimitedFileWriter" 를 제공하여 주고 있다. 파일 처리 Component는 직접 배치 Job Xml에 작성할 수 있을 뿐만 아니라 공통 Job Configuration File에 공통화 해서 좀더 Simple하게 작성 할 수 있다.

배치 Job Xml에서 기본적으로 파일 처리하는 예는 다음과 같다.

  • 예) Fixed File Read

        <bean id="BeanID입력" class="bxm.batch.item.file.ext.FixedFileReader" abstract="true">
            <property name="strict" value="true" />
            <property name="encoding" value="UTF-8" />
            <property name="targetType" value="bxm.customizing.dto.TestBeanDTO" />
        </bean>

다음은 기본파일 처리를 공통 Job Configuration Xml 파일로 공통화한 예이다.

  • 공통 Job Configuration Xml (RFixed로 Bean Id 정의)

    아래의 예는 strict 값을 true, encoding 값을 Default 값으로 설정한 예이다.

    (참고 : strict 는 파일 존재 여부에 따라 에러를 발생 시킬 것인지에 대한 처리 옵션 값이다.)

        <bean id="RFix" class="bxm.batch.item.file.ext.FixedFileReader" abstract="true">
            <property name="strict" value="true" />
            <property name="encoding" value="UTF-8" />
            <property name="targetType" value="bxm.omm.root.IOmmObject" />
        </bean>
  • 배치 Job Xml (업무)

    공통 Job Configuration Xml 파일에 정의한 Bean을 참조하여 처리.

    1. strict와 encoding 설정 값은 공통 Job Configuration Xml의 값을 사용하므로 설정하지 않는다.

    2. parent 에 공통 Job Configuration Xml 에 정의한 Bean ID를 설정한다.

          <bean id="빈ID입력" parent="RFix"scope="step">
              <property name="resource" value="file:///bxm/file/bxmtest/file.dat" />
              <property name="targetType" value="bxm.customizing.dto.TestBeanDTO" />
          </bean>

FixedFileReader, DelimitedFileReader, FixedFileWriter, DelimitedFileWriter 기본 Property

FixedFileReader, DelimitedFileReader : 파일 Reader*
Property 설명

strict

파일 존재 여부 체크 (true : 체크, false : 체크하지 않음).
Default 값은 true

encoding

파일 Read시 읽으려는 encoding 설정

resource

Read 하려는 파일 Resource Location

queueSize

파일 Read 시 Queue에 저장 처리하는 Size. Default 값은 20.

lineSeparator

파일 Read 개행처리 값 설정 (참고 : 각 시스템에서
생성하는 기본 개행 처리 값이 다름)

delimiter

Delimiter 형식으로 파일 Read시 구분값 설정

FixedFileWriter, DelimitedFileWriter : 파일 Writer*
Property 설명

encoding

파일 Write encoding 설정

resource

Write 하려는 파일 Resource Location

lineSeparator

파일 Write 시 개행처리 값 설정 (참고 : 각 시스템에서
생성하는 기본 개행 처리 값이 다름)

appendAllowed

파일 Write시 파일이 존재하는 경우 Append 해서 처리를 할
것인지에 대한 설정

shouldDeleteIfEmpty

Write 한 파일 사이즈가 0 인 경우 파일을 삭제할
것인지에 대한 Property

delimiter

Delimiter 형식으로 파일 Write시 구분값 설정

Copyright© Bankwareglobal All Rights Reserved.