This commit is contained in:
Rinjae
2025-09-05 18:57:45 +09:00
commit aacc1a389e
1229 changed files with 167963 additions and 0 deletions
@@ -0,0 +1,731 @@
package com.eactive.eai.outbound;
import java.util.Properties;
import javax.jms.JMSException;
import org.apache.commons.lang3.StringUtils;
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.amq.AMQAdapterConstants;
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
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.server.EAIServerManager;
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.AMQSender;
import com.eactive.eai.control.LogSender;
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;
public class AMQProcess extends DefaultProcess {
@Override
public void logSenderCtrlSendReq() throws Exception {
try {
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
@Override
public void logSenderCtrlSendRes() throws Exception {
try {
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
@Override
public void outboundCtrlCallService() throws Exception {
// 인터페이스에 셋팅된 타임아웃설정
int iTimeoutValue = getTimeoutCodeToValue();
this.timeout = iTimeoutValue * 1000;
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
try {
this.resObject = AMQSender.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 (JMSException jmse) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAICUL001";
String rspErrorMsg = ExceptionUtil.make(jmse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, jmse);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
}
}
@Override
public void outboundCtrlCallServiceAsync() throws Exception {
/**
* async에서는 인터페이스 값을 설정하지 않고 Adapter의 타임아웃을 쓰기위해서 설정하지 않음
*/
try {
this.resObject = AMQSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject,
this.tempProp);
} catch (JMSException jmse) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAICUL001";
String rspErrorMsg = ExceptionUtil.make(jmse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, jmse);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
}
}
@Override
public void transControlTransformSingleRes() throws Exception {
try {
this.srcTranObject = this.resObject;
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, false, this.diURI, this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 300 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP030";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
}
}
@Override
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) {
if (logger.isError())
logger.error(guidLogPrefix + " 200 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP020";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
@Override
public void printCallError(Exception e1) throws Exception {
this.resObject = "";
if ("RECEAICUL001".equals(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo() + "] Queue Transfer Error - "
+ e1.getMessage());
}
} else {
// REST 는 TEST Call을 할수 없음.20200813.최준호
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo() + "] 수동시스템 오류 ");
}
}
}
@Override
public void setRcvLogInfo() throws Exception {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp); // 300
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().getBizData();
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP002";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError()) {
logger.error(guidLogPrefix + rspErrorMsg, e);
}
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
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().getBizData();
} 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.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
}
}
}
}
@Override
public void setTopicResult() throws Exception {
try {
this.jmsRespObject = future.value(this.timeout);
if (this.jmsRespObject == null) {
throw new Exception("RECEAIOHP010");
}
resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP010";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
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];
}
}
@Override
public void checkResultMessage() throws Exception {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " SYNC - QUEUE RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
@Override
public void checkSendResult() throws Exception {
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " ASYNC - QUEUE RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
}
@Override
public void init() throws Exception {
this.prop = null;
this.adapterName = null;
this.resEaiMsg = this.reqEaiMsg;
this.adapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
// DefaultProcess 이관시 누락된 부분 추가
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);
}
// Inbound Adapter mesageType
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO inAdptGrpVO = adapterManager.getAdapterGroupVO(this.reqEaiMsg.getSngSysItfTp());
this.inAdapterMsgType = MessageType.ASC;
if (inAdptGrpVO == null) {
if (logger.isWarn()) {
if (this.prop == null) {
logger.warn(guidLogPrefix + "Source Adapter is null, TAS Inbound ");
} else {
logger.warn(guidLogPrefix + "Source Adapter is null, TAS Inbound = "
+ this.prop.getProperty(Processor.TAS_ADAPTER_GROUP_NAME));
}
}
this.inAdapterMsgType = MessageType.ASC;
} else {
this.inAdapterMsgType = inAdptGrpVO.getMessageType();
}
}
@Override
public void setSendMsg() throws Exception {
try {
// 200 로그를 위한 변환된 메시지부를 설정
this.reqEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.outboundCharset);
if (this.tgtTranObject instanceof String) {
this.reqObject = (String) this.tgtTranObject;
} else {
throw new Exception("Invlid Transform output message (" + this.tgtTranObject + ")");
}
AdapterGroupVO adptGrpVO = null;
try {
AdapterManager adapterManager = AdapterManager.getInstance();
adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
if (adptGrpVO == null) {
throw new Exception("adapter group not found");
}
AdapterVO adptVO = adptGrpVO.nextAdapterVO();
if (adptVO == null) {
throw new Exception("adapter not found");
}
this.adapterName = adptVO.getName();
this.adptrMsgType = adptGrpVO.getMessageType();
AdapterPropManager manager = AdapterPropManager.getInstance();
this.outboundProp = (Properties) manager.getProperties(adptVO.getPropGroupName());// clone 안함으로 변경
if (this.tempProp == null) {
this.tempProp = new Properties();
}
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, this.adapterGroupName);
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
this.tempProp.setProperty(AMQAdapterConstants.TEMP_INTERFACE_RESPONSE_TYPE, this.psvItfTp);
this.tempProp.setProperty(AMQAdapterConstants.TEMP_MESSAGE_TYPE, this.adptrMsgType);
String svcName = getServiceId(this.reqEaiMsg);
if (svcName == null) {
svcName = "";
} else {
svcName = svcName.trim();
}
this.tempProp.setProperty(HttpClientAdapterServiceKey.TRAN_CODE, svcName);
this.adptrMsgPtrnCd = adptGrpVO.getAdptrMsgPtrnCd();
this.adptrMsgType = adptGrpVO.getMessageType();
} catch (Exception e) {
throw new Exception("Target Adapter Fail (" + this.adapterGroupName + ") ");
}
// 표준메시지 방식일 경우 KESA메시지에 업무메시지를 설정하여 전달한다.
// migration - boolean 값이 아니라 [S, N, C] 값을 가짐
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
this.reqObject = makeStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject,
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);
}
} else {
// 변환을 수행하고 결과가 비표준 XML일 경우에만
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getCnvEn())
&& MessageType.XML.equals(adptGrpVO.getMessageType())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " Add Xml Header Tag to NONSTANDARD XML Message");
}
String reqString = (String) this.reqObject;
if (!StringUtils.startsWith(reqString, "<?xml")) {
reqString = "<?xml version=\"1.0\" encoding=\"" + this.outboundCharset + "\"?>\n" + reqString;
this.reqObject = reqString;
}
}
if (logger.isDebug())
logger.debug(guidLogPrefix + " HTTP NONSTANDARD Request Message : "
+ MessageUtil.toAdapterTypeString(this.reqObject, this.inboundCharset));
}
// TAS 선택시 시뮬레이터 url로 변경
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer() && EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())
&& StringUtils.equals(adptGrpVO.getType(), "AMQ")) {
PropManager manager = PropManager.getInstance();
Properties prop = manager.getProperties(RouteKeys.SIM);
String simAddr = prop.getProperty(RouteKeys.SIM_REST_MOCKSERVER);
if (StringUtils.isBlank(simAddr)) {
throw new Exception(String.format("Properties %s > %s not setted", RouteKeys.SIM,
RouteKeys.SIM_REST_MOCKSERVER));
}
String url = StringUtils.removeEnd(simAddr, "/") + "/mockapi/" + this.reqEaiMsg.getEAISvcCd();
this.outboundProp.put(HttpClientAdapterServiceKey.URL, url);
logger.debug("simUrl=" + url);
}
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP022";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
@Override
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 = "RECEAIOHP060";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
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 = "RECEAIOHP060";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
}
@Override
public void performSend() 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_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.orgMessage"
+ 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 = "RECEAIOHP040";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
@Override
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);
String bizData = this.resEaiMsg.getStandardMessage().getBizData();
if (bizData != null && bizData.length() > 0) {
this.tgtTranObject = bizData;
}
if (this.tgtTranObject instanceof byte[]) {
this.tgtTranObject = action.excute(this.orgData, (byte[]) this.tgtTranObject,
HeaderActionKeys.MESSAGE_RECV, headerContolType);
this.resEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.inboundCharset);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " this.tgtTranObject"
+ MessageUtil.toAdapterTypeString((byte[]) this.tgtTranObject, this.outboundCharset));
}
} 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 = "RECEAIOHP040";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
@Override
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.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
}
}
// ---------------------------------------------------------------------
}
@Override
public void getBizMessage() throws Exception {
// setRcvLogInfo() 에서 이미 호출됨
}
@Override
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 {
// SA 응답 메시지 설정
setTopicResult();
} catch (Exception e) {
// Timeout
executeTimeout();
}
}
}
}
}
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,929 @@
package com.eactive.eai.outbound;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
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.handler.AdapterErrorMessageHandler;
import com.eactive.eai.adapter.handler.AdapterErrorMessageHandlerFactory;
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
import com.eactive.eai.common.EAIKeys;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.header.HeaderActionKeys;
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.routing.Process;
import com.eactive.eai.common.server.EAIServerManager;
import com.eactive.eai.common.submessage.SubMessageManager;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.common.util.MessageKeyExtractor;
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.util.UUIDGenerator;
import com.eactive.eai.control.LogSender;
import com.eactive.eai.message.StandardItem;
import com.eactive.eai.message.StandardMessage;
import com.eactive.eai.message.manager.StandardMessageManager;
import com.eactive.eai.message.mapper.MessageMapper;
import com.eactive.eai.message.service.InterfaceMapper;
import com.ext.eai.common.stdmessage.STDMessageKeys;
public abstract class DefaultProcess extends Process {
protected static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
protected static Logger esbLogger = Logger.getLogger(Logger.LOGGER_ESBFW);
protected String guidLogPrefix = this.getClass().getSimpleName() + "] ";
protected static ThreadLocal local = new ThreadLocal(); // 경과시간 동기화를 위한 ThreadLocal
protected int svrLogLevel;
protected EAIMessage resEaiMsg;
protected EAIMessage reqEaiMsg;
protected Properties callProp;
protected Object tgtTranObject;
protected int logPssSno;
protected String svcTsmtUsgTp;
protected String psvItfTp;
protected Properties prop;
protected Properties outboundProp;
protected Properties tempProp;
protected boolean isComp;
protected String svcPssTp;
protected int svcPssSeq;
protected Object jmsRespObject;
protected boolean isSuccess;
protected String adapterGroupName;
protected String adapterName;
protected Object reqObject;
protected Object resObject;
protected String inboundCharset;
protected String outboundCharset;
protected String adptrMsgPtrnCd; // migration - boolean 값이 아니라 [S, N, C] 값을 가짐
protected String diURI;
protected boolean isTgtTran;
protected com.eactive.eai.common.worker.Future future;
protected com.eactive.eai.common.worker.JMSListenerAction jmsRespAction;
protected String inAdapterMsgType; // 송신어댑터 타입
protected String adptrMsgType; // 추가
protected String topicName;
protected String topicConFactory;
protected int timeout;
protected String tracekey;
protected Object srcTranObject;
protected byte[] orgData;
public EAIMessage clientReturn() {
if (svrLogLevel >= 1) {
try {
long msgSndTm = System.currentTimeMillis();
Long threadData = (Long) local.get();
long processTm = msgSndTm - threadData.longValue();
if (esbLogger.isInfo())
esbLogger.info(
guidLogPrefix + " End... - 경과시간 : " + processTm + "(ms) - EAI Server Log Level is INFO");
} catch (Exception e) {
logger.warn("clientReturn", e);
}
}
return resEaiMsg;
}
public void callService(EAIMessage reqEaiMsg, Properties prop) {
if (reqEaiMsg == null) {
return;
}
if (StringUtils.equals(reqEaiMsg.getFlwCntlRtnNm(), "PUBFC")) {
try {
this.reqEaiMsg = (EAIMessage) reqEaiMsg.clone();
if (prop != null) {
this.callProp = (Properties) prop.clone();
}
} catch (Exception e) {
logger.warn("callService-1", e);
}
} else {
this.reqEaiMsg = reqEaiMsg;
this.callProp = prop;
}
svrLogLevel = this.reqEaiMsg.getSvrLogLvl();
guidLogPrefix = this.getClass().getSimpleName() + "] GUID["
+ reqEaiMsg.getMapper().getGuid(reqEaiMsg.getStandardMessage()) + "] UUID["
+ this.reqEaiMsg.getSvcOgNo() + "] ";
if (svrLogLevel >= 1) {
try {
long msgRcvTm = System.currentTimeMillis();
local.set(new Long(msgRcvTm));
if (esbLogger.isInfo())
esbLogger.info(guidLogPrefix + " started... - EAI Server Log Level is INFO");
} catch (Exception e) {
logger.warn("callService", e);
}
}
try {
// IN,OUT adapter의 charset.
this.inboundCharset = prop.getProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_IN);
// Queue에서 호출될때 설정이 없음
if (StringUtils.isBlank(this.inboundCharset)) {
this.inboundCharset = this.reqEaiMsg.getStandardMessage().getBizDataCharset();
}
String outboundAdapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
AdapterGroupVO outboundAdapterGvo = AdapterManager.getInstance()
.getAdapterGroupVO(outboundAdapterGroupName);
prop.setProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_OUT,
StringUtils.defaultIfBlank(outboundAdapterGvo.getMessageEncode(), Charset.defaultCharset().name()));
this.outboundCharset = prop.getProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_OUT);
flow();
} catch (Exception e) {
logger.warn("flow", e);
} finally {
if (jmsRespAction != null) {
this.jmsRespAction.doEnd();
}
}
}
public void flow() throws Exception {
// WarmUp start
if (!isRealCall()) {
return;
}
// WarmUp end
// 송신전 처리 start
try {
// 초기화
init();
// 송신변환
if (isSourceTransform()) {
// 수동메시지 변환
transControlTransformSingleReq();
} else {
// 메시지 설정
setTgtTranObject();
}
// Header컨트롤여부
if (isHeaderControl()) {
performSend();
}
// 송신전 메시지 설정
setSendMsg();
} catch (Exception e) {
// 오류처리
checkErrorReturn(e);
return;
}
// 송신전 처리 end
// Sync-Async 호출 start
try {
// 아웃바운드 Sync 호출
if (isOutboundSync()) {
// 송신전로그
logSenderCtrlSendReq();
try {
// Sync 호출
outboundCtrlCallService();
} catch (Exception e1) {
printCallError(e1);
}
// 응답메시지확인
checkResultMessage();
// Sync 에서 Wait 올경우 체크
waitCheckForSync();
} else {
// SA
if (isSyncAsyncPattern()) {
// 응답환경설정
getTopicProperty();
} else {
// 복원저장
storeMessage();
}
// 송신전 로그
logSenderCtrlSendReq();
try {
// Async 호출
outboundCtrlCallServiceAsync();
} catch (Exception e1) {
printCallError(e1);
}
// 송신결과확인
checkSendResult();
// SA
if (isSyncAsyncPattern()) {
try {
// SA응답메시지 설정
setTopicResult();
} catch (Exception e) {
// Timeout
executeTimeout();
}
}
// AA : commented - Do nothing
// else if (isAsyncAsyncPattern()){
// //TimerInfo 설정
// setTimerInfo();
// //timerInforInsert
// timerInfoControlTimerInfoInsert();
// }
}
} catch (Exception e) {
performSendError();
}
// Sync-Async 호출 end
// 정상처리 확인 start
// 정상처리확인
if (checkOutboundTransaction()) {
// 동기거래
if (isSync()) {
// 응답로그값 설정
setRcvLogInfoExtend();
// 응답로그
logSenderCtrlSendRes();
// 업무응답메시지추출
getBizMessage();
// 업무 응답메시지 확인
boolean successReturn = isSuccessReturn();
if (logger.isDebug())
logger.debug(guidLogPrefix + " isSuccessReturn() >> [" + successReturn + "]");
if (successReturn) {
// 정상메시지변환
transformToSource();
} else {
// 오류메시지변환
transformErrorToSource();
}
if (logger.isDebug())
logger.debug(guidLogPrefix + " isTgtTranCall() >> [" + isTgtTranCall() + "]");
// 응답변환
if (isTgtTranCall()) {
// 응답메시지변환
transControlTransformSingleRes();
// 변환응답메시지설정
setConvertedMsg();
} else {
// 응답메시지설정
setResMsg();
}
transControlHeaderTrnsformSinglesRes();
// Header컨트롤여부
if (isHeaderControl()) {
performRecv();
}
} else {
// 비동기 거래
}
} else {
// sync 오류시 추가
// if (isSync()) {
// }
// default
// 요청거래
if (isRequest()) {
// 오류메시지설정
setOutboundErrorMessage();
// 오류메시지로그
logSenderCtrlSendError();
} else {
// default
}
}
}
protected void setRcvLogInfoExtend() throws Exception {
setRcvLogInfo();
// 비표준만 셋팅함 표준은 위 코드에서 셋팅함
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
InterfaceMapper mapper = this.resEaiMsg.getMapper();
StandardMessage standardMessage = this.resEaiMsg.getStandardMessage();
// GUID SET
mapper.nextGuidSeq(standardMessage);
String guid = mapper.getGuid(standardMessage);
String guidSeq = mapper.getGuidSeq(standardMessage);
mapper.setGuid(standardMessage,
guid + StringUtils.defaultString(StringUtils.leftPad(guidSeq, UUIDGenerator.GUID_SEQ_LENGTH, '0')));
// 시스템구분
// stdmsg.setData("stdheader.Inter_chn", EAIServerManager.getInstance().getSystemGubun());
mapper.setReqSysCode(standardMessage, EAIServerManager.getInstance().getSystemGubun());
// 수신시각 설정
// stdmsg.setData("stdheader.recv_tm", DatetimeUtil.getCurrentTimeMillis());
mapper.setRecvTime(standardMessage, DatetimeUtil.getCurrentTimeMillis());
// 전문응답구분
// stdmsg.setData("stdheader.return_gubun", STDMessage.SEND_RECV_CD_RECV);
mapper.setSendRecvDivision(standardMessage, STDMessageKeys.SEND_RECV_CD_RECV);
// 처리결과
String procsRsltDvcd = mapper.getResponseType(standardMessage);
if (StringUtils.isBlank(procsRsltDvcd)) {
mapper.setResponseType(standardMessage, STDMessageKeys.RESPONSE_TYPE_CODE_N);
}
standardMessage.setBizData(this.resObject, this.outboundCharset);
StandardMessageManager.getInstance().getMessageCoordinator().coordinateAfterRecvNonStdSyncResponse(standardMessage);
}
// inbound adapter로 참조데이터 전달
if (this.tempProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP) != null) {
this.callProp.put(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP,
this.tempProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP));
}
}
/**
* WarmUp 여부
*
* @return
*/
public boolean isRealCall() {
if (this.callProp != null) {
String mode = this.callProp.getProperty(EAIKeys.CALL_MODE_KEY);
if (mode != null && EAIKeys.CALL_MODE_WARMUP.equals(mode)) {
logger.warn(guidLogPrefix + " Warming Up Called");
return false;
} else {
return true;
}
} else {
return true;
}
}
public void setTgtTranObject() throws Exception {
String bizData = this.reqEaiMsg.getStandardMessage().getBizData();
// if(bizData != null && bizData.length() > 0) {
if (bizData != null) {
this.tgtTranObject = bizData;
}
}
/**
* 헤더 추가삭제/삭제추가 여부
*
* @return
*/
public boolean isHeaderControl() {
// supplDelYn = Y && (da || ad)
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " Header Control 여부 : [" + this.reqEaiMsg.getCurrentSvcMsg().getSupplDelYn()
+ "]");
logger.debug(guidLogPrefix + " Header Control Type : ["
+ this.reqEaiMsg.getCurrentSvcMsg().getHdrCtrlDstcd() + "]");
logger.debug(guidLogPrefix + " header Action Name : ["
+ this.reqEaiMsg.getCurrentSvcMsg().getHdrRefClsName() + "]");
}
String hdrCtrlDstcd = StringUtil.getNullStr(this.reqEaiMsg.getCurrentSvcMsg().getHdrCtrlDstcd());
if (HeaderActionKeys.SUPPORT_Y.equals(StringUtil.getNullStr(this.reqEaiMsg.getCurrentSvcMsg().getSupplDelYn()))
&& (HeaderActionKeys.DELETE_ADD_HEADER.equals(hdrCtrlDstcd)
|| HeaderActionKeys.ADD_DELETE_HEADER.equals(hdrCtrlDstcd))) {
return true;
} else {
return false;
}
}
public void checkErrorReturn(Exception e1) throws Exception {
try {
if (this.resEaiMsg == null)
this.resEaiMsg = this.reqEaiMsg;
// 에러코드가 설정되지 않은 경우
// 공통에러코드를 설정한다.
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
String[] msgArgs = new String[1];
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
// [EAI 서비스코드:{1}] 송신전 메시지 처리 중 에러
String rspErrorCode = "RECEAIOCO000";
String rspErrorMsg = ExceptionUtil.make(e1, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, e1);
this.resEaiMsg.setRspErr(rspErrorCode, rspErrorMsg);
}
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
if (EAIMessageKeys.SYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())) {
// 요청시 에러 발생해서 응답 설정필요
StandardMessageManager standardManager = StandardMessageManager.getInstance();
standardManager.getMessageCoordinator().coordinateInReturnObject(this.resEaiMsg.getStandardMessage());
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp);
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
}
} catch (Exception e) {
if (logger.isWarn()) {
logger.warn(guidLogPrefix + " 송신전 오류애 대한 처리로직 수행 중 오류가 발생");
logger.warn(e.getMessage());
}
}
}
public boolean isOutboundSync() {
if (logger.isDebug())
logger.debug(guidLogPrefix + "수동인터페이스 통신유형[" + this.psvItfTp + "]");
if (EAIMessageKeys.SYNC_SVC.equals(this.psvItfTp)) {
return true;
} else {
return false;
}
}
public boolean isSyncAsyncPattern() {
if (!MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
return false;
} else if (EAIMessageKeys.SYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())) {
return true;
} else {
return false;
}
}
public void performSendError() throws Exception {
try {
if (this.resEaiMsg == null)
this.resEaiMsg = this.reqEaiMsg;
if(EAIMessageKeys.ASYNC_SVC.equals(this.resEaiMsg.getCurrentSvcMsg().getPsvItfTp())){
return ;
}
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
if (EAIMessageKeys.SYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())) {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp);
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
}
} catch (Exception e) {
if (logger.isWarn()) {
logger.warn(guidLogPrefix + "송신에러 처리로직 수행 중 오류가 발생");
logger.warn(e.getMessage());
}
}
}
public void executeTimeout() throws Exception {
this.jmsRespObject = new byte[0];
}
public boolean checkOutboundTransaction() {
if (!MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
return false;
} else {
return true;
}
}
public boolean isSync() {
// SS || SA
if (EAIMessageKeys.SYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())
|| EAIMessageKeys.SYNC_SVC.equals(this.psvItfTp)) {
return true;
} else {
return false;
}
}
public boolean isSuccessReturn() {
try {
// 표준헤더의 출력메시지 정보의 출력데이터 유형구분코드가 '02' 이고
// 오류변환이 있는 경우에 오류변환을 수행하도록 한다
/**
* NexCore 는 오류일경우 업무데이터가 없음 응답에 N이 아닐경우 ERROR로 설정(오류변환주석처리)
*/
InterfaceMapper mapper = this.resEaiMsg.getMapper();
StandardMessage standardMessage = this.resEaiMsg.getStandardMessage();
String responseType = mapper.getResponseType(standardMessage);
if ((com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)
||com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(this.adptrMsgPtrnCd))
&& responseType != null
&& !STDMessageKeys.RESPONSE_TYPE_CODE_N.equals(responseType)
// &&
// EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvEn())
) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " 표준헤더의 출력메시지 정보의 출력데이터 유형구분코드[" + responseType + "]가 오류출력");
}
this.isSuccess = false;
} else {
this.isSuccess = MessageKeyExtractor.isSuccessMessage(this.adapterGroupName, this.resObject);
// 비표준인 경우 출력 데이터 유형구분코드를 EAI가 설정한다.
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
if (this.isSuccess) {
mapper.setResponseType(standardMessage, STDMessageKeys.RESPONSE_TYPE_CODE_N);
} else {
mapper.setResponseType(standardMessage, STDMessageKeys.RESPONSE_TYPE_CODE_E);
}
}
}
} catch (Exception e) {
this.isSuccess = false;
}
return this.isSuccess;
}
public void logSenderCtrlSendError() throws Exception {
try {
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
} catch (Exception e) {
if (logger.isWarn())
logger.warn(guidLogPrefix + " EAI 서비스코드[" + this.resEaiMsg.getEAISvcCd() + "] " + this.logPssSno
+ " 거래로그 중 오류발생");
}
}
public void transformToSource() throws Exception {
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
this.resEaiMsg.setRspErrCd(EAIMessageKeys.EAI_SUCCESS_CODE);
}
// 2020.02.07 업무데이터가 Empty 이면 변환을 Skip한다.
// if(MessageUtil.isBizDataEmpty(this.resBytes)) {
// if (logger.isInfo()) logger.info(guidLogPrefix + "Response Message is EMPTY, Skip Transform.");
// this.isTgtTran = false;
// }
// else
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getBsRspCnvEn())) {
this.isTgtTran = true;
this.resEaiMsg.setRspnsChngMsgType(EAIMessageKeys.RSPNSCHNGMSGTYPE_RES);
} else {
this.isTgtTran = false;
}
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getBsRspCnvMsgID();
}
public void transformErrorToSource() throws Exception {
this.resEaiMsg.setRspErrCd(EAIMessageKeys.BWK_ERRMSG_CODE);
// 2020.02.07 업무데이터가 Empty 이면 변환을 Skip한다.
// if(MessageUtil.isBizDataEmpty(this.resBytes)) {
// if (logger.isInfo()) logger.info(guidLogPrefix + "Error Response Message is EMPTY, Skip Transform.");
// this.isTgtTran = false;
// }
// else
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvEn())) {
this.isTgtTran = true;
} else {
this.isTgtTran = false;
/**
* 20210608 NexCore 는 오류일경우 업무데이터가 없음 에러 변환이 없기 때문에 isTgtTran 로 설정하면 변환을 안탐
*/
// //--------------------------------------------------
// // 오류응답인 경우 에러변환이 없는 경우 에러로 처리함
// //--------------------------------------------------
// String[] msgArgs = new String[1];
// msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
// if (logger.isError()) {
// logger.error(guidLogPrefix + " 오류응답변환 미등록 EAI서비스코드["+msgArgs[0]+"]");
// }
//
// String rspErrorCode = "RECEAIOHP030";
// String rspErrorMsg = ExceptionUtil.make(rspErrorCode, "오류응답변환 미등록 ", msgArgs);
// if (logger.isError()) logger.error(guidLogPrefix + rspErrorMsg);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
// //---------------------------------------------------
}
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvMsgID();
this.resEaiMsg.setRspnsChngMsgType(EAIMessageKeys.RSPNSCHNGMSGTYPE_ERR);
}
public void setResMsg() throws Exception {
StandardMessage resStandardMessage = this.resEaiMsg.getStandardMessage();
InterfaceMapper mapper = this.resEaiMsg.getMapper();
String responseType = mapper.getResponseType(resStandardMessage);
if(!STDMessageKeys.RESPONSE_TYPE_CODE_N.equals(responseType)){
String inboudnAdapterGroupName = this.callProp.getProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME);
String inboudnAdapterName = this.callProp.getProperty(HttpClientAdapterServiceKey.ADAPTER_NAME);
if(StringUtils.isBlank(inboudnAdapterGroupName) || StringUtils.isBlank(inboudnAdapterName)) {
return;
}
AdapterGroupVO inboundAdapterGroupVO = AdapterManager.getInstance().getAdapterGroupVO(inboudnAdapterGroupName);
AdapterVO inboundAdapterVO = AdapterManager.getInstance().getAdapterVO(inboudnAdapterGroupName, inboudnAdapterName);
String errorResponseHandlerClass = AdapterPropManager.getInstance().getProperty(inboundAdapterVO.getPropGroupName(), "ERR_MSG_HANDLER");
if(StringUtils.isBlank(errorResponseHandlerClass)) {
return;
}
logger.info(inboudnAdapterName+", Handle Error Message Class-"+errorResponseHandlerClass);
AdapterErrorMessageHandler adapterErrorMessageHandler = AdapterErrorMessageHandlerFactory.createHandler(errorResponseHandlerClass);
Object responseObj = adapterErrorMessageHandler.generateNonStandardErrorResponseMessage(inboudnAdapterGroupName, inboudnAdapterName, this.callProp, this.tgtTranObject, resStandardMessage);
if(responseObj != null) {
resStandardMessage.setBizData(responseObj, inboundAdapterGroupVO.getMessageEncode());
}
}
}
public boolean isTgtTranCall() {
return this.isTgtTran;
}
public void setConvertedMsg() throws Exception {
this.resEaiMsg.getStandardMessage().setBizData(this.tgtTranObject, this.inboundCharset);
}
public boolean isSourceTransform() {
try {
// 표준헤더의 출력메시지 정보의 출력데이터 유형구분코드가 '02' 이고
// 오류변환이 있는 경우에 오류변환을 수행하도록 한다
InterfaceMapper mapper = this.reqEaiMsg.getMapper();
StandardMessage standardMessage = this.reqEaiMsg.getStandardMessage();
String responseType = mapper.getResponseType(standardMessage);
String returnType = mapper.getSendRecvDivision(standardMessage);
// 2025.03.28 responseType값이 없을때 return값이 " "로 설정되어 if문에서 true가 되어 에러응답변환 값으로 설정됨
if (responseType != null && !"".equals(responseType.trim()) && !STDMessageKeys.RESPONSE_TYPE_CODE_N.equals(responseType)
&& EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvEn())) {
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvMsgID();
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " 요청변환(에러응답변환) 출력데이터 유형구분코드[" + responseType + "] - " + this.diURI);
}
return true;
} else {
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getCnvEn())) {
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getCnvMsgID();
// ----------------------------------------------------------------
// AA 응답 거래일 경우 기동어댑터의 정상응답 에러응답여부를 확인하여
// 오류응답일 경우 오류변환을 수행
// ----------------------------------------------------------------
if (EAIMessageKeys.ASYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())
&& EAIMessageKeys.ASYNC_SVC.equals(this.psvItfTp)
&& STDMessageKeys.SEND_RECV_CD_RECV.equals(returnType)
&& EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvEn())) {
String inAdapter = this.reqEaiMsg.getSngSysItfTp();
boolean successFlag = MessageKeyExtractor.isSuccessMessage(inAdapter,
standardMessage.getBizData());
if (!successFlag) {
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getErrRspCnvMsgID();
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " 요청변환(에러응답변환) - " + this.diURI);
}
}
}
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " 요청변환 - " + this.diURI);
}
return true;
} else {
return false;
}
}
} catch (Exception e) {
return false;
}
}
public void setOutboundErrorMessage() throws Exception {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp);
InterfaceMapper mapper = this.resEaiMsg.getMapper();
StandardMessage standardMessage = this.resEaiMsg.getStandardMessage();
// 에러에 대한 응답메시지
if(this.tempProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP) instanceof Map) {
Map<String, Object> map = (Map<String, Object>) this.tempProp.get(HttpAdapterServiceKey.OUTBOUND_PROPERTY_MAP);
this.resObject = map.get(HttpAdapterServiceKey.OUTBOUND_RESPONSE_MESSAGE);
}
standardMessage.setBizData(this.resObject, this.inboundCharset);
try {
mapper.nextGuidSeq(standardMessage);
mapper.setSendRecvDivision(standardMessage, STDMessageKeys.SEND_RECV_CD_RECV);
StandardMessageManager standardManager = StandardMessageManager.getInstance();
standardManager.getMessageCoordinator().coordinateSetStandardMessageError(standardMessage, mapper,
this.resEaiMsg.getRspErrCd(), this.resEaiMsg.getRspErrMsg());
} catch (Exception e) {
logger.error(e.getMessage());
}
}
public boolean isRequest() {
// ----------------------------------------------
// FILE 변경에 따른 BUG
// AA 응답거래일 경우
// 에러 로그를 남기지 않는다.
// AA 응답거래일 경우에는 FlowControl에서 ExceptionHandler에 의해
// 900 ERROR 로그를 남긴다.
// ----------------------------------------------
InterfaceMapper mapper = reqEaiMsg.getMapper();
StandardMessage standardMessage = reqEaiMsg.getStandardMessage();
String returnType = mapper.getSendRecvDivision(standardMessage);
// AA && RES
if (EAIMessageKeys.ASYNC_SVC.equals(this.reqEaiMsg.getSvcTsmtUsgTp())
&& EAIMessageKeys.ASYNC_SVC.equals(this.psvItfTp)
&& STDMessageKeys.SEND_RECV_CD_RECV.equals(returnType)) {
return false;
} else {
return true;
}
}
protected int getTimeoutCodeToValue() throws Exception {
// PropManager propManager = PropManager.getInstance();
// /**
// * TIMEOUT CODE 로 변경됨
// * TIMEOUT_CODE : S : 30
// * TIMEOUT_CODE : M : 90
// * TIMEOUT_CODE : L : 180
// * TIMEOUT_CODE : X : 300
// * TIMEOUT_CODE : DEFAULT : S
// */
//// this.timeout = this.reqEaiMsg.getCurrentSvcMsg().getTmoVl() * 1000; //180 * 1000;
// String timeoutCode = this.reqEaiMsg.getCurrentSvcMsg().getTimeoutCode(); //S/M/L/X
// if (StringUtils.isEmpty(timeoutCode)){
// timeoutCode = propManager.getProperty("TIMEOUT_CODE", "DEFAULT" );
// }
// String timeoutCodeValue = propManager.getProperty("TIMEOUT_CODE", timeoutCode ); //실제 값
//
// int iTimeoutValue = 30;
// try{
// iTimeoutValue = Integer.parseInt(timeoutCodeValue);
// }catch(Exception e){
//
// }
// /**
// * TODO 20210826 타임아웃값 조정
// * MCI 일경우 전체 타임아웃에서 5초 추가
// * EAI 일경우 전체 타임아웃값
// * FEP 일경우 전체 타임아웃은 무의미
// */
// if (EAIServerManager.getInstance().isMCI()){
// iTimeoutValue += 5;
// }
//
// return iTimeoutValue;
// return this.reqEaiMsg.getCurrentSvcMsg().getTmoVl() * 1000;
StandardMessageManager standardManager = StandardMessageManager.getInstance();
return standardManager.getMessageCoordinator().coordinateForTimeoutCodeToValue(this.reqEaiMsg);
// return this.reqEaiMsg.getCurrentSvcMsg().getTmoVl();
}
public abstract void logSenderCtrlSendReq() throws Exception;
public abstract void logSenderCtrlSendRes() throws Exception;
public abstract void outboundCtrlCallService() throws Exception;
public abstract void outboundCtrlCallServiceAsync() throws Exception;
public abstract void transControlTransformSingleRes() throws Exception;
public abstract void transControlTransformSingleReq() throws Exception;
public abstract void printCallError(Exception e1) throws Exception;
public abstract void setRcvLogInfo() throws Exception;
public abstract void setTopicResult() throws Exception;
public abstract void checkResultMessage() throws Exception;
public abstract void checkSendResult() throws Exception;
public abstract void init() throws Exception;
public abstract void setSendMsg() throws Exception;
public abstract void getTopicProperty() throws Exception;
public abstract void performSend() throws Exception;
public abstract void performRecv() throws Exception;
public abstract void storeMessage() throws Exception;
public abstract void getBizMessage() throws Exception;
public abstract void waitCheckForSync() throws Exception;
public abstract void transControlHeaderTrnsformSinglesRes() throws Exception;
protected Object makeSubStandardMessageData(EAIMessage eaiMessage, String msgType, Object bizObject, String charset)
throws Exception {
StandardMessageManager standardManager = StandardMessageManager.getInstance();
StandardMessage standardMessage = eaiMessage.getStandardMessage();
String outboundAdapterGroupName = eaiMessage.getCurrentSvcMsg().getPsvSysItfTp();
AdapterGroupVO outboundAdapterGvo = AdapterManager.getInstance().getAdapterGroupVO(outboundAdapterGroupName);
standardMessage.setBizData(bizObject, outboundAdapterGvo.getMessageEncode());
StandardMessage subMessage = standardManager.getVersionMessage();
SubMessageManager subManager = SubMessageManager.getInstance();
String eaiSvcCode = eaiMessage.getEAISvcCd();
Map<String, String> subMap = subManager.getSubMessageMap(eaiSvcCode);
if (subMap != null) {
for (Map.Entry<String, String> entry : subMap.entrySet()) {
if (logger.isDebug()) {
logger.debug(String.format("DefaultProcess] SUBSTANDARD-MAPPING path: %s, value: %s",
entry.getKey(), entry.getValue()));
}
StandardItem sItem = subMessage.findItem(entry.getKey());
if (sItem != null) {
sItem.setValue(entry.getValue());
}
}
}
MessageMapper versionMapper = standardManager.getVersionMapper();
subMessage = versionMapper.convertToSub(standardMessage, subMessage);
subMessage.setBizDataCharset(charset);
eaiMessage.setSubMessage(subMessage);
if (logger.isDebug()) {
logger.debug(String.format("DefaultProcess] SUBSTANDARD-LOGGING SAVE UUID: %s, LOGSEQ: %s, HEADER: %s",
eaiMessage.getSvcOgNo(), this.logPssSno, subMessage.toFixedString(false)));
}
if (MessageType.JSON.equals(msgType)) {
return subMessage.toJson();
} else if (MessageType.XML.equals(msgType)) {
return subMessage.toXML();
} else if (MessageType.ASC.equals(msgType)) {
return subMessage.toByteArray(charset);
} else {
throw new Exception("Unsupported msgType - " + msgType);
}
}
protected EAIMessage convertToStandardMessage(EAIMessage eaiMessage, String msgType, Object message, String charset)
throws Exception {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessageManager standardManager = StandardMessageManager.getInstance();
MessageMapper versionMapper = standardManager.getVersionMapper();
StandardMessage orgStandardMessage = eaiMessage.getStandardMessage();
StandardMessage subMessage = versionMapper.parseSub(msgType, message);
subMessage.setBizDataCharset(charset);
eaiMessage.setSubMessage(subMessage);
if (logger.isDebug()) {
logger.debug(String.format("DefaultProcess] SUBSTANDARD-LOGGING SAVE UUID: %s, LOGSEQ: %s, HEADER: %s",
eaiMessage.getSvcOgNo(), this.logPssSno, subMessage.toFixedString(false)));
}
StandardMessage standardMessage = versionMapper.mapFromSub(subMessage, orgStandardMessage);
standardMessage.setBizDataCharset(charset);
standardManager.getMessageCoordinator().coordinateAfterParsing(standardMessage, null, new Properties());
eaiMessage.setStandardMessage(standardMessage);
mapper.setRecvTime(standardMessage, DatetimeUtil.getCurrentTimeMillis());
return eaiMessage;
}
}
@@ -0,0 +1,833 @@
package com.eactive.eai.outbound;
import java.net.SocketTimeoutException;
import java.util.Properties;
import com.eactive.eai.common.TransactionContextKeys;
import com.eactive.eai.util.PropertiesUtil;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
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.http.HttpStatusException;
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
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.server.EAIServerManager;
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.HttpSender;
import com.eactive.eai.control.LogSender;
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.eactive.eai.util.SimHeaderUtil;
import com.ext.eai.common.stdmessage.STDMessageKeys;
public class HTTPProcess extends DefaultProcess {
static final long serialVersionUID = 1L;
protected static final String TIMEOUT_ERROR = "RECEAIOHP003";
protected static final String STATUS_ERROR = "RECEAIOHP004";
protected final ObjectMapper objectMapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
public void outboundCtrlCallServiceAsync() throws Exception {
// async에서는 인터페이스 값을 설정하지 않고 Adapter의 타임아웃을 쓰기위해서 설정하지 않음
try {
this.tempProp.put(HttpClientAdapterServiceKey.LOG_PROCESS_NO, this.logPssSno);
this.resObject = HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp);
} catch (SocketTimeoutException ste) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = TIMEOUT_ERROR;
String rspErrorMsg = ExceptionUtil.make(ste, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, ste);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (HttpStatusException hse) {
String[] msgArgs = new String[2];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
msgArgs[1] = Integer.toString(hse.getStatus());
String rspErrorCode = STATUS_ERROR;
String rspErrorMsg = ExceptionUtil.make(hse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, hse);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
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 outboundCtrlCallService() throws Exception {
// 인터페이스에 셋팅된 타임아웃설정
int iTimeoutValue = getTimeoutCodeToValue();
this.timeout = iTimeoutValue * 1000;
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
try {
this.resObject = HttpSender.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 (SocketTimeoutException ste) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = TIMEOUT_ERROR;
String rspErrorMsg = ExceptionUtil.make(ste, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, ste);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (HttpStatusException hse) {
String[] msgArgs = new String[2];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
msgArgs[1] = Integer.toString(hse.getStatus());
String rspErrorCode = STATUS_ERROR;
String rspErrorMsg = ExceptionUtil.make(hse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, hse);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
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 logSenderCtrlSendRes() throws Exception {
try {
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void logSenderCtrlSendReq() throws Exception {
try {
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void transControlTransformSingleRes() throws Exception {
try {
this.srcTranObject = this.resObject;
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, false, this.diURI,
this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 300 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP030";
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) {
if (logger.isError())
logger.error(guidLogPrefix + " 200 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP020";
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];
if (TIMEOUT_ERROR.equals(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo()
+ "] 수동시스템 Timeout이 발생함 - Adapter 상태 변경하지 않음 ");
}
} else if (STATUS_ERROR.equals(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo()
+ "] 수동시스템 Response status가 200이 아님 - Adapter 상태 변경하지 않음 ");
}
} else {
AdapterManager manager = AdapterManager.getInstance();
AdapterVO vo = manager.getAdapterVO(this.adapterGroupName, this.adapterName);
if (vo != null) {
if (!StringUtils.isEmpty(vo.getTestCallClass())) {
vo.setStatus(false);
}
}
}
}
public void setRcvLogInfo() throws Exception {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp); // 300
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) SET
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 = "RECEAIOHP002";
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);
}
}
}
else {
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer()
&& com.eactive.eai.adapter.Keys.TESTMASTER_TAS.equals(adptGrpVO.getTestMasterYn())) {// 비표준 시뮬레이터
this.resObject = SimHeaderUtil.getSimData(this.resObject);
}
}
}
public void setTopicResult() throws Exception {
try {
this.jmsRespObject = future.value(this.timeout);
if (this.jmsRespObject == null) {
if (logger.isError())
logger.error(guidLogPrefix + "SYNC-ASYNC - HTTP setTopicResult jmsRespObject is null. timeout="
+ this.timeout);
throw new Exception("RECEAIOHP010");
}
resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP010";
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().getBizData();
} else if (this.jmsRespObject instanceof byte[]) {
this.resObject = (byte[]) this.jmsRespObject;
} else {
this.resObject = new byte[0];
}
}
public void checkResultMessage() throws Exception {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " SYNC - HTTP RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
public void checkSendResult() throws Exception {
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " ASYNC - HTTP RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
}
public void init() throws Exception {
this.prop = null;
this.adapterName = this.callProp.getProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME);
this.resEaiMsg = this.reqEaiMsg;
this.tempProp = new Properties();
// GW 전달 로직 추가
// tempProp로 넘겨서 하는 이유는 outboundProp가 clone 안하는 로직이라 outboundProp로 넘길시 문제의 소지가 있음
String transactionId = callProp.getProperty(HttpClientAdapterServiceKey.TRANSACTION_ID);
String instanceId = callProp.getProperty(HttpClientAdapterServiceKey.INSTANCE_ID);
if (StringUtils.isNotBlank(transactionId) && StringUtils.isNotBlank(instanceId)) {
this.tempProp.put(HttpClientAdapterServiceKey.TRANSACTION_ID, transactionId);
this.tempProp.put(HttpClientAdapterServiceKey.INSTANCE_ID, instanceId);
}
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp());
if (eaiServerManager.isTASEnabledEAIServer() && EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())
// RESTAdapter는 교체하지 않는다
&& !StringUtils.equals(adptGrpVO.getType(), com.eactive.eai.adapter.Keys.TYPE_REST)) {
PropManager manager = PropManager.getInstance();
Properties prop = manager.getProperties(RouteKeys.SIM);
if (reqEaiMsg.getCurrentSvcMsg().isSyncItfTp()) {
this.adapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_SYNC, "_SIM_OU_HTT_SyC");
} else {
this.adapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_ASYNC, "_SIM_OU_HTT_AsC");
}
this.reqEaiMsg.getSvcMsg(0).setPsvSysItfTp(this.adapterGroupName);
} else {
this.adapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
}
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);
}
// Inbound 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);
}
} else {
this.inAdapterMsgType = inAdptGrpVO.getMessageType();
}
}
public String getUrlSubString(String url, int length) {
try {
int start = 0;
if (url.startsWith("http://"))
start = 7;
if (url.length() > length + start) {
url = url.substring(start, length + start);
} else {
url = url.substring(start);
}
} catch (Exception ex) {
return "";
}
return url;
}
public void setSendMsg() throws Exception {
try {
// 200 로그를 위한 변환된 메시지부를 설정
this.reqEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.outboundCharset);
this.reqObject = this.tgtTranObject;
AdapterGroupVO adptGrpVO = null;
AdapterVO adptVO = null;
try {
AdapterManager adapterManager = AdapterManager.getInstance();
adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
if (adptGrpVO == null) {
String msg = String.format("AdapterGroup not found. - groupName %s adapterName %s", adapterGroupName);
logger.error(msg);
throw new Exception(msg);
}
if(StringUtils.isEmpty(this.adapterName)) {
adptVO = adptGrpVO.nextAdapterVO();
}
else {
adptVO = adptGrpVO.getAdapterVO(adapterName);
}
if (adptVO == null) {
String msg = String.format("Adapter not found. - groupName %s adapterName %s", adapterGroupName, adapterName);
logger.error(msg);
throw new Exception(msg);
}
this.tempProp.setProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME, adptVO.getName());
}
catch(Exception ex) {
String[] msgArgs = new String[1];
msgArgs[0] = String.valueOf(this.adapterGroupName);
String resMsg = ExceptionUtil.make("RECEAIOHP900", msgArgs);
throw new Exception(resMsg, ex);
}
try {
AdapterPropManager manager = AdapterPropManager.getInstance();
this.outboundProp = manager.getProperties(adptVO.getPropGroupName());// clone 안함으로 변경
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, this.adapterGroupName);
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
// MFC_FAILOVER : FAILOVER = Y 일 경우 무조건 2센터로 라우팅하도록 한다. (2020-08-27)
PropManager pmanager = PropManager.getInstance();
String mfcFailOver = pmanager.getProperty("MFC_FAILOVER", "FAILOVER");
if (mfcFailOver != null && "Y".equals(mfcFailOver.toUpperCase())) {
String url2grp = this.outboundProp.getProperty(HttpClientAdapterServiceKey.URL_2GRP);
if (logger.isInfo())
logger.info(guidLogPrefix + "MFC_FAILOVER URL_2GRP - " + url2grp);
if (url2grp != null && url2grp.trim().length() > 0) {
this.tempProp.setProperty(HttpClientAdapterServiceKey.URL, url2grp);
this.reqEaiMsg.getCurrentSvcMsg().setPsvSysSvcCd(getUrlSubString(url2grp, 20));
}
if (logger.isInfo())
logger.info(guidLogPrefix + "MFC_FAILOVER URL - "
+ this.tempProp.getProperty(HttpClientAdapterServiceKey.URL));
} else {
// 센터구분코드(2) 일 경우, URL_2GRP 로 URL 정보를 치환한다. (2020-07-23)
// DR일 경우에 대한 처리는 동일하게
// if (STDMessageKeys.CNTERDSTCD_DR.equals(extmessage.getTargetGroup())) {
// String url_2grp = this.outboundProp.getProperty(HttpClientAdapterServiceKey.URL_2GRP);
// if (logger.isInfo())
// logger.info(guidLogPrefix + "CNTERDSTCD URL_2GRP - " + url_2grp);
// if (url_2grp != null && url_2grp.trim().length() > 0) {
// this.tempProp.setProperty(HttpClientAdapterServiceKey.URL, url_2grp);
// this.reqEaiMsg.getCurrentSvcMsg().setPsvSysSvcCd(getUrlSubString(url_2grp, 20));
// }
// if (logger.isInfo())
// logger.info(guidLogPrefix + "CNTERDSTCD URL - "
// + this.tempProp.getProperty(HttpClientAdapterServiceKey.URL));
// }
}
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, TransactionContextKeys.TRANSACTION_UUID);
String svcName = getServiceId(this.reqEaiMsg);
if (svcName == null) {
svcName = "";
} else {
svcName = svcName.trim();
}
this.tempProp.setProperty(HttpClientAdapterServiceKey.TRAN_CODE, svcName);
if (logger.isInfo())
logger.info(guidLogPrefix + " HTTP NKESA svcName : " + svcName);
// FRST_DMND_SYS_IP_VAL 로 라우팅하도록 함
String operationEnv = getOperationEnv(this.reqEaiMsg);
if (com.eactive.eai.common.server.Keys.EAI_LOCAL.equals(operationEnv)
&& EAIServerManager.getInstance().isMCI()) {
String firstServiceIp = getFirstRequestSysIp(this.reqEaiMsg);
this.tempProp.setProperty(HttpClientAdapterServiceKey.LOCAL_CALL, HttpClientAdapterServiceKey.LOCAL_CALL_Y);
this.tempProp.setProperty(HttpClientAdapterServiceKey.LOCAL_IP, firstServiceIp);
if (logger.isInfo())
logger.info(guidLogPrefix + " HTTP NKESA LOCAL_CALL IP : " + firstServiceIp);
}
this.adptrMsgPtrnCd = adptGrpVO.getAdptrMsgPtrnCd();
this.adptrMsgType = adptGrpVO.getMessageType();
this.outboundProp.setProperty("MESSAGE_TYPE", this.adptrMsgType);
} catch (Exception e) {
throw new Exception("Target Adapter Fail (" + this.adapterGroupName + ") ", e);
}
// 하나캐피탈 POC 관련 추가
// 계정계 호출 url 표준헤더에서 가져와 셋팅
String targetUrl = this.callProp.getProperty("HTTP_URL");
if (StringUtils.isNotBlank(targetUrl)) {
this.outboundProp.setProperty("HTTP_URL", targetUrl);
}
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
// StandardMessage object -> message (FLAT|XML|JSON|?)
String restOption = this.reqEaiMsg.getCurrentSvcMsg().getRestOption();
setStandardRouteInfo(restOption);
this.reqObject = makeStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject, 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);
}
}
else {
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer()
&& EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())) {
this.reqObject = SimHeaderUtil.addSimHeader(reqEaiMsg.getEAISvcCd(), getInstCode(reqEaiMsg), reqObject);
if(logger.isDebug()) logger.debug(guidLogPrefix + " SIM LOG " + this.reqObject);
}
// 비표준 XML의 경우를 고려하여 XML Header의 유무를 확인
// 변환을 수행하고 결과가 비표준 XML일 경우에만
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getCnvEn())
&& MessageType.XML.equals(adptGrpVO.getMessageType())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " Add Xml Header Tag to NONSTANDARD XML Message");
}
if (this.reqObject instanceof String) {
String reqString = (String) this.reqObject;
if (!StringUtils.startsWith(reqString, "<?xml")) {
reqString = "<?xml version=\"1.0\" encoding=\"" + this.outboundCharset + "\"?>\n"
+ reqString;
this.reqObject = reqString;
}
}
}
if (logger.isDebug())
logger.debug(guidLogPrefix + " HTTP NONSTANDARD Request Message : "
+ MessageUtil.toAdapterTypeString(this.reqObject, this.inboundCharset));
}
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP022";
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 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);
// this.timeout = this.reqEaiMsg.getCurrentSvcMsg().getTmoVl() * 1000; //180 * 1000;
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 = "RECEAIOHP060";
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 = "RECEAIOHP060";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
}
public void performSend() 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_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.orgMessage"
+ 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 = "RECEAIOHP040";
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);
String bizData = this.resEaiMsg.getStandardMessage().getBizData();
if (bizData != null && bizData.length() > 0) {
this.tgtTranObject = bizData;
}
if (this.tgtTranObject instanceof byte[]) {
this.tgtTranObject = action.excute(this.orgData, (byte[]) this.tgtTranObject,
HeaderActionKeys.MESSAGE_RECV, headerContolType);
this.resEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.inboundCharset);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " this.tgtTranObject"
+ MessageUtil.toAdapterTypeString((byte[]) this.tgtTranObject, this.outboundCharset));
}
} 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 = "RECEAIOHP040";
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 getBizMessage() throws Exception {
}
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 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();
}
}
}
}
}
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
protected void setStandardRouteInfo(String routeOption) throws JsonProcessingException {
if(StringUtils.isBlank(routeOption)) {
return ;
}
JsonNode rootNode = 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);
});
}
}
}
@@ -0,0 +1,186 @@
package com.eactive.eai.outbound;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.message.EAIMessageKeys;
import com.eactive.eai.control.LogSender;
import com.eactive.eai.control.Transform;
import com.ext.eai.common.stdmessage.STDMessageKeys;
public class LoopBackProcess extends DefaultProcess {
static final long serialVersionUID = 1L;
public void flow() throws Exception {
if (!isRealCall()) {
return;
}
init();
// 송신전로그
logSenderCtrlSendReq();
// 송신변환
if (isSourceTransform()) {
// 수동메시지 변환 DI
transControlTransformSingleReq();
// 응답메시지설정
setTranMessage();
} else {
// 메시지 설정
setReturn();
}
setReturnType(this.resEaiMsg, STDMessageKeys.SEND_RECV_CD_RECV);
// 응답로그설정
logSenderCtrlSendRes();
clientReturn();
}
public void transControlTransformSingleReq() throws Exception {
this.srcTranObject = this.reqObject;
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getCnvMsgID();
try {
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, true, this.diURI, this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 200 변환오류");
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOSA020";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
// this.resEaiMsg.setRspErrCd(rspErrorCode);
// this.resEaiMsg.setRspErrMsg(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
}
}
public void init() throws Exception {
this.logPssSno = 200;
this.prop = null;
this.adapterName = null;
this.resEaiMsg = this.reqEaiMsg;
String bizData = this.reqEaiMsg.getStandardMessage().getBizData();
if (bizData != null && bizData.length() > 0) {
this.reqObject = bizData;
}
}
public boolean isSourceTransform() {
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getCnvEn())) {
return true;
} else {
return false;
}
}
public void setReturn() throws Exception {
if (logger.isDebug())
logger.debug(guidLogPrefix + " 변환룰이 적용되지 않았으므로 요청메시지를 리턴합니다.");
this.resEaiMsg.getStandardMessage().setBizData("response", this.inboundCharset);
}
public void setTranMessage() throws Exception {
if (logger.isDebug())
logger.debug(guidLogPrefix + " 변환룰이 적용되어 변환된 응답메시지를 리턴합니다.");
this.resEaiMsg.getStandardMessage().setBizData(resObject, this.inboundCharset);
}
@Override
public void logSenderCtrlSendReq() throws Exception {
try {
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
} catch (Exception e) {
if (logger.isWarn())
logger.warn(guidLogPrefix + " EAI 서비스코드[" + this.reqEaiMsg.getEAISvcCd() + "] 거래로그 중 오류발생");
}
}
@Override
public void logSenderCtrlSendRes() throws Exception {
this.logPssSno = 300;
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
}
@Override
public void outboundCtrlCallService() throws Exception {
}
@Override
public void outboundCtrlCallServiceAsync() throws Exception {
}
@Override
public void transControlTransformSingleRes() throws Exception {
}
@Override
public void printCallError(Exception e1) throws Exception {
}
@Override
public void setRcvLogInfo() throws Exception {
}
@Override
public void setTopicResult() throws Exception {
}
@Override
public void checkResultMessage() throws Exception {
}
@Override
public void checkSendResult() throws Exception {
}
@Override
public void setSendMsg() throws Exception {
}
@Override
public void getTopicProperty() throws Exception {
}
@Override
public void performSend() throws Exception {
}
@Override
public void performRecv() throws Exception {
}
@Override
public void storeMessage() throws Exception {
}
@Override
public void getBizMessage() throws Exception {
}
@Override
public void waitCheckForSync() throws Exception {
}
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
}
@@ -0,0 +1,248 @@
package com.eactive.eai.outbound;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import org.apache.commons.lang.StringUtils;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.message.EAIMessageKeys;
import com.eactive.eai.common.property.PropManager;
import com.eactive.eai.common.server.Keys;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.common.util.LogKeys;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.control.LogSender;
public class MessageLoggingProcess extends DefaultProcess {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
public int logSequence;
// public EAIMessage resEaiMsg;
// public EAIMessage reqEaiMsg;
// public java.util.Properties callProp;
// static final long serialVersionUID = 1L;
public static final String LOG_DIR = "MsgReceiveDir";
@Override
public void flow() throws Exception {
// WarmUp start
if (!isRealCall()) {
return;
}
// WarmUp end
// LogToFile
logToFile();
// Condition
if (isAsyncAsyncIF()) {
// SendEAILog
logSenderSend();
}
}
public EAIMessage clientReturn() {
return this.reqEaiMsg;
}
public void logSenderSend() throws Exception {
LogSender.send(this.logSequence, this.reqEaiMsg, this.callProp);
}
public boolean isAsyncAsyncIF() {
String svcTsmtUsgTP = reqEaiMsg.getSvcTsmtUsgTp();
String psvItfTp = reqEaiMsg.getCurrentSvcMsg().getPsvItfTp();
if (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTP) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)) {
return true;
} else {
return false;
}
}
public void logToFile() throws Exception {
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
if (logger.isDebug())
logger.debug("MessageLoggingProcess] executing logToFile method. ********************");
FileWriter fw = null;
BufferedWriter bw = null;
try {
String sLogDirectory = PropManager.getInstance().getProperty(LogKeys.LOGGER_INFO, LogKeys.LOG_DIRECOTRY_PREFIX);
String rootPath = null;
boolean pathExist = true;
if(StringUtils.isEmpty(sLogDirectory)) {
sLogDirectory = ".";
}
rootPath = sLogDirectory + File.separator + System.getProperty(Keys.SERVER_KEY) + File.separator + LOG_DIR;
File dir = new File(rootPath);
if (!dir.exists()) {
pathExist = dir.mkdir();
}
if(!pathExist) {
logger.warn("log directory create failed skip file logging - " + rootPath);
return;
}
String logFileName = DatetimeUtil.getCurrentTimeMillis() + "-" + this.reqEaiMsg.getSvcOgNo() + ".log";
File f = new File(dir, logFileName);
fw = new FileWriter(f);
bw = new BufferedWriter(fw);
String charset = this.callProp.getProperty(com.eactive.eai.adapter.Keys.CHARSET_KEY_IN, "MS949");
Object data = this.reqEaiMsg.getStandardMessage().getBizData();
if (data == null) {
bw.write("BizMsg is null.");
} else if (data instanceof byte[]) {
byte[] buff = (byte[]) data;
bw.write(new String(buff, charset));
} else if (data instanceof String) {
bw.write((String)data);
} else {
bw.write(data.toString());
}
bw.flush();
} catch (Exception e) {
logger.error("logToFile error", e);
throw e;
} finally {
this.logSequence = 400;
this.resEaiMsg = this.reqEaiMsg;
try {
if (bw != null)
bw.close();
} catch (Exception e) {
}
try {
if (fw != null)
fw.close();
} catch (Exception e) {
}
}
}
@Override
public void logSenderCtrlSendReq() throws Exception {
}
@Override
public void logSenderCtrlSendRes() throws Exception {
}
@Override
public void outboundCtrlCallService() throws Exception {
}
@Override
public void outboundCtrlCallServiceAsync() throws Exception {
}
@Override
public void transControlTransformSingleRes() throws Exception {
}
@Override
public void transControlTransformSingleReq() throws Exception {
}
@Override
public void printCallError(Exception e1) throws Exception {
}
@Override
public void setRcvLogInfo() throws Exception {
}
@Override
public void setTopicResult() throws Exception {
}
@Override
public void checkResultMessage() throws Exception {
}
@Override
public void checkSendResult() throws Exception {
}
@Override
public void init() throws Exception {
}
@Override
public void setSendMsg() throws Exception {
}
@Override
public void getTopicProperty() throws Exception {
}
@Override
public void performSend() throws Exception {
}
@Override
public void performRecv() throws Exception {
}
@Override
public void storeMessage() throws Exception {
}
@Override
public void getBizMessage() throws Exception {
}
@Override
public void waitCheckForSync() throws Exception {
}
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
}
@@ -0,0 +1,661 @@
package com.eactive.eai.outbound;
import java.net.SocketTimeoutException;
import java.util.Properties;
import com.eactive.eai.common.TransactionContextKeys;
import com.eactive.eai.common.circuitBreaker.CircuitBreakerManager;
import com.eactive.eai.message.StandardMessage;
import com.eactive.eai.util.PropertiesUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.initech.core.util.PropertiesManager;
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
import org.apache.commons.lang3.StringUtils;
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.http.HttpStatusException;
import com.eactive.eai.adapter.http.client.HttpClientAdapterServiceKey;
import com.eactive.eai.adapter.http.dynamic.HttpAdapterServiceKey;
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.server.EAIServerManager;
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.HttpSender;
import com.eactive.eai.control.LogSender;
import com.eactive.eai.control.Transform;
import com.eactive.eai.env.ElinkConfig;
import com.eactive.eai.inbound.processor.Processor;
import com.ext.eai.common.stdmessage.STDMessageKeys;
public class RESTProcess extends HTTPProcess {
static final long serialVersionUID = 1L;
public void outboundCtrlCallServiceAsync() throws Exception {
// async에서는 인터페이스 값을 설정하지 않고 Adapter의 타임아웃을 쓰기위해서 설정하지 않음
try {
this.tempProp.put(HttpClientAdapterServiceKey.LOG_PROCESS_NO, this.logPssSno);
this.resObject = HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject,
this.tempProp);
} catch (SocketTimeoutException ste) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = TIMEOUT_ERROR;
String rspErrorMsg = ExceptionUtil.make(ste, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, ste);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (HttpStatusException hse) {
String[] msgArgs = new String[2];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
msgArgs[1] = Integer.toString(hse.getStatus());
String rspErrorCode = STATUS_ERROR;
String rspErrorMsg = ExceptionUtil.make(hse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, hse);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
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 outboundCtrlCallService() throws Exception {
// 인터페이스에 셋팅된 타임아웃설정
int iTimeoutValue = getTimeoutCodeToValue();
this.timeout = iTimeoutValue * 1000;
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
String circuitBreakerUseYn = PropManager.getInstance().getProperty("CircuitBreaker", "useYn");
try {
if("Y".equals(circuitBreakerUseYn)){
String apiId = reqEaiMsg.getEAISvcCd();
CircuitBreaker circuitBreaker = CircuitBreakerManager.getInstance().getCircuitBreaker(apiId);
// ObjectMapper 인스턴스 생성
ObjectMapper objectMapper = new ObjectMapper();
// 서킷 브레이커의 메트릭 정보와 상태 정보를 직접 Node로 변환
ObjectNode combinedNode = objectMapper.createObjectNode();
combinedNode.put("state", circuitBreaker.getState().toString());
combinedNode.set("metrics", objectMapper.valueToTree(circuitBreaker.getMetrics()));
logger.info("CircuitBreaker state "+combinedNode.toString());
this.resObject = circuitBreaker.executeCallable(() -> HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp));
}else{
this.resObject = HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp);
}
this.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (SocketTimeoutException ste) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = TIMEOUT_ERROR;
String rspErrorMsg = ExceptionUtil.make(ste, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, ste);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (HttpStatusException hse) {
String[] msgArgs = new String[2];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
msgArgs[1] = Integer.toString(hse.getStatus());
String rspErrorCode = STATUS_ERROR;
String rspErrorMsg = ExceptionUtil.make(hse, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(guidLogPrefix + rspErrorMsg, hse);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP001";
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 logSenderCtrlSendRes() throws Exception {
try {
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void logSenderCtrlSendReq() throws Exception {
try {
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void transControlTransformSingleRes() throws Exception {
try {
this.srcTranObject = this.resObject;
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, false, this.diURI, this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 300 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP030";
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) {
if (logger.isError())
logger.error(guidLogPrefix + " 200 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP020";
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];
if (TIMEOUT_ERROR.equals(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo()
+ "] 수동시스템 Timeout이 발생함 - Adapter 상태 변경하지 않음 ");
}
} else if (STATUS_ERROR.equals(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo()
+ "] 수동시스템 Response status가 200이 아님 - Adapter 상태 변경하지 않음 ");
}
} else {
// REST 는 TEST Call을 할수 없음.20200813.최준호
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " UUID[" + this.reqEaiMsg.getSvcOgNo() + "] 수동시스템 오류 ");
}
}
}
public void setRcvLogInfo() throws Exception {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp); // 300
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().getBizData();
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP002";
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().getBizData();
} 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) {
throw new Exception("RECEAIOHP010");
}
resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP010";
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 init() throws Exception {
this.prop = null;
this.tempProp = new Properties();
this.adapterName = this.callProp.getProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME);
this.resEaiMsg = this.reqEaiMsg;
this.adapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
// DefaultProcess 이관시 누락된 부분 추가
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);
}
// Inbound Adapter mesageType
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO inAdptGrpVO = adapterManager.getAdapterGroupVO(this.reqEaiMsg.getSngSysItfTp());
this.inAdapterMsgType = MessageType.ASC;
if (inAdptGrpVO == null) {
if (logger.isWarn()) {
if (this.prop == null) {
logger.warn(guidLogPrefix + "Source Adapter is null, TAS Inbound ");
} else {
logger.warn(guidLogPrefix + "Source Adapter is null, TAS Inbound = "
+ this.prop.getProperty(Processor.TAS_ADAPTER_GROUP_NAME));
}
}
this.inAdapterMsgType = MessageType.ASC;
} else {
this.inAdapterMsgType = inAdptGrpVO.getMessageType();
}
}
public void setSendMsg() throws Exception {
try {
// 200 로그를 위한 변환된 메시지부를 설정
this.reqEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.outboundCharset);
if (this.tgtTranObject instanceof String) {
this.reqObject = (String) this.tgtTranObject;
} else {
throw new Exception("Invlid Transform output message (" + this.tgtTranObject + ")");
}
AdapterGroupVO adptGrpVO = null;
AdapterVO adptVO = null;
try {
AdapterManager adapterManager = AdapterManager.getInstance();
adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
if (adptGrpVO == null) {
String msg = String.format("AdapterGroup not found. - groupName %s adapterName %s", adapterGroupName);
logger.error(msg);
throw new Exception(msg);
}
if(StringUtils.isEmpty(this.adapterName)) {
adptVO = adptGrpVO.nextAdapterVO();
}
else {
adptVO = adptGrpVO.getAdapterVO(adapterName);
}
if (adptVO == null) {
String msg = String.format("Adapter not found. - groupName %s adapterName %s", adapterGroupName, adapterName);
logger.error(msg);
throw new Exception(msg);
}
this.tempProp.setProperty(com.eactive.eai.adapter.Keys.OUT_ADAPTER_NAME, adptVO.getName());
}
catch(Exception ex) {
String[] msgArgs = new String[1];
msgArgs[0] = String.valueOf(this.adapterGroupName);
String resMsg = ExceptionUtil.make("RECEAIOHP900", msgArgs);
throw new Exception(resMsg, ex);
}
String restOption = null;
try {
AdapterPropManager manager = AdapterPropManager.getInstance();
this.outboundProp = manager.getProperties(adptVO.getPropGroupName());// clone 안함으로 변경
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, this.adapterGroupName);
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
restOption = this.reqEaiMsg.getCurrentSvcMsg().getRestOption();
if (restOption != null) {
this.tempProp.setProperty(HttpClientAdapterServiceKey.REST_OPTION, restOption);
}
String toutval = String.valueOf(this.reqEaiMsg.getCurrentSvcMsg().getTmoVl());
if (StringUtils.isNotBlank(toutval)) {
this.tempProp.setProperty(HttpClientAdapterServiceKey.TOUTVAL, toutval);
}
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, TransactionContextKeys.TRANSACTION_UUID);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_HEADER);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_METHOD);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REWRITE_PATH);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_QUERY_STRING);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_PATH_VARIABLES);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_REMOTE_ADDR);
PropertiesUtil.copyPropertyIfPresent(this.callProp, this.tempProp, HttpAdapterServiceKey.INBOUND_SCHEME);
String svcName = getServiceId(this.reqEaiMsg);
if (svcName == null) {
svcName = "";
} else {
svcName = svcName.trim();
}
this.tempProp.setProperty(HttpClientAdapterServiceKey.TRAN_CODE, svcName);
this.adptrMsgPtrnCd = adptGrpVO.getAdptrMsgPtrnCd();
this.adptrMsgType = adptGrpVO.getMessageType();
this.outboundProp.setProperty("MESSAGE_TYPE", this.adptrMsgType);
} catch (Exception e) {
throw new Exception("Target Adapter Fail (" + this.adapterGroupName + ") ", e);
}
// 표준메시지 방식일 경우 KESA메시지에 업무메시지를 설정하여 전달한다.
// migration - boolean 값이 아니라 [S, N, C] 값을 가짐
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
setStandardRouteInfo(restOption);
this.reqObject = makeStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject, 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);
}
} else {
// 변환을 수행하고 결과가 비표준 XML일 경우에만
if (EAIMessageKeys.YES_FLAG.equals(this.reqEaiMsg.getCurrentSvcMsg().getCnvEn())
&& MessageType.XML.equals(adptGrpVO.getMessageType())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " Add Xml Header Tag to NONSTANDARD XML Message");
}
String reqString = (String) this.reqObject;
if (!StringUtils.startsWith(reqString, "<?xml")) {
reqString = "<?xml version=\"1.0\" encoding=\"" + this.outboundCharset + "\"?>\n" + reqString;
this.reqObject = reqString;
}
}
if (logger.isDebug())
logger.debug(guidLogPrefix + " HTTP NONSTANDARD Request Message : "
+ MessageUtil.toAdapterTypeString(this.reqObject, this.inboundCharset));
}
// TAS 선택시 시뮬레이터 url로 변경
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer() && EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())
&& StringUtils.equals(adptGrpVO.getType(), "RST")) {
PropManager manager = PropManager.getInstance();
Properties prop = manager.getProperties(RouteKeys.SIM);
String simAddr = prop.getProperty(RouteKeys.SIM_REST_MOCKSERVER);
if (StringUtils.isBlank(simAddr)) {
throw new Exception(String.format("Properties %s > %s not setted", RouteKeys.SIM,
RouteKeys.SIM_REST_MOCKSERVER));
}
String url = StringUtils.removeEnd(simAddr, "/") + "/mockapi/" + this.reqEaiMsg.getEAISvcCd();
this.outboundProp.put(HttpClientAdapterServiceKey.URL, url);
logger.debug("simUrl=" + url);
}
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP022";
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 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 = "RECEAIOHP060";
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 = "RECEAIOHP060";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
}
public void performSend() 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_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.orgMessage"
+ 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 = "RECEAIOHP040";
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);
String bizData = this.resEaiMsg.getStandardMessage().getBizData();
if (bizData != null && bizData.length() > 0) {
this.tgtTranObject = bizData;
}
if (this.tgtTranObject instanceof byte[]) {
this.tgtTranObject = action.excute(this.orgData, (byte[]) this.tgtTranObject,
HeaderActionKeys.MESSAGE_RECV, headerContolType);
this.resEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.inboundCharset);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " this.tgtTranObject"
+ MessageUtil.toAdapterTypeString((byte[]) this.tgtTranObject, this.outboundCharset));
}
} 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 = "RECEAIOHP040";
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 getBizMessage() throws Exception {
// setRcvLogInfo() 에서 이미 호출됨
}
public void storeMessage() throws Exception {
}
}
@@ -0,0 +1,687 @@
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;
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 {
/**
* async에서는 인터페이스 값을 설정하지 않고 Adapter의 타임아웃을 쓰기위해서 설정하지 않음
*/
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)) {
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();
}
}
}
}
}
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
}
@@ -0,0 +1,771 @@
package com.eactive.eai.outbound;
import java.util.Properties;
import org.apache.commons.lang3.StringUtils;
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.http.client.HttpClientAdapterServiceKey;
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.server.EAIServerManager;
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.Transform;
import com.eactive.eai.control.WebTSender;
import com.eactive.eai.env.ElinkConfig;
import com.eactive.eai.inbound.processor.Processor;
import com.eactive.eai.message.StandardMessage;
import com.eactive.eai.message.StandardMessageUtil;
import com.eactive.eai.message.manager.StandardMessageManager;
import com.eactive.eai.message.parser.StandardReader;
import com.eactive.eai.util.SimHeaderUtil;
import com.ext.eai.common.stdmessage.STDMessageKeys;
import tmax.webt.WebtIOException;
import tmax.webt.WebtServiceException;
import tmax.webt.WebtServiceFailException;
public class WebTProcess extends DefaultProcess {
static final long serialVersionUID = 1L;
protected static String prefix = "RECEAIOWP";
public void outboundCtrlCallServiceAsync() throws Exception {
// async에서는 인터페이스 값을 설정하지 않고 Adapter의 타임아웃을 쓰기위해서 설정하지 않음
try {
this.resObject = WebTSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, tempProp);
} catch (WebtIOException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "002";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (WebtServiceFailException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "003";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (WebtServiceException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "004";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "001";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Throwable t) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "001";
String rspErrorMsg = ExceptionUtil.make(t, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
}
}
public void outboundCtrlCallService() throws Exception {
// 인터페이스에 셋팅된 타임아웃설정
int iTimeoutValue = getTimeoutCodeToValue();
this.timeout = iTimeoutValue * 1000;
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
try {
this.resObject = WebTSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, tempProp);
// 응답코드에 대한 처리
this.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (WebtIOException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "002";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (WebtServiceFailException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "003";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (WebtServiceException e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "004";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "001";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
} catch (Throwable t) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = prefix + "001";
String rspErrorMsg = ExceptionUtil.make(t, rspErrorCode, msgArgs);
if (logger.isError())
logger.error(rspErrorMsg);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new RuntimeException(rspErrorCode);
}
}
public void logSenderCtrlSendRes() throws Exception {
try {
LogSender.send(this.logPssSno, this.resEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.resEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void logSenderCtrlSendReq() throws Exception {
try {
LogSender.send(this.logPssSno, this.reqEaiMsg, this.prop);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP021";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
if (logger.isWarn())
logger.warn(rspErrorMsg);
}
}
public void transControlTransformSingleRes() throws Exception {
try {
this.srcTranObject = this.resObject;
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, false, this.diURI, this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 300 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP030";
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 {
this.srcTranObject = StandardMessageUtil.getBizData(this.reqEaiMsg);
this.diURI = this.reqEaiMsg.getCurrentSvcMsg().getCnvMsgID();
this.tgtTranObject = Transform.transformSingle(this.guidLogPrefix, true, this.diURI, this.srcTranObject);
} catch (Exception e) {
if (logger.isError())
logger.error(guidLogPrefix + " 200 변환오류", e);
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP020";
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];
AdapterManager manager = AdapterManager.getInstance();
AdapterVO vo = manager.getAdapterVO(this.adapterGroupName, this.adapterName);
if (vo != null) {
if (!StringUtils.isEmpty(vo.getTestCallClass())) {
vo.setStatus(false);
}
}
}
public void setRcvLogInfo() throws Exception {
this.logPssSno = TranLogUtil.getResLogSeq(this.svcPssTp, this.svcPssSeq, this.isComp); // 300
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 = "RECEAIOHP002";
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);
}
}
} else {
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer()
&& com.eactive.eai.adapter.Keys.TESTMASTER_TAS.equals(adptGrpVO.getTestMasterYn())) {// 비표준 시뮬레이터
this.resObject = SimHeaderUtil.getSimData(this.resObject);
}
}
}
public void setTopicResult() throws Exception {
try {
this.jmsRespObject = future.value(this.timeout);
if (this.jmsRespObject == null) {
if (logger.isError())
logger.error(guidLogPrefix + "SYNC-ASYNC - HTTP setTopicResult jmsRespObject is null. timeout="
+ this.timeout);
throw new Exception("RECEAIOHP010");
}
resEaiMsg = setResponseForOutbound(this.resEaiMsg);
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP010";
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 (logger.isDebug()) {
logger.debug(guidLogPrefix + " SYNC - HTTP RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
public void checkSendResult() throws Exception {
if (MessageUtil.checkRspErrCd(this.resEaiMsg.getRspErrCd())) {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " ASYNC - HTTP RESPONSE MESSAGE : "
+ MessageUtil.toAdapterTypeString(this.resObject, this.outboundCharset));
}
}
}
public void init() throws Exception {
this.prop = null;
this.adapterName = null;
this.resEaiMsg = this.reqEaiMsg;
this.tempProp = new Properties();
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer() && EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())) {
PropManager manager = PropManager.getInstance();
Properties prop = manager.getProperties(RouteKeys.SIM);
if (reqEaiMsg.getCurrentSvcMsg().isSyncItfTp()) {
this.adapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_SYNC, "_SIM_OU_HTT_SyC");
} else {
this.adapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_ASYNC, "_SIM_OU_HTT_AsC");
}
this.reqEaiMsg.getSvcMsg(0).setPsvSysItfTp(this.adapterGroupName);
} else {
this.adapterGroupName = reqEaiMsg.getCurrentSvcMsg().getPsvSysItfTp();
}
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);
}
// Inbound Adapter mesageType
AdapterManager adapterManager = AdapterManager.getInstance();
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);
}
} else {
this.inAdapterMsgType = inAdptGrpVO.getMessageType();
}
}
public String getUrlSubString(String url, int length) {
try {
int start = 0;
if (url.startsWith("http://"))
start = 7;
if (url.length() > length + start) {
url = url.substring(start, length + start);
} else {
url = url.substring(start);
}
} catch (Exception ex) {
return "";
}
return url;
}
public void setSendMsg() throws Exception {
try {
AdapterGroupVO adptGrpVO = null;
try {
AdapterManager adapterManager = AdapterManager.getInstance();
adptGrpVO = adapterManager.getAdapterGroupVO(this.adapterGroupName);
if (adptGrpVO == null) {
throw new Exception("adapter group not found");
}
AdapterVO adptVO = adptGrpVO.nextAdapterVO();
if (adptVO == null) {
throw new Exception("adapter not found");
}
this.adapterName = adptVO.getName();
AdapterPropManager manager = AdapterPropManager.getInstance();
/**
* tempProp로 수정중
*/
this.outboundProp = (Properties) manager.getProperties(adptVO.getPropGroupName());// clone 안함으로 변경
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_GROUP_NAME, this.adapterGroupName);
this.tempProp.setProperty(HttpClientAdapterServiceKey.ADAPTER_NAME, adptVO.getName());
// MFC_FAILOVER : FAILOVER = Y 일 경우 무조건 2센터로 라우팅하도록 한다. (2020-08-27)
PropManager pmanager = PropManager.getInstance();
String mfcFailOver = pmanager.getProperty("MFC_FAILOVER", "FAILOVER");
if (mfcFailOver != null && "Y".equals(mfcFailOver.toUpperCase())) {
String url_2grp = this.outboundProp.getProperty(HttpClientAdapterServiceKey.URL_2GRP);
if (logger.isInfo())
logger.info(guidLogPrefix + "MFC_FAILOVER URL_2GRP - " + url_2grp);
if (url_2grp != null && url_2grp.trim().length() > 0) {
this.tempProp.setProperty(HttpClientAdapterServiceKey.URL, url_2grp);
this.reqEaiMsg.getCurrentSvcMsg().setPsvSysSvcCd(getUrlSubString(url_2grp, 20));
}
if (logger.isInfo())
logger.info(guidLogPrefix + "MFC_FAILOVER URL - "
+ this.tempProp.getProperty(HttpClientAdapterServiceKey.URL));
} else {
// 센터구분코드(2) 일 경우, URL_2GRP 로 URL 정보를 치환한다. (2020-07-23)
// DR일 경우에 대한 처리는 동일하게
// if(STDMessageKeys.CNTERDSTCD_DR.equals(extmessage.getTargetGroup()) ) {
// String url_2grp = this.outboundProp.getProperty(HttpClientAdapterServiceKey.URL_2GRP);
// if (logger.isInfo()) logger.info(guidLogPrefix + "CNTERDSTCD URL_2GRP - " + url_2grp );
// if(url_2grp != null && url_2grp.trim().length() > 0) {
// this.tempProp.setProperty(HttpClientAdapterServiceKey.URL, url_2grp);
// this.reqEaiMsg.getCurrentSvcMsg().setPsvSysSvcCd( getUrlSubString(url_2grp, 20) );
// }
// if (logger.isInfo()) logger.info(guidLogPrefix + "CNTERDSTCD URL - " + this.tempProp.getProperty(HttpClientAdapterServiceKey.URL) );
// }
}
String svcName = getServiceId(this.reqEaiMsg);
if (svcName == null) {
svcName = "";
} else {
svcName = svcName.trim();
}
this.tempProp.setProperty(HttpClientAdapterServiceKey.TRAN_CODE, svcName);
if (logger.isInfo())
logger.info(guidLogPrefix + " HTTP NKESA svcName : " + svcName);
// ENVR_INFO_DVSN_CD = L
// FRST_DMND_SYS_IP_VAL 로 라우팅하도록 함
String operationEnv = getOperationEnv(this.reqEaiMsg);
if (com.eactive.eai.common.server.Keys.EAI_LOCAL.equals(operationEnv)
&& EAIServerManager.getInstance().isMCI()) {
String firstServiceIp = getFirstRequestSysIp(this.reqEaiMsg);
this.tempProp.setProperty(HttpClientAdapterServiceKey.LOCAL_CALL,
HttpClientAdapterServiceKey.LOCAL_CALL_Y);
this.tempProp.setProperty(HttpClientAdapterServiceKey.LOCAL_IP, firstServiceIp);
if (logger.isInfo())
logger.info(guidLogPrefix + " HTTP NKESA LOCAL_CALL IP : " + firstServiceIp);
}
this.adptrMsgPtrnCd = adptGrpVO.getAdptrMsgPtrnCd();
this.adptrMsgType = adptGrpVO.getMessageType();
} catch (Exception e) {
throw new Exception("Target Adapter Fail (" + this.adapterGroupName + ") ");
}
// 200 로그를 위한 변환된 메시지부를 설정
this.reqEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.outboundCharset);
// 표준메시지 방식일 경우 KESA메시지에 업무메시지를 설정하여 전달한다.
// migration - boolean 값이 아니라 [S, N, C] 값을 가짐
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
this.reqObject = makeStandardMessageData(this.reqEaiMsg, this.adptrMsgType, this.reqObject,
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);
}
} else {
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if (eaiServerManager.isTASEnabledEAIServer()
&& EAIMessageKeys.TRANTYPE_TAS.equals(reqEaiMsg.getTranType())) {
this.reqObject = SimHeaderUtil.addSimHeader(reqEaiMsg.getEAISvcCd(), getInstCode(reqEaiMsg),
reqObject);
}
if (logger.isDebug())
logger.debug(guidLogPrefix + " HTTP NONSTANDARD Request Message : "
+ MessageUtil.toAdapterTypeString(this.reqObject, this.inboundCharset));
}
} catch (Exception e) {
String[] msgArgs = new String[1];
msgArgs[0] = this.reqEaiMsg.getEAISvcCd();
String rspErrorCode = "RECEAIOHP022";
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 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 = "RECEAIOHP060";
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 = "RECEAIOHP060";
String rspErrorMsg = ExceptionUtil.make(e, rspErrorCode, msgArgs);
this.resEaiMsg.setRspErr(rspErrorCode,rspErrorMsg);
throw new Exception(rspErrorMsg);
}
}
}
public void performSend() 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_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.orgMessage"
+ 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 = "RECEAIOHP040";
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);
String bizData = this.resEaiMsg.getStandardMessage().getBizData();
if (bizData != null && bizData.length() > 0) {
this.tgtTranObject = bizData;
}
if (this.tgtTranObject instanceof byte[]) {
this.tgtTranObject = action.excute(this.orgData, (byte[]) this.tgtTranObject,
HeaderActionKeys.MESSAGE_RECV, headerContolType);
this.resEaiMsg.getStandardMessage().setBizData(tgtTranObject, this.inboundCharset);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " this.tgtTranObject"
+ MessageUtil.toAdapterTypeString((byte[]) this.tgtTranObject, this.outboundCharset));
}
} 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 = "RECEAIOHP040";
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 getBizMessage() throws Exception {
}
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 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();
}
}
}
}
}
/**
* 출력 매체 부 매핑 작업 운영관리 > 환경정보 > 공통코드관리 > 프라퍼티 관리 STDMESSAGE >
* DATAHEADER_OTPT_TRANSFORM=true 일 때에만 변환 수행
*/
@SuppressWarnings("unchecked")
@Override
public void transControlHeaderTrnsformSinglesRes() throws Exception {
}
}
@@ -0,0 +1,35 @@
package com.eactive.eai.outbound.pool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class BidSendThreadPoolExecutor {
private static BidSendThreadPoolExecutor instance = new BidSendThreadPoolExecutor();
/**
* 기동 여부
*/
private boolean started;
private static ExecutorService executor = Executors.newFixedThreadPool(10);
/**
* 1. 기능 : Default Constructor
* 2. 처리 개요 :
* 3. 주의사항
**/
private BidSendThreadPoolExecutor() {
}
public static BidSendThreadPoolExecutor getInstance() {
return instance;
}
public ExecutorService getExecutor(){
return executor;
}
public static void destroy(){
instance = null;
executor.shutdownNow();
}
}