package com.eactive.eai.adapter.jtc;

import tmax.jtc.TuxAsyncMsgListener;
import tmax.jtc.TuxAsyncService;
import tmax.jtc.io.TuxBuffer;

import javax.transaction.xa.Xid;


// 비동기요청(JEUS->TUXEDO tpacall)에 대한 비동기 응답을 받을 경우 사용 
//TmaxXid xid = new TmaxXid(1,4,0);
//TuxAsyncService service = new TuxAsyncService("TUXGW1","TUX_INSERT");
//try {
//    service.getXAResource().start(xid, 0);
//} 
//catch (XAException e) {
//    
//    e.printStackTrace();
//}
//TuxBuffer input = service.createStringBuffer();
//input.setString("abc");
//TuxAsyncMsgListener listener = new TestMsgListener(service, xid);
//service.tpacall(input, null, listener ); 

public class TestMsgListener implements TuxAsyncMsgListener {
	TuxAsyncService service;
	Xid xid;
	public TestMsgListener(TuxAsyncService service, Xid xid) {
		this.service = service;
		this.xid = xid;
	}
	
	public void handleError(Exception e) {
		// System.out.println(e);
	}
	
	public void handleEvent(TuxBuffer rcvBuffer) {
		// System.out.println(Thread.currentThread().getName()+" ] rcv " + rcvBuffer);
		try {
			// TODO : Call Internal service			
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
	