MultiType Read, Write

  • 배치 작업 Xml Sample

<?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-int="http://www.springframework.org/schema/batch-integration"
xsi:schemaLocation="http://www.bankwareglobal.com/schema/batchex http://www.bankwareglobal.com/schema/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/batch-integration http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">

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

    <job-component xmlns="http://www.bankwareglobal.com/schema/batchex" id="jobcomp" with-dependon="true">
        <base-package name="bxm.dft.smp.batch.bean">
            <include name="MSmpMultiType*Btch"/>
        </base-package>
    </job-component>

    <!--
        * 배치작업 : RMultiType(FIXED) TO WMultiType(DELIMITED) 샘플
        * 배치스텝
            - JSmpMultiType100 : RMultiType(FIXED) TO WMultiType(DELIMITED) 샘플
     -->
    <job id="JSmpMultiType" xmlns="http://www.bankwareglobal.com/schema/batchex">
        <step id="JSmpMultiType100" parent="parentStep">
            <tasklet>
                <chunk reader="RJSmpMultiType100" processor="MSmpMultiTypeBtch" writer="WJSmpMultiType100"/>
            </tasklet>
        </step>
    </job>

 <!--
  * MultiType Fixed File을 Read 하기위한 bean 설정
  -->
    <bean id="RJSmpMultiType100" parent="RMultiTypeFix" scope="step">
        <property name="resource" value="file:///data1/prod/bxm400/dat/input.txt" />
        <property name="encoding" value="UTF-8" />
        <property name="headerLine" value="1"/>
        <property name="footerLine" value="1"/>
        <property name="headerTargetType" value="bxm.dft.smp.batch.bean.dto.MSmpMultiTypeBtch02Dto"/>
  <property name="bodyTargetType" value="bxm.dft.smp.batch.bean.dto.MSmpMultiTypeBtch03Dto"/>
  <property name="footerTargetType" value="bxm.dft.smp.batch.bean.dto.MSmpMultiTypeBtch04Dto"/>
 </bean>

 <!--
  * MultiType Delimited File 로 Write 하기위한 bean 설정
  -->
 <bean id="WJSmpMultiType100" parent="WMultiTypeDelimit" scope="step">
        <property name="resource" value="file:///data1/prod/bxm400/dat/output.txt" />
        <property name="encoding" value="UTF-8" />
        <property name="delimiter" value=";"/>
        <property name="targetType" value="bxm.dft.smp.batch.bean.dto.MSmpMultiTypeBtch01Dto" />
 </bean>
</beans>

*배치 소스코드 Sample

@BxmBean("MSmpMultiTypeBtch")
@Scope("step")
@BxmCategory(logicalName = "RMultiTypeFix to WMultiTypeDelimit 샘플")
public class MSmpMultiTypeBtch implements ItemProcessor<IOmmObject, MSmpMultiTypeBtch01Dto> {
 final Logger logger = LoggerFactory.getLogger(this.getClass());
 /**
  * process
  * - 처리 대상 데이터를 건 별로 업무요건에 따라 처리하는 역할을 수행한다.
  */
 @Override
 @BxmCategory(logicalName = "process : MultiType 처리")
 public MSmpMultiTypeBtch01Dto process(IOmmObject in) throws Exception {
  MSmpMultiTypeBtch01Dto out = new MSmpMultiTypeBtch01Dto();
  MSmpMultiTypeBtch02Dto header = null;
  MSmpMultiTypeBtch03Dto body = null;
  MSmpMultiTypeBtch04Dto footer = null;
  if (in instanceof MSmpMultiTypeBtch02Dto) { // Header
   header = (MSmpMultiTypeBtch02Dto) in;
  } else if (in instanceof MSmpMultiTypeBtch03Dto) { // Body
   body = (MSmpMultiTypeBtch03Dto) in;
  } else if (in instanceof MSmpMultiTypeBtch04Dto) { // Footer
   footer = (MSmpMultiTypeBtch04Dto) in;
  }
  /**
   * Multi Type Out Dto 처리
   * - Multi Type의 Write 처리는 Master DTO에 include하여 정의한다.
   * - 참고로 이 샘플은 Read한 DTO를 그대로 Write로 전달하도록 구성한 샘플이다.
   */
  if (header != null) {
   out.setHeader(header);
  }
  if (body != null) {
   out.setBody(body);
  }
  if (footer != null) {
   out.setFooter(footer);
  }
  return out;
 }
}
SWLab Bankware Global
  • 전체
  • BXM
  • BXCM
  • BXCP
  • BXI
제품 선택 시 더 정확한 매뉴얼 가이드를 제공해드립니다.

Copyright© Bankwareglobal All Rights Reserved.