1c139be54e
인터페이스 TIMEOUT만 사용하도록 수정 (HTTP_TIMEOUT 미사용. 단, token거래(인터페이스 존재하지않음) 발급은 어댑터 프로퍼티값 사용.) 타임아웃 기준을 단일화하여 운영 혼란 방지
714 lines
28 KiB
Java
714 lines
28 KiB
Java
package com.eactive.eai.outbound;
|
|
|
|
import java.util.Properties;
|
|
|
|
import com.eactive.eai.adapter.AdapterGroupVO;
|
|
import com.eactive.eai.adapter.AdapterManager;
|
|
import com.eactive.eai.adapter.AdapterPropManager;
|
|
import com.eactive.eai.adapter.AdapterVO;
|
|
import com.eactive.eai.adapter.socket2.EAIConnectException;
|
|
import com.eactive.eai.adapter.socket2.EAINoAvailableConnectionException;
|
|
import com.eactive.eai.adapter.socket2.EAITimeoutException;
|
|
import com.eactive.eai.adapter.socket2.SocketAdapterFacade;
|
|
import com.eactive.eai.common.EAIKeys;
|
|
import com.eactive.eai.common.exception.ExceptionUtil;
|
|
import com.eactive.eai.common.header.HeaderAction;
|
|
import com.eactive.eai.common.header.HeaderActionFactory;
|
|
import com.eactive.eai.common.header.HeaderActionKeys;
|
|
import com.eactive.eai.common.logger.Keys;
|
|
import com.eactive.eai.common.message.EAIMessage;
|
|
import com.eactive.eai.common.message.EAIMessageKeys;
|
|
import com.eactive.eai.common.message.MessageType;
|
|
import com.eactive.eai.common.property.PropManager;
|
|
import com.eactive.eai.common.routing.RouteKeys;
|
|
import com.eactive.eai.common.stdmessage.STDMessageMapper;
|
|
import com.eactive.eai.common.util.MessageUtil;
|
|
import com.eactive.eai.common.util.StringUtil;
|
|
import com.eactive.eai.common.util.TranLogUtil;
|
|
import com.eactive.eai.common.worker.Future;
|
|
import com.eactive.eai.common.worker.ResponseMap;
|
|
import com.eactive.eai.control.LogSender;
|
|
import com.eactive.eai.control.SocketSender;
|
|
import com.eactive.eai.control.Transform;
|
|
import com.eactive.eai.env.ElinkConfig;
|
|
import com.eactive.eai.inbound.processor.Processor;
|
|
import com.eactive.eai.message.StandardMessage;
|
|
import com.eactive.eai.message.manager.StandardMessageManager;
|
|
import com.eactive.eai.message.parser.StandardReader;
|
|
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
public class SocketProcess extends DefaultProcess {
|
|
static final long serialVersionUID = 1L;
|
|
|
|
public void logSenderCtrlSendReq() throws Exception {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "" + this.reqEaiMsg.getSvcOgNo() + " - " + this.logPssSno);
|
|
try {
|
|
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP021";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isWarn())
|
|
logger.warn(rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void logSenderCtrlSendRes() throws Exception {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "" + this.resEaiMsg.getSvcOgNo() + " - " + this.logPssSno);
|
|
try {
|
|
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP021";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isWarn())
|
|
logger.warn(rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void outboundCtrlCallService() throws Exception {
|
|
// 인터페이스에 셋팅된 타임아웃설정
|
|
int iTimeoutValue = getTimeoutCodeToValue();
|
|
this.timeout = iTimeoutValue * 1000;
|
|
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
|
try {
|
|
this.resObject = SocketSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp);
|
|
// 응답코드에 대한 처리
|
|
this.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
|
|
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
|
this.resEaiMsg = setSendTime(this.resEaiMsg);
|
|
}
|
|
} catch (EAIConnectException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP002";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (EAINoAvailableConnectionException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP003";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (EAITimeoutException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP004";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP001";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
}
|
|
}
|
|
|
|
public void outboundCtrlCallServiceAsync() throws Exception {
|
|
// 인터페이스에 셋팅된 타임아웃설정
|
|
int iTimeoutValue = getTimeoutCodeToValue();
|
|
this.timeout = iTimeoutValue * 1000;
|
|
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
|
try {
|
|
this.resObject = SocketSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject,
|
|
this.tempProp);
|
|
} catch (EAIConnectException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP002";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (EAINoAvailableConnectionException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP003";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (EAITimeoutException e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP004";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP001";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
}
|
|
}
|
|
|
|
public void transControlTransformSingleRes() throws Exception {
|
|
try {
|
|
this.srcTranObject = this.resObject;
|
|
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, false, this.diURI, this.srcTranObject);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP030";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void transControlTransformSingleReq() throws Exception {
|
|
try {
|
|
String bizData = this.reqEaiMsg.getStandardMessage().getBizData();
|
|
if (bizData != null && bizData.length() > 0) {
|
|
this.srcTranObject = bizData;
|
|
}
|
|
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, true, this.diURI, this.srcTranObject);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP020";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new Exception(rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void printCallError(Exception e1) throws Exception {
|
|
this.resObject = new byte[0];
|
|
}
|
|
|
|
public void setRcvLogInfo() throws Exception {
|
|
// this.logPssSno = 300;
|
|
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp);
|
|
|
|
this.prop = new Properties();
|
|
if (this.isSuccess) {
|
|
prop.setProperty(Keys.ERROR_MESSAGE, Keys.FALSE);
|
|
} else {
|
|
prop.setProperty(Keys.ERROR_MESSAGE, Keys.TRUE);
|
|
}
|
|
|
|
// 표준메시지 파싱
|
|
if(MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
|
|
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "내부표준 추출");
|
|
try {
|
|
resEaiMsg = setRcvLogInfo(resEaiMsg, this.adptrMsgType, this.resObject, this.outboundCharset);
|
|
this.resObject = resEaiMsg.getStandardMessage().getBizDataBytes();
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP031"; // 잘못된 KB 내부표준메시지 수신[{1}]
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
}
|
|
}
|
|
else if (com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(this.adptrMsgPtrnCd)) {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "SUB표준 업무데이터 추출");
|
|
try {
|
|
this.resEaiMsg = convertToStandardMessage(resEaiMsg, adptrMsgType, this.resObject, this.outboundCharset);
|
|
this.resObject = resEaiMsg.getStandardMessage().getBizDataBytes();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP031"; // 잘못된 내부표준메시지 수신[{1}]
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setTopicResult() throws Exception {
|
|
try {
|
|
this.jmsRespObject = future.value(this.timeout);
|
|
if (this.jmsRespObject == null) {
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + "SYNC-ASYNC - SOCKET setTopicResult jmsRespObject is null. timeout="
|
|
+ this.timeout);
|
|
throw new Exception("RECEAIOSP010");
|
|
}
|
|
resEaiMsg = setResponseForOutbound(this.resEaiMsg);
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP010";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
} finally {
|
|
if (jmsRespAction != null) {
|
|
this.jmsRespAction.doEnd();
|
|
}
|
|
}
|
|
|
|
if (this.jmsRespObject == null) {
|
|
this.resObject = new byte[0];
|
|
} else if (this.jmsRespObject instanceof EAIMessage) {
|
|
EAIMessage topicEaiMsg = (EAIMessage) this.jmsRespObject;
|
|
this.resObject = topicEaiMsg.getStandardMessage().getBizDataBytes();
|
|
} else if (this.jmsRespObject instanceof byte[]) {
|
|
this.resObject = (byte[]) this.jmsRespObject;
|
|
} else {
|
|
this.resObject = new byte[0];
|
|
}
|
|
}
|
|
|
|
public void checkResultMessage() throws Exception {
|
|
// 동기방식거래를 비동기 방식의 어댑터로 할 경우 발생함
|
|
if (this.resObject != null) {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + " SYNC - SOCKET RESPONSE MESSAGE +"
|
|
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
|
|
|
|
} else {
|
|
if (logger.isWarn())
|
|
logger.warn(guidLogPrefix + " SYNC - SOCKET RESPONSE MESSAGE is NULL :"
|
|
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
|
|
this.resObject = new byte[0];
|
|
}
|
|
|
|
}
|
|
|
|
public void checkSendResult() throws Exception {
|
|
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + " ASYNC - SOCKET SEND...");
|
|
}
|
|
}
|
|
|
|
public void init() throws Exception {
|
|
this.tempProp = new Properties();
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "callProp [" + this.callProp + "]");
|
|
|
|
this.svcTsmtUsgTp = this.reqEaiMsg.getSvcTsmtUsgTp(); // Inbound 호출방식
|
|
this.psvItfTp = this.reqEaiMsg.getCurrentSvcMsg().getPsvItfTp(); // 호출방식
|
|
|
|
// 복합거래의 보상거래여부를 확인
|
|
this.svcPssTp = this.reqEaiMsg.getSvcPssTp();
|
|
this.svcPssSeq = this.reqEaiMsg.getSvcPssSeq();
|
|
|
|
if (this.callProp != null) {
|
|
logger.debug(guidLogPrefix + "COMP_VALUE[" + this.callProp.getProperty(EAIKeys.CALL_COMP_KEY) + "]");
|
|
if (EAIKeys.CALL_COMP_VALUE.equals(this.callProp.getProperty(EAIKeys.CALL_COMP_KEY))) {
|
|
this.isComp = true;
|
|
try {
|
|
this.svcPssSeq = Integer.parseInt(this.callProp.getProperty(EAIKeys.CALL_COMP_SVC_SEQ));
|
|
logger.debug(guidLogPrefix + "CALL_COMP_SVC_SEQ[" + this.svcPssSeq + "]");
|
|
} catch (Exception e) {
|
|
logger.warn(guidLogPrefix + "CALL_COMP_SVC_SEQ Get Error");
|
|
}
|
|
} else {
|
|
this.isComp = false;
|
|
}
|
|
} else {
|
|
this.isComp = false;
|
|
}
|
|
|
|
String returnType = getReturnType(reqEaiMsg);
|
|
|
|
if (STDMessageKeys.SEND_RECV_CD_RECV.equals(returnType)) {
|
|
this.logPssSno = 400;
|
|
} else {
|
|
this.logPssSno = TranLogUtil.getReqLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp);
|
|
}
|
|
|
|
this.prop = null;
|
|
this.resEaiMsg = this.reqEaiMsg;
|
|
|
|
this.adapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
|
|
this.adapterName = this.callProp.getProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME);
|
|
|
|
// 업무데이터에서 추출한 값을 KESA 개별부에 설정 (eb-Bank 관련)
|
|
// 송신전 메세지 설정(setSendMsg)에서 init으로 로직 이동
|
|
AdapterManager adapterManager = AdapterManager.getInstance();
|
|
|
|
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
|
|
AdapterVO adptVO = null;
|
|
AdapterPropManager manager = AdapterPropManager.getInstance();
|
|
|
|
if (adptGrpVO != null) {
|
|
adptVO = adptGrpVO.nextAdapterVO();
|
|
}
|
|
|
|
if (adptVO == null) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
// RECEAIOSP003 - EAI 서비스코드[{1}] Socket Adapter 가용 connection 이 없는 오류
|
|
String rspErrorCode = "RECEAIOSP003";
|
|
String rspErrorMsg = ExceptionUtil.make(rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
|
|
throw new Exception("가용한 어댑터가 없습니다.[" + this.adapterGroupName + "]");
|
|
|
|
} else {
|
|
this.outboundProp = manager.getProperties(adptVO.getPropGroupName());
|
|
}
|
|
this.adptrMsgPtrnCd = adptGrpVO.getAdptrMsgPtrnCd(); // migration - boolean 값이 아니라 [S, N, C] 값을 가짐
|
|
this.adptrMsgType = adptGrpVO.getMessageType();
|
|
|
|
String currentAdapterName = this.adapterGroupName;
|
|
if(this.adapterName != null) {
|
|
currentAdapterName = currentAdapterName + "." + this.adapterName;
|
|
}
|
|
this.tempProp.setProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_GROUP_NAME, currentAdapterName);
|
|
|
|
// Inboud Adapter mesageType
|
|
AdapterGroupVO inAdptGrpVO = adapterManager.getAdapterGroupVO(this.reqEaiMsg.getSngSysItfTp());
|
|
this.inAdapterMsgType = MessageType.ASC;
|
|
|
|
if (inAdptGrpVO == null) {
|
|
if (logger.isWarn()) {
|
|
String tasAdapterName = "";
|
|
if (this.callProp != null)
|
|
tasAdapterName = this.callProp.getProperty(Processor.TAS_ADAPTER_GROUP_NAME);
|
|
logger.warn(guidLogPrefix + "Source Adapter is null, TAS Inbound = " + tasAdapterName);
|
|
}
|
|
this.inAdapterMsgType = MessageType.ASC;
|
|
} else {
|
|
this.inAdapterMsgType = inAdptGrpVO.getMessageType();
|
|
}
|
|
}
|
|
|
|
public void setSendMsg() throws Exception {
|
|
// 표준메시지 방식일 경우 KESA메시지에 업무메시지를 설정하여 전달한다.
|
|
// [S, N, C] 값을 가짐
|
|
if (logger.isDebug())
|
|
logger.debug(guidLogPrefix + "IF_TYPE[" + this.adptrMsgPtrnCd + "]");
|
|
|
|
// 200 로그를 위한 변환된 메시지부를 설정
|
|
this.reqEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.outboundCharset);
|
|
|
|
if (this.tgtTranObject instanceof byte[]) {
|
|
this.reqObject = (byte[]) this.tgtTranObject;
|
|
} else if (this.tgtTranObject instanceof String) {
|
|
this.reqObject = ((String)this.tgtTranObject).getBytes(this.outboundCharset);
|
|
}
|
|
|
|
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
|
String restOption = this.reqEaiMsg.getCurrentSvcMsg().getRestOption();
|
|
setStandardRouteInfo(restOption);
|
|
AdapterManager adapterManager = AdapterManager.getInstance();
|
|
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(adapterGroupName);
|
|
AdapterVO adptVO = null;
|
|
if (adapterName == null) {
|
|
String[] adptrs = adptGrpVO.getAdapterNames();
|
|
if (adptrs != null && adptrs.length > 0) {
|
|
adptVO = adptGrpVO.getAdapterVO(adptrs[0]);
|
|
}
|
|
} else {
|
|
adptVO = adptGrpVO.getAdapterVO(adapterName);
|
|
this.tempProp.setProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME, adptVO.getName());
|
|
}
|
|
|
|
if (adptVO == null) {
|
|
throw new Exception("adapter not found");
|
|
}
|
|
|
|
this.tempProp.setProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_GROUP_NAME, this.adapterGroupName);
|
|
|
|
// 표준전문일 경우 헤더부 거래타임아웃시간(TX_TMOT_TKTM) 셋팅 어댑터 기준
|
|
AdapterPropManager adaptrPropManager = AdapterPropManager.getInstance();
|
|
Properties prop = adaptrPropManager.getProperties(adptVO.getPropGroupName());
|
|
String txTmotTktm = prop.getProperty("timeout", "50");
|
|
setTimeout(this.reqEaiMsg, StringUtil.stringFormat(txTmotTktm, true, '0', 3));
|
|
|
|
|
|
this.reqObject = makeStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject, this.outboundCharset);
|
|
if(this.reqObject instanceof String) {
|
|
this.reqObject = ((String) this.reqObject).getBytes(this.outboundCharset);
|
|
}
|
|
}
|
|
else if (com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(this.adptrMsgPtrnCd)) {
|
|
this.reqObject = makeSubStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject, this.outboundCharset);
|
|
if(this.reqObject instanceof String) {
|
|
this.reqObject = ((String) this.reqObject).getBytes(this.outboundCharset);
|
|
}
|
|
}
|
|
|
|
|
|
if (logger.isDebug()) {
|
|
if (this.reqObject != null) {
|
|
logger.debug(guidLogPrefix + " Socket Request Message : "
|
|
+ MessageUtil.toAdapterTypeString(this.reqObject, this.inboundCharset));
|
|
} else {
|
|
logger.debug(guidLogPrefix + " Socket Request Message : IS NULL");
|
|
}
|
|
}
|
|
}
|
|
|
|
public void getTopicProperty() throws Exception {
|
|
PropManager propManager = PropManager.getInstance();
|
|
|
|
this.topicConFactory = propManager.getProperty(RouteKeys.GROUP_NAME,
|
|
RouteKeys.ROUTING_TOPIC_CONNECTION_FACTORY);
|
|
this.topicName = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_TOPIC);
|
|
int iTimeoutValue = getTimeoutCodeToValue();
|
|
this.timeout = iTimeoutValue * 1000;
|
|
this.tracekey = this.reqEaiMsg.getCurrentSvcMsg().getKeyMgtMsgVl();
|
|
|
|
if (ElinkConfig.isUseCacheTopic()) {
|
|
this.future = new Future();
|
|
try {
|
|
ResponseMap.getInstance().put(this.tracekey, future);
|
|
} catch (Exception e) {
|
|
logger.error(guidLogPrefix + "Cannot start the Cache Response Future. - " + e.getMessage(), e);
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP060";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new Exception(rspErrorMsg);
|
|
}
|
|
} else {
|
|
jmsRespAction = new com.eactive.eai.common.worker.JMSListenerAction(this.topicConFactory, this.topicName,
|
|
this.timeout);
|
|
jmsRespAction.doInit(this.tracekey);
|
|
this.future = new Future();
|
|
try {
|
|
jmsRespAction.doStart(future.getSlot());
|
|
} catch (Exception e) {
|
|
logger.error(guidLogPrefix + "Cannot start the JMSListenerAction. - " + e.getMessage(), e);
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP060";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new Exception(rspErrorMsg);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void performSend() throws Exception {
|
|
try {
|
|
// 변화후에 있기 때문에 tgtTranObject 이용해야 된다.
|
|
String headerActionName = this.reqEaiMsg.getCurrentSvcMsg().getHdrRefClsName();
|
|
String headerContolType = StringUtil.getNullStr(this.reqEaiMsg.getCurrentSvcMsg().getHdrCtrlDstcd());
|
|
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Header 로직을 실행합니다.");
|
|
logger.debug(guidLogPrefix + "headerActionName : [" + headerActionName + "]");
|
|
logger.debug(guidLogPrefix + "전송 Type : [" + HeaderActionKeys.MESSAGE_SEND + "]");
|
|
logger.debug(guidLogPrefix + "Header Control Type : [" + headerContolType + "]");
|
|
}
|
|
|
|
HeaderAction action = HeaderActionFactory.createAction(headerActionName);
|
|
|
|
if (this.tgtTranObject instanceof byte[]) {
|
|
this.orgData = new byte[((byte[]) this.tgtTranObject).length];
|
|
System.arraycopy(this.tgtTranObject, 0, this.orgData, 0, ((byte[]) this.tgtTranObject).length);
|
|
|
|
this.tgtTranObject = action.excute(this.orgData, (byte[]) this.tgtTranObject,
|
|
HeaderActionKeys.MESSAGE_SEND, headerContolType);
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "this.tgtTranObject "
|
|
+ MessageUtil.toAdapterTypeString((byte[]) this.tgtTranObject, this.inboundCharset));
|
|
}
|
|
|
|
} else {
|
|
if (logger.isWarn()) {
|
|
logger.warn(guidLogPrefix + "byte[] 만허용됩니다. 업무메시지타입을 확인하세요" + this.tgtTranObject);
|
|
}
|
|
|
|
}
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Header 로직을 종료합니다.");
|
|
}
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP050";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new Exception(rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void performRecv() throws Exception {
|
|
try {
|
|
String headerActionName = this.reqEaiMsg.getCurrentSvcMsg().getHdrRefClsName();
|
|
String headerContolType = StringUtil.getNullStr(this.reqEaiMsg.getCurrentSvcMsg().getHdrCtrlDstcd());
|
|
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Header 로직을 실행합니다.");
|
|
logger.debug(guidLogPrefix + "headerActionName : [" + headerActionName + "]");
|
|
logger.debug(guidLogPrefix + "전송 Type : [" + HeaderActionKeys.MESSAGE_RECV + "]");
|
|
logger.debug(guidLogPrefix + "Header Control Type : [" + headerContolType + "]");
|
|
}
|
|
|
|
HeaderAction action = HeaderActionFactory.createAction(headerActionName);
|
|
|
|
if (this.resObject instanceof byte[]) {
|
|
this.resObject = action.excute(this.orgData, (byte[]) this.resObject, HeaderActionKeys.MESSAGE_RECV,
|
|
headerContolType);
|
|
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "this.resObject"
|
|
+ MessageUtil.toAdapterTypeString((byte[]) this.resObject, this.outboundCharset));
|
|
}
|
|
|
|
} else {
|
|
if (logger.isWarn()) {
|
|
logger.warn(guidLogPrefix + "byte[] 만허용됩니다. 업무메시지타입을 확인하세요" + this.resObject);
|
|
}
|
|
|
|
}
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Header 로직을 종료합니다.");
|
|
}
|
|
} catch (Exception e) {
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP050";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new Exception(rspErrorMsg);
|
|
}
|
|
}
|
|
|
|
public void storeMessage() throws Exception {
|
|
// ----------------------------------------------
|
|
// 비동기-비동기 거래 &&수동이 표준이 아닌 경우
|
|
// 원거래복원 여부가 '1' 일 경우 복원 정보를 저장
|
|
// ----------------------------------------------
|
|
String recoverYn = getRecoverYn(reqEaiMsg);
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Message 복원 Flag [" + recoverYn + "]");
|
|
}
|
|
if (EAIMessageKeys.ASYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())
|
|
&& !com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)
|
|
&& STDMessageKeys.RECOVER_YN_YES.equals(recoverYn)) {
|
|
|
|
try {
|
|
String keyMgtMsgCtnt = this.reqEaiMsg.getCurrentSvcMsg().getKeyMgtMsgVl();
|
|
if (logger.isDebug()) {
|
|
logger.debug(guidLogPrefix + "Message 복원 실행 KEY[" + keyMgtMsgCtnt + "]");
|
|
}
|
|
String extBizCd = this.reqEaiMsg.getExtBizCd();
|
|
STDMessageMapper.storeMessageHeader(keyMgtMsgCtnt, this.reqEaiMsg.getStandardMessage(), extBizCd, this.inAdapterMsgType);
|
|
} catch (Exception e) {
|
|
if (logger.isError()) {
|
|
logger.error(guidLogPrefix + "Message 저장 중 에러 발생", e);
|
|
}
|
|
|
|
String[] msgArgs = new String[1];
|
|
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
|
|
String rspErrorCode = "RECEAIOSP011";
|
|
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
|
|
if (logger.isError())
|
|
logger.error(guidLogPrefix + rspErrorMsg, e);
|
|
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
|
|
throw new RuntimeException(rspErrorCode);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void getBizMessage() throws Exception {
|
|
|
|
}
|
|
|
|
public void waitCheckForSync() throws Exception {
|
|
// Sync - Sync 거래중 Wait 메시지가 올경우 대비
|
|
// Async -Sync 는 Flow Control에서 처리 함
|
|
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd) && resObject != null) {
|
|
if (EAIMessageKeys.SYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())) {
|
|
StandardMessage standardMessage = null;
|
|
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
|
StandardReader reader = null;
|
|
try {
|
|
standardMessage = standardManager.getStandardMessage();
|
|
reader = standardManager.getReader(this.adptrMsgType);
|
|
reader.parse(standardMessage, resObject);
|
|
//표준 전문 파싱 후 어댑터의 charset을 설정한다.
|
|
standardMessage.setBizDataCharset(outboundCharset);
|
|
}catch(Exception e) {
|
|
logger.error("standardMessage parsing error " + e.getMessage(),e);
|
|
return ;
|
|
}
|
|
boolean isWait = standardManager.getMessageCoordinator().coordinateIsWaitCheckForSync(standardMessage);
|
|
if (isWait) {
|
|
getTopicProperty();
|
|
try {
|
|
setTopicResult();
|
|
}catch (Exception e) {
|
|
executeTimeout();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected void setStandardRouteInfo(String routeOption) throws JsonProcessingException {
|
|
if(StringUtils.isBlank(routeOption)) {
|
|
return ;
|
|
}
|
|
JsonNode rootNode = new ObjectMapper().readTree(routeOption);
|
|
JsonNode standardCommonFields = rootNode.get("standardCommonFields");
|
|
|
|
if (standardCommonFields != null && standardCommonFields.isObject()) {
|
|
standardCommonFields.fields().forEachRemaining(field -> {
|
|
String key = field.getKey();
|
|
String value = field.getValue().asText();
|
|
|
|
StandardMessage standardMessage = this.reqEaiMsg.getStandardMessage();
|
|
standardMessage.setData(key, value);
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void transControlHeaderTrnsformSinglesRes() throws Exception {
|
|
|
|
}
|
|
}
|