Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보...

48
Tmax WebTJCA User Guide Tmax v5.0 SP1 Copyright © 2009 TmaxSoft Co., Ltd. All Rights Reserved.

Transcript of Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보...

Page 1: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Tmax

WebTJCA User Guide

Tmax v5.0 SP1

Copyright © 2009 TmaxSoft Co., Ltd. All Rights Reserved.

Page 2: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Copyright Notice

Copyright © 2009 TmaxSoft Co., Ltd. All Rights Reserved.

대한민국 경기도 성남시 분당구 서현동 263 분당스퀘어(AK프라자) 12층

Restricted Rights Legend

All TmaxSoft Software (Tmax®) and documents are protected by copyright laws and the Protection Act of Com

puter Programs, and international convention. TmaxSoft software and documents are made available under the

terms of the TmaxSoft License Agreement and may only be used or copied in accordance with the terms of this

agreement. No part of this document may be transmitted, copied, deployed, or reproduced in any form or by any

means, electronic, mechanical, or optical, without the prior written consent of TmaxSoft Co., Ltd.

이 소프트웨어(Tmax®) 사용설명서의 내용과 프로그램은 저작권법, 컴퓨터프로그램보호법 및 국제 조약에 의해

서 보호받고 있습니다. 사용설명서의 내용과 여기에 설명된 프로그램은 TmaxSoft Co., Ltd.와의 사용권 계약 하에

서만 사용이 가능하며, 사용권 계약을 준수하는 경우에만 사용 또는 복제할 수 있습니다. 이 사용설명서의 전부 또

는 일부분을 TmaxSoft의 사전 서면 동의 없이 전자, 기계, 녹음 등의 수단을 사용하여 전송, 복제, 배포, 2차적 저

작물작성 등의 행위를 하여서는 안 됩니다.

Trademarks

Tmax®, Tmax WebtoB® and JEUS® are registered trademark of TmaxSoft Co., Ltd. Other products, titles or

services may be registered trademarks of their respective companies.

Tmax®, Tmax WebtoB® 와 JEUS®는 TmaxSoft Co., Ltd.의 등록 상표입니다. 기타 모든 제품들과 회사 이름은 각

각 해당 소유주의 상표로서 참조용으로만 사용됩니다.

Open Source Software Notice

This product includes various open source software that has been developed and/or licensed by “OpenSSL”, “RSA

Data Security, Inc.”, “Apache Foundation”, or “Jean-loup Gailly and Mark Adler.” TmaxSoft fully respects the

aforementioned parties and the open source software used in this product. More details can be found within the

directory “${INSTALL_PATH}/license/oss_licenses”

본 제품은 “OpenSSL”, “RSA Data Security, Inc.”, “Apache Foundation” 및 “Jean-loup Gailly와 Mark Adler”에 의

해 개발 또는 라이선스된 오픈 소스 소프트웨어를 포함합니다. 오픈 소스 소프트웨어와 개발자에 대해 경의를 표

합니다. 관련 상세 정보는 제품의 디렉터리 “${INSTALL_PATH}/license/oss_licenses”에 기재된 사항을 참고해 주

십시오.

안내서 정보

안내서 제목: Tmax WebTJCA User Guide

발행일: 2009-08-10

소프트웨어 버전: Tmax v5.0 SP1

안내서 버전: v2.1.1

Page 3: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

내용 목차

안내서에 대하여 .......................................................................................................................... vii

제1장 소개 ................................................................................................................................. 1

1.1. 개요 ............................................................................................................................ 1

1.2. JCA ............................................................................................................................. 1

1.2.1. JCA 구조 .......................................................................................................... 2

1.2.2. WebTJCA ......................................................................................................... 3

제2장 WebTJCA API .................................................................................................................. 5

2.1. CCI ............................................................................................................................. 5

2.1.1. Connection 관련 API .......................................................................................... 6

2.1.2. 서비스 요청을 위한 API ..................................................................................... 6

2.1.3. 데이터 표현 API ................................................................................................ 7

2.2. 트랜잭션 ...................................................................................................................... 8

2.2.1. XA 트랜잭션 ...................................................................................................... 8

2.2.2. 로컬 트랜잭션 ................................................................................................... 9

2.3. Logging ....................................................................................................................... 9

2.4. 비동기 요청, 대화형 통신 지원 ..................................................................................... 10

제3장 WebTJCA Inbound 통신 ................................................................................................. 11

3.1. 개요 ........................................................................................................................... 11

3.2. Worker 스레드 ............................................................................................................ 12

3.3. Message Driven Bean ................................................................................................ 13

3.4. Logging ..................................................................................................................... 14

제4장 예제 ................................................................................................................................ 15

4.1. JEUS6 에서 WebTJCA 사용 ........................................................................................ 15

4.1.1. 리소스 어댑터 구성 .......................................................................................... 15

4.1.2. Outbound 예제 ................................................................................................ 20

4.1.3. Inflow 예제 ...................................................................................................... 21

4.2. WebLogic에서 WebTJCA 사용 .................................................................................... 26

4.2.1. 리소스 어댑터 구성 .......................................................................................... 26

4.2.2. Outbound 예제 ................................................................................................ 28

4.2.3. Inflow 예제 ...................................................................................................... 28

Appendix A. WebTJCA ra.xml 설정 ......................................................................................... 31

A.1. 필드 정보 ................................................................................................................... 31

A.1.1. <resourceadapter-class> ................................................................................. 31

Tmax iii

Page 4: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션
Page 5: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

그림 목차

[그림 1.1] JCA 구조 ..................................................................................................................... 2

[그림 1.2] Inbound Communication Model .................................................................................... 3

[그림 3.1] Inbound Communication Model ................................................................................... 11

[그림 3.2] Inbound 구조 ............................................................................................................. 12

Tmax v

Page 6: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션
Page 7: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

안내서에 대하여

안내서의 대상

본 안내서는 Tmax®(이하 Tmax)의 WebTJCA를 사용하여 개발하는 개발자를 대상으로 기술한다.

안내서의 전제 조건

본 안내서는 Tmax 시스템에 대한 전반적인 이해와 Tmax 시스템이 제공하는 각종 기능 및 특성에 대한 습

득을 위한 기본서이다.

본 안내서를 원활하게 이해하기 위해서는 다음과 같은 사항을 미리 알고 있어야 한다.

● 미들웨어(Middleware) 및 UNIX 시스템에 대한 이해

● Tmax의 기본 개념 이해

● Java , C 프로그래밍의 이해

● JEUS, WebLogic에 대한 이해

안내서의 제한 조건

본 안내서는 제품 특성상 언급되는 JEUS나 WebLogic에 대해서 자세히 다루지 않는다. 따라서 해당 내용

은 JEUS나 WebLogic 안내서를 참고한다. 실무에서의 구체적인 사용방법이나 관리 및 운용에 관한 사항

은 각 제품의 안내서를 참고한다.

참고

Tmax 시스템 개발에 대한 기본적인 내용은 "Tmax Administration Guide"나 "Tmax Application Devel

oment Guide"를 참고한다. Tmax에서 제공하는 명령어와 C API에 대한 설명은 “Tmax Reference

Guide”를 참고한다.

안내서에 대하여 vii

Page 8: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

안내서 구성

Tmax WebTJCA User Guide는 총 4개의 장과 Appendix-A 로 구성되어 있다.

각 장의 주요 내용은 다음과 같다.

● 제1장: 개요

WebTJCA에 대해서 소개한다.

● 제2장: WebTJCA API

Outbound 통신을 개발하기 위해서 CCI를 구현한 WebTJCA API를 설명한다.

● 제3장: WebTJCA Inbound 통신

Tmax와 Resource-Adapter의 환경설정 파일을 설명한다.

● 제4장: 예제

JEUS6와 WebLogic에서 WebTJCA를 사용하는 방법에 대해 예제를 통해 설명한다.

● Appendix-A: WebTJCA ra.xml 설정

WebTJCA ra.xml 설정을 위한 세부사항을 설명한다.

viii Tmax WebTJCA User Guide

Page 9: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

안내서 규약

의미표기

프로그램 소스 코드의 파일명, 디렉터리<AaBbCc123>

Ctrl과 C를 동시에 누름<Ctrl>+C

GUI의 버튼 또는 메뉴 이름[Button]

강조진하게

다른 관련 안내서 또는 안내서 내의 다른 장 및 절 언급" "(따옴표)

화면 UI에서 입력 항목에 대한 설명'입력항목'

메일계정, 웹 사이트하이퍼링크

메뉴의 진행 순서>

하위 디렉터리 또는 파일 있음+----

하위 디렉터리 또는 파일 없음|----

참고 또는 주의사항참고

그림 이름[그림 1.1]

표 이름[표 1.1]

명령어, 명령어 수행 후 화면에 출력된 결과물, 예제코드AaBbCc123

안내서에 대하여 ix

Page 10: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

시스템 사용 환경

요구 사항

IBM AIX 5.xPlatform

HP-UX 11.xx

Solaris 7~9 (SunOS 5.7~5.9)

최소 120MB 하드디스크 공간Hardware

256MB 이상 메모리 공간

1GB 이상 하드디스크와 512MB 이상 메모리 공간 권장

Oracle 9i 또는 10gDatabase

x Tmax WebTJCA User Guide

Page 11: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

관련 안내서

설명안내서

Tmax를 이용하기 위한 환경설정을 하는 방법과 시스템 운영방식을

기술한 안내서이다.

Tmax

Administration Guide

Tmax 애플리케이션 프로그램 개발에 사용하는 API의 개념 및 사용

법과 예제를 기술한 안내서이다.

Tmax

Application Development Guide

참고 문헌

안내서제품

JCA 안내서JEUS

Programming WebLogic Resource AdaptersWebLogic

Deploying Applications to WebLogic Server

안내서에 대하여 xi

Page 12: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

연락처

Korea

TmaxSoft Co., Ltd

263 BundangSquare (AK Plaza) 12th floor, Seohyeon-dong, Bundang-gu,

Seongnam-si, Gyeonggi-do, 463-824

South Korea

Tel: +82-31-8018-1000

Fax: +82-31-8018-1115

Email: [email protected]

Web (Korean): http://www.tmax.co.kr

기술지원: http://technet.tmaxsoft.com

USA

TmaxSoft, Inc.

560 Sylvan Avenue Englewood Cliffs, NJ 07632

U.S.A

Tel: 1-201-567-8266

Fax: 1-201-567-7339

Email: [email protected]

Web (English): http://www.tmaxsoft.com

Japan

TmaxSoft Japan Co., Ltd.

5F Sanko Bldg, 3-12-16 Mita, Minato-Ku, Tokyo, 108-0073

Japan

Tel: +81-3-5765-2550

Fax: +81-3-5765-2567

Email: [email protected]

Web (Japanese): http://www.tmaxsoft.co.jp

xii Tmax WebTJCA User Guide

Page 13: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

China

TmaxSoft China Co., Ltd.

Beijing Silver Tower, RM 1508, 2# North Rd Dong San Huan,

Chaoyang District, Beijing, China, 100027

China

Tel: +86-10-6410-6145~8

Fax: +86-10-6410-6144

Email: [email protected]

Web (Chinese): http://www.tmaxsoft.com.cn

ASEAN Office

TmaxSoft Pte. Ltd.

30 Cecil Street, Level 15 Unit 05 Prudential Tower, Singapore 049712

Singapore

Tel: +65-6232-2889

Fax: +65-6232-2919

Email: [email protected]

Web (English): http://asean.tmaxsoft.com

안내서에 대하여 xiii

Page 14: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션
Page 15: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

제1장 소개

본 장에서는 JCA 스펙과 WebTJCA에 대해서 소개한다.

1.1. 개요WebTJCA는 J2EE의 JCA(J2EE Connector Architecture) 스펙에서 리소스 어댑터 역할을 하는 라이브러

리 패키지이다. 사용자는 이 라이브러리를 통해서 Tmax와 통신할 수 있다.

기존 WebT는 JEUS를 통하거나 단일 애플리케이션으로만 동작하도록 제공하여 개발자는 특정한 설정과

API를 이용하여 Tmax와 통신하였다.

WebTJCA는 JCA 스펙을 구현하여 사용자가 스펙만 알고 있으면 WebT를 알지 못해도 Tmax와의 서비스

요청이 가능하다.

1.2. JCAJCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application

Server(WAS, 이하 웹 애플리케이션 서버) 환경 서비스(Enterprise Information System, 이하 EIS)와의 연

동을 위해 정의된 표준 프레임워크(Framework)이다.

JCA 이전까지는 EIS와 연동을 하기 위해서 각 벤더의 EIS 및 웹 애플리케이션 서버마다 별도의 인터페이

스를 구현하는 커스텀 드라이버를 구현하여 사용했다. 따라서 특정 제품간에 연동 자체가 불가능해지는

것을 제외하더라도 각각의 드라이버에 따라 다양한 인터페이스와 개발 방식을 따라야 하는 문제가 있었

다.

N * M 문제라고 불려지는 이 상황은 기본적으로 코드 레벨을 수정하지 않으면 연동이 불가능하고, 이로

인하여 J2EE 환경의 이식성과 확장성에 심각한 제약을 가져온다. 이 문제를 해결하기 위하여 JCA 스펙에

서 리소스 어댑터와 웹 애플리케이션 서버 사이의 인터페이스와 상호작용을 확정하였다. 그리고 표준에

맞는 웹 애플리케이션 서버와 리소스 어댑터라면 코드 레벨을 수정하지 않아도 상호 호환되어 동작하는

것을 목표로 발전되었다. 각 EIS 벤더의 커스텀 드라이버를 표준화된 구조(Architecture)로 대체함으로써

이전에 발생하였던 N * M 연동 문제를 N + M 으로 줄일 수 있게 되었다.

참고

Connector 1.5 스펙은 http://java.sun.com/j2ee/connector/download.html에서 받을 수 있다.

제1장 소개 1

Page 16: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

1.2.1. JCA 구조

다음은 JCA 구조에 대한 그림이다.

[그림 1.1] JCA 구조

Outbound 통신

웹 애플리케이션 서버에서 EIS로 서비스 요청을 하는 것을 Outbound 통신이라고 한다.

JCA 스펙은 애플리케이션 개발자에게 CCI(Common Client Interface) 스펙을 제공하여 개발자는 EIS와

연계된 애플리케이션을 개발할 수 있다.

2 Tmax WebTJCA User Guide

Page 17: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

리소스 어댑터는 cci, spi 스펙을 구현하여 제공해야 한다.

Inbound 통신

EIS에서 웹 애플리케이션 서버로 서비스 요청을 하는 것을 Inbound 통신이라고 한다.

JCA 1.5 스펙에서는 웹 애플리케이션 서버에서 EIS로 요청하는 서비스뿐만 아니라 EIS에서 웹 애플리케

이션 서버로도 서비스를 요청할 수 있는 스펙을 제공한다.

다음은 Inbound 통신 구조이다.

[그림 1.2] Inbound Communication Model

1.2.2. WebTJCA

WebTJCA는 JCA 스펙을 구현한 라이브러리로 webt5.9.7.0.jar로 배포한다.

이 라이브러리에는 JCA 스펙 구현 부분 뿐만 아니라 기존 WebT에서 사용하던 라이브러리도 함께 포함되

어 있어 기존 WebT도 사용 가능하다.

WebTJCA는 Outbound, Inbound 통신을 모두 지원한다.

Outbound 통신

Deployer는 webt5.9.7.0.jar를 사용하고 ra.xml과 웹 애플리케이션 서버 업체의 고유한 설정을 이용하여

리소스 어댑터를 생성하여 웹 애플리케이션 서버에 디플로이(Deploy)해야 한다.

애플리케이션 개발자는 CCI를 이용하여 서비스 요청을 하는 애플리케이션을 작성할 수 있다.

제1장 소개 3

Page 18: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Inbound 통신

Deployer는 webt5.9.7.0.jar를 사용하고 ra.xml과 웹 애플리케이션 서버 업체의 고유한 설정을 이용하여

리소스 어댑터 를 생성하여 웹 애플리케이션 서버에 디플로이해야 한다.

애플리케이션 개발자는 Message Driven Bean을 작성하여 메시지 수신 부분에서 실제 요청할 EJB를 요

청한다.

4 Tmax WebTJCA User Guide

Page 19: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

제2장 WebTJCA API

Outbound 통신을 개발하기 위해서 CCI를 구현한 WebTJCA API를 설명한다.

2.1. CCICCI는 리소스 어댑터를 사용하기 위한 표준 클라이언트 API를 정의한 스펙이다. 사용자는 CCI를 이용하

여 다양한 리소스 어댑터에 대해서도 동일한 애플리케이션 코드를 생성할 수 있다.

JCA 스펙에서 CCI는 필수 구현 조건은 아니다. 사용자는 CCI를 이용해서 서비스를 호출해도 무방하지만

업체마다 고유의 스펙으로 애플리케이션을 작성해도 된다.

스펙에서 구현해야 할 인터페이스는 다음과 같다.

● 애플리케이션에서 생성할 Connection 관련 인터페이스

javax.resource.cci.connectionFactory

javax.resource.cci.Connection

javax.resource.cci.ConnectionSpec

javax.resource.cci.LocalTransaction

● EIS와 상호 동작을 위한 인터페이스

javax.resource.cci.Interaction

javax.resource.cci.InteractionSpec

● Inflow 구조에서 Message Driven Bean에서 구현할 메시지 리스너(Message listener) 인터페이스

javax.resource.cci.MessageListener

● EIS와 주고 받는 데이터를 표현하기 위한 인터페이스

javax.resource.cci.Record

javax.resource.cci.MappedRecord

javax.resource.cci.IndexedRecord

javax.resource.cci.RecordFactory

javax.resource.cci.Streamable

제2장 WebTJCA API 5

Page 20: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

javax.resource.cci.ResultSet

java.sql.ResultSetMetaData

● 리소스 어댑터 구현과 EIS Connection에 관한 기본 정보를 제공하는 메타데이터 관련 인터페이스

javax.resource.cci.ConnectionMetaData

javax.resource.cci.ResourceAdapterMetaData

javax.resource.cci.ResultSetInfo

● 추가 인터페이스

javax.resource.ResourceException

javax.resource.cci.ResourceWarning

WebTJCA에서는 위의 CCI를 이용해서 애플리케이션을 구현할 수 있다.

참고

인터페이스의 메소드는 JDK JavaDoc을 참고한다.

2.1.1. Connection 관련 API

리소스 어댑터를 디플로이한 이후에는 사용자는 JNDI를 이용하여 ConnectionFactory를 참고할 수 있으

며 ConnectionFactory를 이용하여 Connection을 생성할 수 있다.

다음은 WebTJCA의 Connection 사용 예제이다.

ConnectionFactory connFactory = (ConnectionFactory)ctx.lookup("TmaxConnector");

Connection conn = connFactory.getConnection();

getConnection()을 호출할 때 새로운 Connection을 생성하거나 이미 생성한 Connection을 반환한다.

2.1.2. 서비스 요청을 위한 API

서비스 요청을 하기 위한 Interaction 인터페이스는 Connection 인터페이스에서 생성한다.

어떤 서비스를 호출할 지는 InteractionSpec을 구현한 클래스를 이용한다. InteractionSpec을 생성하는 인

터페이스는 스펙에 없기 때문에 WebTJCA에서는 TmaxInteractionSpecImpl을 이용하여 생성한다.

WebTJCA는 동기 호출(tpcall)만 제공한다.

다음은 서비스 요청에 관한 예제이다.

6 Tmax WebTJCA User Guide

Page 21: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Interaction action = conn.createInteraction();

TmaxInteractionSpecImpl aspec = new TmaxInteractionSpecImpl();

aspec.setSvcName("TOUPPER");

aspec.setAction(InteractionSpec.SYNC_SEND_RECEIVE);

RecordFactory recordFactory = connFactory.getRecordFactory();

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

sndBuf.put("$String","abc");

MappedRecord rcvBuf = recordFactory.createMappedRecord(null);

if( action.execute(aspec, sndBuf, rcvBuf) )

{

String result = (String)rcvBuf.get("$String");

System.out.println(result);

}

2.1.3. 데이터 표현 API

WebTJCA는 Tmax에서 제공하는 데이터 중 String, CArray, FDL 타입의 데이터를 제공한다.

ConnectionFactory로부터 getRecordFactory() 메소드를 이용하여 RecodFactory를 얻어와서 createMappe

dRecord로 데이터 객체를 생성하여 사용하는 데이터를 입력한다.

다음은 RecordFactory 생성 예제이다.

RecordFactory recordFactory = connFactory.getRecordFactory();

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

String 사용

MappedRecord의 put 메소드를 이용하여 설정한다.

put의 키에 "$String"을 입력할 경우 value는 String으로 인식하여 Tmax에 String형의 메시지를 전달한다.

다음은 String 생성 예제이다.

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

sndBuf.put("$String","abc");

get 함수를 이용할 경우에도 키에 "$String"을 입력하면 저장된 String 객체를 반환한다.

CArray 사용

MappedRecord의 put 메소드를 이용하여 설정한다.

제2장 WebTJCA API 7

Page 22: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

put의 키에 "$CArray"를 입력할 경우 value는 byte[ ]로 인식하여 Tmax에 CArray형의 메시지를 전달한다.

다음은 CArray 생성 예제이다.

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

sndBuf.put("$CArray",new byte[]{0,1,2});

get 함수를 이용할 경우에도 키에 "$String"을 입력하면 저장된 byte[ ]를 반환한다.

FDL 사용

MappedRecord의 put 메소드를 이용하여 설정한다.

put의 키에 FDL에서 설정한 키를 입력할 경우 value는 해당하는 필드 타입으로 인식하여 Tmax에 FDL 타

입의 메시지를 전달한다.

다음은 FDL 생성에 관한 예제이다.

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

sndBuf.put("ID","tmax001");

sndBuf.put("PASS","abcd");

sndBuf.put("AGE",16);

PUT 메소드를 이용하여 필드키와 데이터를 쌍으로 저장한다.

저장한 데이터를 참고하기 위해서는 get 메소드를 이용한다. get 메소드의 반환 객체는 해당 필드의 값을

저장하고 있는 IndexedRecord를 구현한 com.tmax.connector.cci.TmaxFdlRecord를 반환한다.

사용자는 IndexedRecord의 get(int index) 메소드를 이용하여 저장한 필드값을 참고한다.

다음은 FDL 사용 예제이다.

IndexedRecord field = sndBuf.get("ID");

String id = field.get(0);

2.2. 트랜잭션

2.2.1. XA 트랜잭션

WebTJCA는 XA 트랜잭션을 지원한다.

사용자는 ra.xml에서 <support-xa> 항목을 true로 설정해야 하며 <transaction-support> 항목도 XA 트랜잭

션으로 설정해야 한다.

XA 트랜잭션은 설정만 하면 getConnection을 실행할 때에 자동으로 트랜잭션에 참여하며 애플리케이션

에서 Commit이나 Rollback을 하는 경우 2PC 작업으로 Tmax에 Prepare, Commit 요청을 한다.

8 Tmax WebTJCA User Guide

Page 23: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

복구 처리를 위해서는 반드시 <outbound-resourceadapter><connection-definition>에 xid mapping 파일

관련 정보를 입력해야 한다.

만약 이 파일이 존재하지 않는다면 웹 애플리케이션 서버가 재기동할 때는 xid mapping 정보가 존재하지

않아 복구 작업을 수행 할 수 없다.

XA 트랜잭션 작업을 위해서는 Tmax의 jeusgw를 설정하여 해당 포트에 접속해야 한다.

2.2.2. 로컬 트랜잭션

로컬 트랜잭션 처리를 위해서 사용자는 Connection에서 getLocalTransaction 메소드를 이용해야 한다. 설

정에 따라서 자동으로 웹 애플리케이션 서버에서 처리를 해준다.

다음은 로컬 트랜잭션 사용 예제이다.

ConnectionFactory connFactory = (ConnectionFactory)ctx.lookup("TmaxConnector");

Connection conn = connFactory.getConnection();

conn.getLocalTransaction().begin();

....

conn.getLocalTransaction().commit();

로컬 트랜잭션을 위해서는 Tmax의 기본 포트에 접속해야 한다. JAVAGW에 접속해서 로컬 트랜잭션으로

처리할 수 없다.

2.3. Logging리소스 어댑터를 사용하면서 발생하는 로그는 ra.xml을 사용할 때 설정한 로그 파일과 로그 레벨의 적용

을 받아서 생성한다.

<outbound-resourceadapter><connection-definition>에 로그 관련 설정에 Connection을 사용하는 로그를

출력한다.

참고

자세한 사항은 “4.1.1. 리소스 어댑터 구성”의 "ra.xml 설정"을 참고한다.

제2장 WebTJCA API 9

Page 24: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

2.4. 비동기 요청, 대화형 통신 지원현재 정의한 CCI 스펙만으로는 Tmax에서 지원하는 비동기 요청과 대화형 통신을 지원할 수 없기 때문에

다음과 같이 기존 WebT API를 이용하여 구현해야 한다.

Connection으로부터 WebtConnection을 참고하여 WebtRemoteService나 WebtDialogueService를 이용

하여 비동기, 대화형 통신을 할 수 있다.

다음은 비동기 요청의 예제이다.

ConnectionFactory connFactory = (ConnectionFactory)ctx.lookup("TmaxConnector");

Connection conn = connFactory.getConnection();

WebtConnection webtConn = ((TmaxConnectionImpl)conn).getInConnection();

WebtRemoteService svc = new WebtRemoteService("TOUPPER", webtConn);

int cd = svc.tpacall(sendBuf);

rcvBuf = svc.tpgetrply(cd);

conn.close();

다음은 대화형 통신의 예제이다.

ConnectionFactory connFactory = (ConnectionFactory)ctx.lookup("TmaxConnector");

Connection conn = connFactory.getConnection();

WebtConnection webtConn = ((TmaxConnectionImpl)conn).getInConnection();

WebtDialogueService svc = new WebtDialogueService("TOUPPER_CONV", webtConn);

svc.tpconnect(sndbuf..

....

conn.close();

10 Tmax WebTJCA User Guide

Page 25: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

제3장 WebTJCA Inbound 통신

본 장에서는 WebTJCA Inbound 통신에 대해 설명한다.

3.1. 개요Inbound 통신의 처리 과정은 다음과 같다.

[그림 3.1] Inbound Communication Model

Tmax 리소스 어댑터는 Tmax로부터 웹 애플리케이션 서버에 오는 요청에 대해 어떤 서비스를 호출해야

하는지 알 수 없다. 따라서 중간에 Message Driven Bean을 추가하여 리소스 어댑터가 Message Driven

Bean으로 메시지를 전달하고 Message Driven Bean에서는 사용자가 업무에 맞게 해당하는 서비스를 호

출할 수 있도록 작성해야 한다.

리소스 어댑터에서 어떤 Message Driven Bean으로 메시지를 전달해야 하는지는 설정에 의해서 정의한

다.

● ra.xml

ra.xml에 다음과 같이 설정하고 <activationspec-class>에 com.tmax.connector.spi.TmaxActivationSpec

라고 작성하고 <config-property-name>에는 serviceName을 작성하게 설정한다.

<inbound-resourceadapter>

<messageadapter>

<messagelistener>

<messagelistener-type>javax.resource.cci.MessageListener</messagelistener-type>

<activationspec>

<activationspec-class>com.tmax.connector.spi.TmaxActivationSpec

</activationspec-class>

<required-config-property>

<config-property-name>serviceName</config-property-name>

</required-config-property>

제3장 WebTJCA Inbound 통신 11

Page 26: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

</activationspec>

</messagelistener>

</messageadapter>

</inbound-resourceadapter>

</resourceadapter>

</connector>

● Message Driven Bean의 ejb-jar.xml

사용자가 개발한 Message Driven Bean에서 ejb-jar.xml에 다음 예제와 같이 <message-destination-link>

와 <activation-config>를 입력하고 디플로이를 할 경우 해당하는 리소스 어댑터에 <activation-config-

property>를 통지한다.

통지를 받은 Tmax 리소스 어댑터는 serviceName에 입력한 service가 Tmax로부터 요청할 경우 등록된

Message Driven Bean으로 메시지를 전달한다.

<message-destination-link>TmaxRA</message-destination-link>

<activation-config>

<activation-config-property>

<activation-config-property-name>serviceName</activation-config-property-name>

<activation-config-property-value>ECHOSTRING,CREATE_ACCOUNT_B,TRANSFER_MONEY_B

</activation-config-property-value>

</activation-config-property>

</activation-config>

3.2. Worker 스레드Inbound 통신은 설정된 포트를 accept하는 스레드가 기본적으로 하나 생성되며, accept하는 소켓을 read

하기 위한 스레드가 소켓당 하나씩 더 생성된다. 이 스레드의 생성 숫자는 애플리케이션 서버의 Worker

Manager에 Max값으로 결정되며 설정은 업체마다 해당하는 설정에 따른다.

Inbound 구조를 설명한 그림이다.

[그림 3.2] Inbound 구조

12 Tmax WebTJCA User Guide

Page 27: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Tmax 클라이언트로부터 들어온 요청에 대해 RA의 Acceptor 스레드에서 각각의 Worker 스레드를 생성한

다. 생성된 각각의 Worker 스레드에서 해당 요청을 MDB로 전송하면 해당 요청에 대하여 MDB에서 구분

하여 처리한다.

Tmax의 JAVAGW와 연결해야 한다.

3.3. Message Driven BeanMessage Driven Bean을 작성할 때 사용자는 javax.resource.cci.MessageListener를 구현해야 한다.

public Record onMessage(Record in) throws ResourceException 메소드가 리소스 어댑터에서 전달할 때

호출되는 메소드이다.

Record는 MappedRecord로 전달한다.

사용자는 다음과 같이 특별 키를 사용하여 서비스 이름이나 특정 값을 설정하거나 참고할 수 있다.

다음은 Message Driven Bean을 설정하는 예제이다.

public Record onMessage(Record in) throws ResourceException {

String svcName = (String)((MappedRecord)in).get("$ServiceName");

if( svcName.equalsIgnoreCase("echostring") ) {

return in;

}

else if( svcName.equalsIgnoreCase("create_account_b")) {

}

else if( svcName.equalsIgnoreCase("transfer_money_b")) {

}

return in;

}

OnMessage의 반환값이 Tmax에서 요청자에게 전달되는 응답 메시지이다.

사용자는 성공, 실패 여부를 알리기 위해서 다음 예제와 같이 반환값에 $ReturnCode, $UserCode를 입력

해야 한다. 성공했을 때는 $ReturnCode를 0으로 설정하고, 실패했을 때는 $ReturnCode를 -1로 설정하고

$UserCode에 Tmax에서 참고할 수 있는 usercode를 입력한다.

// 성공 시

MappedRecord out = (MappedRecord) in.clone();

out.put("$ReturnCode", new Integer(0));

// 실패 시

out.put("$ReturnCode", new Integer(-1));

out.put("$UserCode", new Integer(usrcode));

제3장 WebTJCA Inbound 통신 13

Page 28: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

3.4. Loggingra.xml의 <resourceadapter>에서 로그 관련 설정을 할 때 Inbound 작업에 대한 로그를 출력한다.

Inbound 로깅을 설정할 때는 ra.xml에 다음과 같은 설정을 추가한다.

<resourceadapter>

<config-property>

<config-property-name>name</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>tmaxin1</config-property-value>

</config-property>

</resourceadapter>

14 Tmax WebTJCA User Guide

Page 29: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

제4장 예제

본 장에서는 JEUS6와 WebLogic에서 WebTJCA를 사용하는 방법에 대해 설명한다.

4.1. JEUS6 에서 WebTJCA 사용JEUS6에서 WebTJCA를 사용하는 방법에 대해 설명한다.

4.1.1. 리소스 어댑터 구성

JCA를 이용하기 위해서 사용자는 우선 리소스 어댑터를 구성해야 한다. 리소스 어댑터에는 웹 애플리케

이션 서버 제공 업체의 고유의 설정과 JCA에서 정의한 설정을 정의해야 한다.

JCA에서 정의한 리소스 어댑터에 포함할 목록은 다음과 같다.

Relative location within RAR fileRequirementsContents of RAR file

META-INF/ra.xmlRequiredDeployment Descriptor

Arbitary (that is, could be at root level or sub-

level)

Optionalhowto.html, image files, etc.

ArbitaryOptionalJAR files

ArbitaryOptionalPlatform-specific native libraries

리소스 어댑터는 Java Archive(JAR) 형식으로 RAR로 패키징되어야 한다.

Deployer는 ra.xml과 jeus-connector-dd.xml을 기술한다.

ra.xml 설정

Inflow와 Outbound를 함께 설정한다.

다음은 ra.xml을 설정하는 예제이다.

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

<connector id="Connector_ID" version="1.5" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd">

<description>Tmax Sample Resource Adapter</description>

<display-name>TmaxRA</display-name>

제4장 예제 15

Page 30: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

<vendor-name>TmaxSoft</vendor-name>

<eis-type>TP Monitor</eis-type>

<resourceadapter-version>1.0.0.0</resourceadapter-version>

<resourceadapter>

<resourceadapter-class>com.tmax.connector.spi.TmaxResourceAdapterImpl

</resourceadapter-class>

<config-property>

<config-property-name>port</config-property-name>

<config-property-type>java.lang.Integer </config-property-type>

<config-property-value>6556</config-property-value>

</config-property>

<config-property>

<config-property-name>fdlfile</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>C:\TmaxSoft\JEUS6.0\lib\application\tmax.fdl

</config-property-value>

</config-property>

<outbound-resourceadapter>

<connection-definition>

<managedconnectionfactory-class>

com.tmax.connector.spi.TmaxManagedConnectionFactoryImpl

</managedconnectionfactory-class>

<config-property>

<config-property-name>host</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>192.168.1.43</config-property-value>

</config-property>

<config-property>

<config-property-name>host_port</config-property-name>

<config-property-type>java.lang.Integer</config-property-type>

<config-property-value>11120</config-property-value>

</config-property>

<config-property>

<config-property-name>backup</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>192.168.1.43</config-property-value>

</config-property>

<config-property>

<config-property-name>backup_port</config-property-name>

<config-property-type>java.lang.Integer</config-property-type>

<config-property-value>15300</config-property-value>

</config-property>

<config-property>

<config-property-name>support_xa</config-property-name>

<config-property-type>java.lang.Boolean</config-property-type>

<config-property-value>true</config-property-value>

16 Tmax WebTJCA User Guide

Page 31: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

</config-property>

<config-property>

<config-property-name>headerType</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>extendedV4</config-property-value>

</config-property>

<config-property>

<config-property-name>connectTimeout</config-property-name>

<config-property-type>java.lang.Integer</config-property-type>

<config-property-value>15000</config-property-value>

</config-property>

<config-property>

<config-property-name>fdlFile</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>C:\TmaxSoft\JEUS6.0\lib\application\tmax.fdl

</config-property-value>

</config-property>

<config-property>

<config-property-name>xidMapperPath</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>C:\TmaxSoft\JEUS6.0\lib\application\</config-property-value>

</config-property>

<config-property>

<config-property-name>xidMapperFile</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>webtxidmapper</config-property-value>

</config-property>

<config-property>

<config-property-name>logLevel</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>DEBUG</config-property-value>

</config-property>

<config-property>

<config-property-name>logDir</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>d:\\</config-property-value>

</config-property>

<config-property>

<config-property-name>logFile</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>webt.log</config-property-value>

</config-property>

<config-property>

<config-property-name>logValidDays</config-property-name>

<config-property-type>java.lang.Integer</config-property-type>

<config-property-value>1</config-property-value>

</config-property>

제4장 예제 17

Page 32: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

<config-property>

<config-property-name>connectionName</config-property-name>

<config-property-type>java.lang.String</config-property-type>

<config-property-value>tmax1</config-property-value>

</config-property>

<connectionfactory-interface>javax.resource.cci.ConnectionFactory

</connectionfactory-interface>

<connectionfactory-impl-class>com.tmax.connector.cci.TmaxConnectionFactoryImpl

</connectionfactory-impl-class>

<connection-interface>javax.resource.cci.Connection</connection-interface>

<connection-impl-class>com.tmax.connector.cci.TmaxConnectionImpl

</connection-impl-class>

</connection-definition>

<transaction-support>XATransaction</transaction-support>

<reauthentication-support>false</reauthentication-support>

</outbound-resourceadapter>

<inbound-resourceadapter>

<messageadapter>

<messagelistener>

<messagelistener-type>javax.resource.cci.MessageListener</messagelistener-type>

<activationspec>

<activationspec-class>com.tmax.connector.spi.TmaxActivationSpec

</activationspec-class>

<required-config-property>

<config-property-name>serviceName</config-property-name>

</required-config-property>

</activationspec>

</messagelistener>

</messageadapter>

</inbound-resourceadapter>

</resourceadapter>

</connector>

참고

ra.xml 설정에 관한 자세한 내용은 “Appendix A. WebTJCA ra.xml 설정”을 참고한다.

jeus-connector-dd.xml 설정

다음은 jeus-connector-dd.xml을 설정하는 예제이다.

해당 예제에서 export-name은 Outbound Connection을 참고할 수 있는 JNDI 이름이다.

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

<jeus-connector-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus">

<module-name>TmaxRA</module-name>

18 Tmax WebTJCA User Guide

Page 33: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

<use-workmanager>true</use-workmanager>

<connection-pool>

<export-name>TmaxConnector</export-name>

<transaction-support>XATransactionOnly</transaction-support>

<pool-management>

<min>5</min>

<max>20</max>

</pool-management>

</connection-pool>

</jeus-connector-dd>

참고

jeus-connector-dd.xml 설정에 관한 자세한 내용은 JEUS 안내서 중 "JEUS JCA 안내서"를 참고한다.

디플로이

● 폴더 구성

webt5.9.7.0.jar

META-INF/ra.xml

META-INF/jeus-connector-dd.xml

● RAR 파일 생성

jar로 TmaxRA.rar 생성

● JCA로 JEUS에 디플로이

JEUS Web 관리자에서 "애플리케이션 모듈 디플로이"를 이용하여 디플로이

참고

디플로이 방법에 대한 자세한 내용은 JEUS 안내서 중 "JEUS JCA 안내서"를 참고한다.

제4장 예제 19

Page 34: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

4.1.2. Outbound 예제

다음은 Tmax의 TOUPPER 서비스를 호출하는 jsp 예제이다.

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@page import="javax.resource.cci.Connection"%>

<%@page import="javax.naming.InitialContext"%>

<%@page import="javax.resource.cci.ConnectionFactory"%>

<%@page import="javax.resource.cci.RecordFactory"%>

<%@page import="javax.resource.cci.MappedRecord"%>

<%@page import="javax.resource.cci.Interaction"%>

<%@page import="javax.resource.cci.InteractionSpec"%>

<%@page import="com.tmax.connector.cci.TmaxInteractionSpecImpl"%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<title>Insert title here</title>

</head>

<body>

<%

InitialContext ctx = new InitialContext();

ConnectionFactory connFactory = (ConnectionFactory)ctx.lookup("TmaxConnector");

Connection conn = connFactory.getConnection();

Interaction action = conn.createInteraction();

TmaxInteractionSpecImpl aspec = new TmaxInteractionSpecImpl();

aspec.setSvcName("TOUPPER");

aspec.setAction(InteractionSpec.SYNC_SEND_RECEIVE);

RecordFactory recordFactory = connFactory.getRecordFactory();

MappedRecord sndBuf = recordFactory.createMappedRecord(null);

sndBuf.put("$String","abc");

MappedRecord rcvBuf = recordFactory.createMappedRecord(null);

if( action.execute(aspec, sndBuf, rcvBuf) )

{

String result = (String)rcvBuf.get("$String");

}

conn.close();

System.out.println("end lookup");

%>

20 Tmax WebTJCA User Guide

Page 35: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

</body>

</html>

4.1.3. Inflow 예제

JCA의 Inflow는 JCA에서 Tmax로부터 서비스 요청이 있을 경우 등록된 Message Driven Bean으로 호출

하는 구조이다.

사용자는 Message Driven Bean을 구현하여 디플로이해서 사용해야 한다.

Message Driven Bean 작성

● TmaxListenerBean.java

다음은 WebTJCA에서 서비스 요청을 수신하여 Message Driven Bean의 OnMessage를 호출하여 서비

스 명에 따라서 다른 EJB를 호출하는 구조의 예제이다.

package com.tmax.sample.echoMBean;

import java.rmi.RemoteException;

import javax.ejb.CreateException;

import javax.ejb.EJBException;

import javax.ejb.MessageDrivenBean;

import javax.ejb.MessageDrivenContext;

import javax.naming.Context;

import javax.naming.InitialContext;

import javax.naming.NamingException;

import javax.resource.ResourceException;

import javax.resource.cci.MappedRecord;

import javax.resource.cci.MessageListener;

import javax.resource.cci.Record;

import javax.rmi.PortableRemoteObject;

import com.tmax.sample.TmaxBLSample;

import com.tmax.sample.TmaxBLSampleHome;

public class TmaxListenerBean implements MessageListener, MessageDrivenBean {

/**

*

*/

private static final long serialVersionUID = 7971664840039920708L;

제4장 예제 21

Page 36: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

public TmaxListenerBean()

{

}

public void ejbCreate() throws EJBException {

}

public void ejbRemove() throws EJBException {

// TODO Auto-generated method stub

}

public void setMessageDrivenContext(MessageDrivenContext ctx)

throws EJBException {

}

public Record onMessage(Record in) throws ResourceException {

System.out.println(in);

String svcName = (String)((MappedRecord)in).get("$ServiceName");

if( svcName.equalsIgnoreCase("echostring") )

{

return in;

}

else if( svcName.equalsIgnoreCase("create_account_b"))

{

System.out.println(((MappedRecord)in).get("$Message"));

Context initial;

try {

System.setProperty("java.naming.factory.initial",

"jeus.jndi.JNSContextFactory");

System.setProperty("java.naming.factory.url.pkgs", "jeus.jndi.jns.url");

System.setProperty("java.naming.provider.url", "192.168.11.253");

initial = new InitialContext();

Object object = initial.lookup("TmaxBLSample"); // return EJB Home

22 Tmax WebTJCA User Guide

Page 37: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

if( object == null )

{

return createFailRecord(in, -6);

}

TmaxBLSampleHome home = (TmaxBLSampleHome)

PortableRemoteObject.narrow(object, TmaxBLSampleHome.class);

TmaxBLSample sample = home.create();

if( sample.createAccount(in) )

{

MappedRecord out = (MappedRecord) in.clone();

out.put("$ReturnCode", new Integer(0));

out.put("RESULT", "OK");

return out;

}

else

{

return createFailRecord(in, -1);

}

} catch (NamingException e) {

e.printStackTrace();

return createFailRecord(in, -2);

} catch (RemoteException e) {

e.printStackTrace();

return createFailRecord(in, -3);

} catch (CreateException e) {

e.printStackTrace();

return createFailRecord(in, -4);

} catch (CloneNotSupportedException e) {

e.printStackTrace();

return createFailRecord(in, -5);

}

}

else if( svcName.equalsIgnoreCase("transfer_money_b"))

{

System.out.println(((MappedRecord)in).get("$Message"));

Context initial;

try {

System.setProperty("java.naming.factory.initial",

"jeus.jndi.JNSContextFactory");

System.setProperty("java.naming.factory.url.pkgs", "jeus.jndi.jns.url");

System.setProperty("java.naming.provider.url", "192.168.11.253");

제4장 예제 23

Page 38: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

initial = new InitialContext();

Object object = initial.lookup("TmaxBLSample"); // return EJB Home

if( object == null )

{

return createFailRecord(in, -6);

}

TmaxBLSampleHome home = (TmaxBLSampleHome)

PortableRemoteObject.narrow(object, TmaxBLSampleHome.class);

TmaxBLSample sample = home.create();

if( sample.transferMoney(in) )

{

MappedRecord out = (MappedRecord) in.clone();

out.put("$ReturnCode", new Integer(0));

out.put("RESULT", "OK");

return out;

}

else

{

return createFailRecord(in, -1);

}

} catch (NamingException e) {

e.printStackTrace();

return createFailRecord(in, -2);

} catch (RemoteException e) {

e.printStackTrace();

return createFailRecord(in, -3);

} catch (CreateException e) {

e.printStackTrace();

return createFailRecord(in, -4);

} catch (CloneNotSupportedException e) {

e.printStackTrace();

return createFailRecord(in, -5);

}

}

return in;

}

public Record createFailRecord(Record src, int usrcode)

{

MappedRecord out = null;

try {

24 Tmax WebTJCA User Guide

Page 39: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

out = (MappedRecord) src.clone();

} catch (CloneNotSupportedException e) {

e.printStackTrace();

return null;

}

out.put("$ReturnCode", new Integer(-1));

out.put("$UserCode", new Integer(usrcode));

out.put("RESULT", "FAIL");

return out;

}

}

● ejb-jar.xml

EJB 2.0 파일을 위한 배치 지시자로서 다음과 같은 옵션 정보를 포함하고 있다.

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

<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">

<display-name>TmaxListenerBean</display-name>

<enterprise-beans>

<message-driven>

<display-name>TmaxListenerBean</display-name>

<ejb-name>TmaxListenerBean</ejb-name>

<ejb-class>com.tmax.sample.echoMBean.TmaxListenerBean</ejb-class>

<transaction-type>Container</transaction-type>

<message-destination-link>TmaxRA</message-destination-link>

<activation-config>

<activation-config-property>

<activation-config-property-name>serviceName</activation-config-property-name>

<activation-config-property-value>

ECHOSTRING,CREATE_ACCOUNT_B,TRANSFER_MONEY_B

</activation-config-property-value>

</activation-config-property>

</activation-config>

</message-driven>

</enterprise-beans>

</ejb-jar>

● jeus-ejb-dd.xml

JEUS의 EJB 2.0 파일을 위한 배치 지시자이다.

제4장 예제 25

Page 40: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

<?xml version="1.0"?>

<jeus-ejb-dd xmlns="http://www.tmaxsoft.com/xml/ns/jeus">

<beanlist>

<jeus-bean>

<ejb-name>TmaxListenerBean</ejb-name>

<mdb-resource-adapter-name>TmaxRA</mdb-resource-adapter-name>

</jeus-bean>

</beanlist>

</jeus-ejb-dd>

참고

jeus-ejb-dd.xml에 대한 자세한 내용은 JEUS 안내서 중 "JEUS EJB 안내서"의 "5.3.1.4. jeus-ejb-

dd.xml 디플로이 디스크립터 작성"을 참고한다.

4.2. WebLogic에서 WebTJCA 사용WebLogic에서 WebTJCA를 사용하는 방법에 대해 설명한다.

4.2.1. 리소스 어댑터 구성

JCA를 이용하기 위해서는 사용자는 우선 리소스 어댑터를 구성해야 한다. 리소스 어댑터에는 웹 애플리

케이션 서버 제공의 고유 설정과 JCA에서 정의한 설정을 정의해야 한다.

JCA에서 정의한 리소스 어댑터에 포함할 목록은 다음과 같다.

Relative location within RAR fileRequirementsContents of RAR file

META-INF/ra.xmlRequiredDeployment Descriptor

Arbitary (that is, could be at root level or sub-

level)

Optionalhowto.html, image files, etc.

ArbitaryOptionalJAR files

ArbitaryOptionalPlatform-specific native libraries

리소스 어댑터는 Java Archive(JAR) 형식으로 RAR로 패키징되어야 한다.

Deployer는 다음과 같이 ra.xml과 weblogic-ra.xml을 기술한다.

● ra.xml 설정

Inflow와 Outbound를 함께 설정한다.

26 Tmax WebTJCA User Guide

Page 41: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

참고

1. ra.xml 설정에 대한 자세한 내용은 “Appendix A. WebTJCA ra.xml 설정”을 참고한다.

2. ra.xml을 설정하는 방법은 “4.1.1. 리소스 어댑터 구성”의 "ra.xml 설정" 예제를 참고한다.

● weblogic-ra.xml 설정

다음은 jeus-connector-dd.xml 설정 예제이다.

해당 예제에서 jndi-name은 Outbound Connection을 참고할 수 있는 JNDI 이름이다.

<?xml version="1.0" ?>

<weblogic-connector xmlns="http://www.bea.com/ns/weblogic/90">

<jndi-name>TmaxRA</jndi-name>

<enable-access-outside-app>true</enable-access-outside-app>

<outbound-resource-adapter>

<connection-definition-group>

<connection-factory-interface>javax.resource.cci.ConnectionFactory

</connection-factory-interface>

<connection-instance>

<jndi-name>TmaxConnector</jndi-name>

<connection-properties>

<pool-params>

<initial-capacity>2</initial-capacity>

<max-capacity>10</max-capacity>

<capacity-increment>1</capacity-increment>

<shrinking-enabled>true</shrinking-enabled>

<shrink-frequency-seconds>60</shrink-frequency-seconds>

</pool-params>

</connection-properties>

</connection-instance>

</connection-definition-group>

</outbound-resource-adapter>

</weblogic-connector>

참고

weblogic-ra.xml 설정에 대한 자세한 내용은 BEA WebLogic Server 안내서 중 "Programming WebLogic

Resource Adapters"를 참고한다.

● 디플로이

– 폴더 구성

제4장 예제 27

Page 42: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

webt5.9.7.0.jar

META-INF/ra.xml

META-INF/weblogic-ra.xml

로 폴더를 구성

– RAR 파일 생성

jar로 TmaxRA.rar 생성

– JCA로 WebLogic에 디플로이

WebLogic 관리자에서 "Application 디플로이"를 이용하여 디플로이

참고

디플로이 방법에 대한 자세한 내용은 BEA WebLogic Server 안내서 중 "Deploying Applications to

WebLogic Server"를 참고한다.

4.2.2. Outbound 예제

Tmax의 TOUPPER 서비스를 호출하는 jsp 예제 파일이다.

Outbound 예제는 “4.1.2. Outbound 예제”의 Outbound 설정 예제를 참고한다.

4.2.3. Inflow 예제

JCA의 Inflow는 JCA에서 Tmax로부터 서비스 요청이 있을 경우 등록된 Message Driven Bean으로 호출

하는 구조이다.

사용자는 Message Driven Bean을 구현하여 디플로이해서 사용해야 한다.

Message Driven Bean 작성

● TmaxListenerBean.java

WebTJCA 에서 서비스 요청을 수신하여 Message Driven Bean의 OnMessage를 호출하여 서비스명에

따라서 다른 EJB를 호출하는 구조이다.

해당 예제는 “4.1.3. Inflow 예제”의 TmaxListenerBean.java의 예제를 참고한다.

● ejb-jar.xml

28 Tmax WebTJCA User Guide

Page 43: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

EJB 2.0파일을 위한 배치 지시자로서 다음과 같은 옵션 정보를 포함하고 있다. 모든 EJB의 구조 정보를

담고 있는 <enterprise-beans>, 애플리케이션 배치를 위한 옵션 정보를 담을 <assembly-descriptor>로

구성되며, 해당 beans에 대한 트랜잭션 처리 방법이나 보안 정책 등을 설정한다. 특히 예제의 설정은

MDB로 이루어진 TmaxListenerBean을 배치하기 위한 것이다.

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

<ejb-jar id="ejb-jar_ID" version="2.1"

xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">

<display-name>TmaxListenerBean</display-name>

<enterprise-beans>

<message-driven>

<display-name>TmaxListenerBean</display-name>

<ejb-name>TmaxListenerBean</ejb-name>

<ejb-class>com.tmax.sample.echoMBean.TmaxListenerBean</ejb-class>

<messaging-type>javax.resource.cci.MessageListener</messaging-type>

<transaction-type>Container</transaction-type>

<message-destination-link>TmaxRA</message-destination-link>

<activation-config>

<activation-config-property>

<activation-config-property-name>serviceName

</activation-config-property-name>

<activation-config-property-value>

ECHOSTRING,CREATE_ACCOUNT_B,TRANSFER_MONEY_B

</activation-config-property-value>

</activation-config-property>

</activation-config>

</message-driven>

</enterprise-beans>

<assembly-descriptor>

<message-destination>

<message-destination-name>TmaxRA</message-destination-name>

</message-destination>

</assembly-descriptor>

</ejb-jar>

JEUS와 달리 WebLogic에서는 다음과 같이 설정해야 한다. WebLogic에서는 message link와 assembly

descriptor를 설정하면 안 된다.

<!-- message--link>TmaxRA</message-destination-link -->

<!-- assembly-descriptor>

<message-destination>

<message-destination-name>TmaxRA</message-destination-name>

</message-destination>

</assembly-descriptor -->

제4장 예제 29

Page 44: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

● weblogic-ejb-jar.xml

WebLogic에 의존적인 속성에 관련된 부분을 정의하는 파일로 캐싱, 클러스터링, 최적화와 관련된 내용

이 포함된다.

<?xml version="1.0" ?>

<weblogic-connector xmlns="http://www.bea.com/ns/weblogic/90">

<jndi-name>TmaxRA</jndi-name>

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

<weblogic-ejb-jar

xmlns="http://www.bea.com/ns/weblogic/90"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.bea.com/ns/weblogic/90

http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">

<weblogic-enterprise-bean>

<ejb-name>TmaxListenerBean</ejb-name>

<message-driven-descriptor>

<resource-adapter-jndi-name>TmaxRA</resource-adapter-jndi-name>

</message-driven-descriptor>

</weblogic-enterprise-bean>

</weblogic-ejb-jar>

30 Tmax WebTJCA User Guide

Page 45: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

Appendix A. WebTJCA ra.xml 설정

본 장에서는 WebTJCA ra.xml을 설정할 때 사용하는 필드 정보에 대해 설명한다.

A.1. 필드 정보http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd를 따르고 있다.

A.1.1. <resourceadapter-class>

"com.tmax.connector.spi.TmaxResourceAdapterImpl"로 설정해야 한다.

<config-property>

<connector><resourceadapter><config-property>에 들어갈 수 있는 정보는 다음과 같다.

이 항목들은 Inflow 설정을 정의한다.

설명유형이름

Inflow Adaptor의 listen할 포트를 등록한다.java.lang.Stringport

사용할 fdl-file의 경로를 지정한다.java.lang.Stringfdlfile

출력할 로그 레벨이다. none, info, debug를 사용할 수 있다.java.lang.StringlogLevel

출력할 로그 파일을 저장할 경로이다. 설정하지 않을 경우 stdio

로 출력한다.

java.lang.StringlogDir

출력할 로그 파일 이름이다. 설정하지 않을 경우 stdio로 출력한

다.

java.lang.StringlogFile

저장할 로그 파일 생성 주기이다.java.lang.IntegerlogValidDays

예) 1일 경우 일별로 로그 파일을 생성한다.

저장할 로그 파일 이름의 형식이다.java.lang.StringlogFileFormat

예) MMddyyyy

<outbound-resourceadapter><connection-definition>

● <managedconnectionfactory-class>

Appendix A. WebTJCA ra.xml 설정 31

Page 46: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

"com.tmax.connector.spi.TmaxManagedConnectionFactoryImpl"로 정의한다.

● <config-property>

<config-property>에 들어갈 수 있는 정보는 다음과 같다.

이 항목들은 Outbound 설정을 정의한다.

설명유형이름

접속할 메인 Tmax 의 IP 주소이다.java.lang.Stringhost

예) 192.168.1.43

접속할 메인 Tmax의 포트이다.java.lang.Integerhost_port

접속할 백업 Tmax의 IP 주소이다.java.lang.Stringbackup

접속할 백업 Tmax의 포트이다.java.lang.Integerbackup_port

XA의 지원 여부이다. (기본값 : false)java.lang.Booleansupport_xa

예) true or false

접속할 Tmax의 버전이다. (기본값 : 3.x 이하)java.lang.StringheaderType

예) 4.0 이상 : extendedV4

Tmax로 접속을 시도하는 시간이다. (단위: 초)java.lang.IntegerconnectTimeout

암호화 여부이다. (기본값 : false)java.lang.Booleanencryption

예) true or false

사용자 이름이다.java.lang.StringuserName

사용자 암호이다.java.lang.StringuserPasswd

도메인 이름이다.java.lang.StringdomainName

도메인 패스워드이다.java.lang.StringdomainPasswd

Tmax로 서비스를 요청할 때 기다리는 시간이다. (단위: 초)java.lang.IntegertpTimeout

총 트랜잭션을 기다리는 시간이다. (단위: 초)java.lang.IntegertxTimeout

Tmax로 서비스를 요청할 때 기다리는 시간이다. (단위: 초)java.lang.IntegertpTimeout

사용할 FDL 파일의 경로이다.java.lang.StringfdlFile

예) /data/tmax/fdl/tmax.fdl

XA를 사용할 때 웹 애플리케이션 서버의 xid와 Tmax에서 사

용할 xid의 mapping을 기록하는 xid mapping 파일을 저장할

경로이다.

java.lang.StringxidMapperPath

예) /data/was/log/webt/xid/

32 Tmax WebTJCA User Guide

Page 47: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션

설명유형이름

XA를 사용할 때 웹 애플리케이션 서버의 xid와 Tmax에서 사

용할 xid의 mapping을 기록하는 xid mapping 파일을 저장할

파일 이름이다.

java.lang.StringxidMapperFile

예) xidmapper.log

출력할 로그 레벨이다. none, info, debug를 사용할 수 있다.java.lang.StringlogLevel

출력할 로그 파일을 저장할 경로이다. 설정하지 않을 경우

stdio로 출력한다.

java.lang.StringlogDir

출력할 로그 파일의 이름이다. 설정하지 않을 경우 stdio로 출

력한다.

java.lang.StringlogFile

저장할 로그 파일의 생성 주기이다.java.lang.IntegerlogValidDays

예) 1일 경우 일별로 로그 파일을 생성한다.

저장할 로그 파일 이름의 형식이다.java.lang.StringlogFileFormat

예) MMddyyyy

Connection 이름이다.java.lang.StringconnectionName

● <connectionfactory-interface>

"javax.resource.cci.ConnectionFactory"로 정의한다.

● <connectionfactory-impl-class>

"com.tmax.connector.cci.TmaxConnectionFactoryImpl"로 정의한다.

● <connection-interface>

"javax.resource.cci.Connection"으로 정의한다.

● <connection-impl-class>

"com.tmax.connector.cci.TmaxConnectionImpl"로 정의한다.

Appendix A. WebTJCA ra.xml 설정 33

Page 48: Tmax WebTJCA User Guide - TmaxSoft · JCA는 ERP(Enterprise Resource Planning)나 레거시 정보 시스템 등을 포함하는 비 Web Application Server(WAS, 이하 웹 애플리케이션