VARIABLE TO VARIABLE

  • 배치 작업 Xml Sample

<?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">

    <!--
        * 배치작업 : 샘플 VARIAVLE TO VARIAVLE 처리 배치
        * 배치스텝
            - sample-variable-to-variable-001 : 가변길이이 데이터를 String 으로 Read하여 String으로 Write 처리
     -->
    <job id="sample-variable-to-variable" xmlns="http://www.springframework.org/schema/batch">
        <step id="sample-variable-to-variable-001">
            <tasklet>
                <chunk reader="r-sample-variable-to-variable-001" processor="SmpVariableToVariableChunk" writer="w-sample-variable-to-variable-001" />
            </tasklet>
        </step>
    </job>

    <!--
        * 샘플용직원정보 Variable File을 Read 하기위한 bean 설정
    -->
    <bean id="r-sample-variable-to-variable-001" parent="RString" scope="step">
        <property name="name" value="r-sample-variable-to-variable-001" />
        <property name="resource" value="file:///${prefixFilePath}/test-fixed-file-#{jobParameters['deptNo']}.txt" />
    </bean>

    <!--
        * 샘플용직원정보 Variable File을 Write 하기위한 bean 설정
    -->
    <bean id="w-sample-variable-to-variable-001" parent="WString" scope="step">
        <property name="name" value="sample-file-line-001-Reader" />
        <property name="resource" value="file:///${prefixFilePath}/test-variable-file-#{jobParameters['deptNo']}.txt" />
    </bean>

</beans>
  • 배치 소스코드 Sample

package sample.batch.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import bxm.common.annotaion.BxmCategory;
import bxmc.batch.item.reader.StringReaderObject;

/**
 * 샘플 Variable TO Variable 배치
 *
 * @author sysadmin
*/
@Scope("step")
@Service("SmpVariableToVariableChunk")
@BxmCategory(logicalName="VARIABLE TO VARIABLE 샘플", description="VARIABLE TO VARIABLE 샘플")
public class SmpVariableToVariableChunk implements ItemProcessor<StringReaderObject, String>{
    private Logger logger= LoggerFactory.getLogger(getClass());

    /**
     * process
     * - 처리 대상 데이터를 건 별로 업무요건에 따라 처리하는 역할을 수행한다.
     */
    @Override
    @BxmCategory(logicalName = "process : 샘플용 직원정보 처리", description = "process : 샘플용 직원정보를 1건씩 처리한다.")
    public String process(StringReaderObject in) throws Exception {

        /********************************************************************
         * Variable 유형은 직접 문자열을 읽거나 혹은 문자열을 쓸때 사용하는 유형이다.
         * - 파일 read  : 1라인씩 read하여 process로 전달
         * - 파일 write : process에서 return한 문자열을 1라인씩 write
         ********************************************************************/

        /**
         * 개별 업무로직 수행
         * ...
         * ...
         */
        int empNo = Integer.parseInt(in.getData().substring(0, 10));
        String empNm = in.getData().substring(10, 20);

        /**
         * return
         */
        return String.format("%15d%15s", empNo , empNm);
    }
}
SWLab Bankware Global
  • 전체
  • BXM
  • BXCM
  • BXCP
  • BXI
제품 선택 시 더 정확한 매뉴얼 가이드를 제공해드립니다.

Copyright© Bankwareglobal All Rights Reserved.