사용자 정의 Java 프로시저를 사용하여 메시지 플로우 개발

시작하기 전에
이 단계는 단순 메시지 강화를 수행하기 위한 시나리오의 11번째 단계입니다. 이 주제에서는 사용자 정의 Java 프로시저를 사용하여 메시지 플로우를 개발하는 방법에 대해 설명합니다. 해당 메시지 모델 및 인스턴스 문서 개발에도 관련됩니다.
  1. COMPLEX 메시지 정의의 www.complex.net 네임스페이스에서 다음과 같은 구조의 addev6in 및 addev6out 메시지를 작성하십시오.
    addev6in
    hexdata                (xsd:hexBinary) local element
    addev6out
    decval                  (xsd:decimal) local element
    fltval                     (xsd:float) local element
    intval                    (xsd:int) local element
  2. MQInput > Mapping > MQOutput 맵핑을 포함하는 addev6 메시지 플로우를 작성하십시오.
  3. 맵을 열고 addev6in을 소스로, addev6out을 대상으로 선택하십시오.
  4. MAPPING3_COMPLEX_flows 프로젝트에서 addev6이라는 ESQL 파일을 작성하고 여기에 다음 함수를 넣으십시오.
    CREATE PROCEDURE decFromBinary( IN hexval BLOB )
    RETURNS DECIMAL
    LANGUAGE JAVA
    EXTERNAL NAME "addev6.decFromBinary";
    CREATE PROCEDURE fltFromBinary( IN hexval BLOB )
    RETURNS DECIMAL
    LANGUAGE JAVA
    EXTERNAL NAME "addev6.fltFromBinary";
    CREATE PROCEDURE intFromBinary( IN hexval BLOB )
    RETURNS DECIMAL
    LANGUAGE JAVA
    EXTERNAL NAME "addev6.intFromBinary";
  5. 다음 컨텐츠를 가진 addev6.java Java 소스 파일을 작성하십시오.
    import java.lang.*;
    import java.math.*;
    public class addev6 {
    //
    // Return decimal element from binary string
    //
    public static BigDecimal decFromBinary( byte[] hexval) {
    // Look for element named decval
    String search = "decval";
    String snval = findElement(hexval ,search );
    // Convert the value to decimal type
    BigDecimal numval = new BigDecimal(snval);
    return numval;
    }
    //
    // Return float element from binary string
    //
    public static Double fltFromBinary( byte[] hexval) {
    // Look for element named fltval
    String search = "fltval";
    String snval = findElement(hexval ,search );
    // Convert the value to float type
    Double numval = new Double(snval);
    return numval;
    }
    //
    // Return integer element from binary string
    //
    public static Long intFromBinary( byte[] hexval) {
    // Look for element named intval
    String search = "intval";
    String snval = findElement(hexval ,search );
    // Convert the value to integer type
    Long numval = new Long(snval);
    return numval;
    }
    //
    // Locate the named element and its value in the binary data
    //
    private static String findElement( byte[] hexval, String search ) {
    // Convert bytes to string
    String hexstr = new String(hexval);
    // Fixed length label/value pairs (length=14)
    int nvals = hexstr.length() / 14;
    String numval = "";
    String[] label = new String[nvals];
    String[] value = new String[nvals];
    // Loop over number of label/value pairs
    for ( int i=0; i < nvals; i ++ ) {
    // get start position
    int st = i * 14;
    // label is length 6
    int endl = st + 6;
    // value is length 8
    int endv = endl + 8;
    // extract label and value from string
    label[i] = hexstr.substring( st, endl);
    value[i] = hexstr.substring( (endl+1), endv);
    // Check whether the current pair has the label requested
    if ( label[i].compareTo( search) == 0 ) {
    // trim padding from the value
    numval = value[i].trim();
    }
    }
    return numval;
    }
    }
  6. Java 코드를 컴파일하고 시스템 CLASSPATH에 클래스 파일의 위치를 추가하십시오. Windows를 재시작해야 할 수도 있습니다.
  7. 메시지 맵핑 편집기의 스프레드시트 분할창에서 대상 메시지를 펼치고 decval 대상 값을 esql:decFromBinary($source/comp:addev6in/bval)로 설정하십시오.
  8. fltval 대상을 esql:fltFromBinary($source/comp:addev6in/bval)로 설정하십시오.
  9. intval 대상을 esql:intFromBinary($source/comp:addev6in/bval)로 설정하십시오.
  10. 등록 정보 대상을 펼치고 다음과 같은 값을 설정하십시오.
    MessageType     |     'addev6out
  11. 적절한 RFH2 헤더를 사용하여 다음 인스턴스 메시지를 작성하십시오.
    <comp:addev6in xmlns:comp="http://www.complex.net">
    <bval>
    <![CDATA[64656376616c20202031342e3238666c7476616c
    2020312e34452b32696e7476616c2020202020313230]]>
    </bval>
    </comp:addev6in>
다음과 같은 자원을 작성했습니다.
이제 메시지 세트 및 메시지 플로우를 전개하십시오.

메시지 세트 및 메시지 플로우 전개

이 단계는 단순 메시지 강화를 수행하기 위한 시나리오의 최종 단계입니다. 이 주제에서는 메시지 세트 및 메시지 플로우를 전개하고 브로커를 통해 인스턴스 메시지를 실행하는 방법에 대해 설명합니다.
  1. BAR 파일 addev6을 작성하십시오.
  2. MAPPING3_COMPLEX_messages 메시지 세트 및 addev6 메시지 플로우를 BAR 파일에 추가하십시오.
  3. 브로커에 BAR 파일을 전개하십시오.
  4. 인스턴스 문서를 입력 큐에 넣으십시오.
출력 메시지는 다음과 같습니다.
<comp:addev6out xmlns:comp="http://www.complex.net">
<decval>14.28</decval>
<fltval>1.4E+2</fltval>
<intval>120</intval>
</comp:addev6out>
이 시나리오가 완료되었습니다.
주의사항 | 등록상표 | 다운로드 | 라이브러리 | 지원 | 피드백
Copyright IBM Corporation 1999, 2006 마지막 갱신 날짜: 5월 12, 2006
ar25251_11_