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,36 @@
package com.eactive.eai.common.routing;
import com.eactive.eai.common.message.EAIMessage;
import java.util.Properties;
/**
* 1. 기능 : FC 와 Outbound Process를 호출하기 위한 JPD Proxy Interface Class
* 2. 처리 개요 :
* * -
* 3. 주의사항
*
* @author : DongHoon Lee
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public interface ElinkESBProcess
{
/**
* 1. 기능 : Process의 호출 메소드
* 2. 처리 개요 :
* - Process의 호출 메소드가 변경된 경우 재정의 해야함.
* 3. 주의사항
*
* @param message
* @param callProp
* @return EAIMessage
* @exception JpdProxyException
**/
public abstract EAIMessage callService(EAIMessage message, Properties callProp);
public static final String SERVICE_URI = "com.eactive.eai.flowcontroller.BaseFCProcess";
}
@@ -0,0 +1,74 @@
package com.eactive.eai.common.routing;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.util.Logger;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
/**
* 1. 기능 : ElinkESBProcess를 호출하는 공통 Class
* 2. 처리 개요 :
* * -
* 3. 주의사항
*
* @author : DongHoon Lee
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public class ElinkESBProcessProxy
{
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
public static String PROXY_ERROR_CODE = "RECEAICPR001";
private static ConcurrentHashMap<String, Class> classLocalCache = new ConcurrentHashMap<String, Class>();
/**
* 1. 기능 : ElinkESBProcess의 호출 메소드(Local|Remote 방식)
* 2. 처리 개요 :
* -
* 3. 주의사항
*
* @param serviceURI Route하기 위한 Process의 URI
* @param eaiMessage EAIMessage Object
* @param isLocal Local Process 호출인지 Remote Process 호출인지 여부
* @param prop Remote Process호출인 경우 (RouteKeys.WLI_URL, RouteKeys.WLI_USER,RouteKeys.WLI_PWD)를 설정
* @return 결과 EAIMessage
* @exception
**/
public static EAIMessage callElinkESBProcess(String serviceURI, EAIMessage eaiMessage, boolean isLocal, Properties prop) throws Exception
{
EAIMessage retMsg = null;
try {
if (isLocal){
Class cl = classLocalCache.get(serviceURI);
if(cl == null) {
cl = Class.forName(serviceURI);
classLocalCache.put(serviceURI, cl);
}
Process proc = (Process)cl.newInstance();
proc.callService(eaiMessage, prop);
retMsg = proc.clientReturn();
}else{
if(eaiMessage == null) {
throw new Exception("EAIMessage is null");
}
else {
retMsg = RemoteProxyClient.callProxyBean(eaiMessage, prop);
}
}
} catch( ClassNotFoundException e) {
if (logger.isError()) logger.error("ElinkProcessProxy] callElinkESBProcess["+serviceURI+"] Class Not Found Exception : ");
throw new Exception(PROXY_ERROR_CODE);
} catch( Exception e) {
if (logger.isError()) logger.error("ElinkProcessProxy] callElinkESBProcess["+serviceURI+"] Exception : "+e.getMessage(),e);
throw new Exception(PROXY_ERROR_CODE);
}
return retMsg;
}
}
@@ -0,0 +1,31 @@
package com.eactive.eai.common.routing;
/**
* 1. 기능 : Outbound Process에서 Transform Process 를 호출하기 위한 JPD Proxy Interface Class
* 2. 처리 개요 :
* * -
* 3. 주의사항
*
* @author : DongHoon Lee
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public interface ElinkESBTransformProcess
{
/**
* 1. 기능 : Transform Process의 호출 메소드
* 2. 처리 개요 :
* - Transform Process의 호출 메소드가 변경된 경우 재정의 해야함.
* 3. 주의사항
*
* @param java.io.Serializable
* @return java.io.Serializable
* @exception
**/
public abstract java.io.Serializable transform(java.io.Serializable object);
public static final String SERVICE_URI = "com.eactive.eai.transform.HostOpenDeposit200";
}
@@ -0,0 +1,51 @@
package com.eactive.eai.common.routing;
import com.eactive.eai.common.util.Logger;
/**
* 1. 기능 : KBESBProcess를 호출하는 공통 Class
* 2. 처리 개요 :
* * -
* 3. 주의사항
*
* @author : DongHoon Lee
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public class ElinkESBTransformProcessProxy
{
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
public static String TRANPROXY_ERROR_CODE = "RECEAICPR100";
/**
* 1. 기능 : KBESBProcess의 호출 메소드(Local|Remote 방식)
* 2. 처리 개요 :
* -
* 3. 주의사항
*
* @param serviceURI Route하기 위한 Process의 URI
* @param eaiMessage EAIMessage Object
* @param isLocal Local Process 호출인지 Remote Process 호출인지 여부
* @param prop Remote Process호출인 경우 (RouteKeys.WLI_URL, RouteKeys.WLI_USER,RouteKeys.WLI_PWD)를 설정
* @return 결과 EAIMessage
* @exception
**/
public static java.io.Serializable transform(String serviceURI, java.io.Serializable object) throws Exception
{
java.io.Serializable converted = null;
try {
// KBESBTransformProcess proc = null;
// proc = (KBESBTransformProcess)JpdProxy.create(KBESBTransformProcess.class, serviceURI);
//
// converted = proc.transform(object);
} catch( Exception e) {
if (logger.isError()) logger.error("KBESBTransformProcessProxy] transform["+serviceURI+"] Exception ", e);
throw new Exception(TRANPROXY_ERROR_CODE);
}
return converted;
}
}
@@ -0,0 +1,186 @@
package com.eactive.eai.common.routing;
import java.util.Properties;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.property.PropManager;
import com.eactive.eai.common.server.EAIServerManager;
import com.eactive.eai.common.server.Keys;
import com.eactive.eai.common.session.SessionManager;
import com.eactive.eai.common.util.JMSSender;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.env.ElinkConfig;
import com.ext.eai.common.stdmessage.STDMessageKeys;
/**
* 1. 기능 : Inbound Layer에서 FlowControl로 라우팅하는 기능을 제공
* 2. 처리 개요 :
* - Inbound Layer에서 정의한 pProperties를 통해 전달한 값을 기반으로
* FlowControl로 JMS Queue/JMS Topic/DirectCall 방식으로 EAIMessage를 전달한다.
* 3. 주의사항
*
* @author :
* @version : v 1.0.0
* @see :
* @since :
* :
*/
public class FlowRouter
{
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
public static final String FRROUTER_ERROR_INVALID = "RECEAICFR000"; // Routing Info 오류
public static final String FRROUTER_ERROR_JPD = "RECEAICFR001"; // 호출 오류
public static final String FRROUTER_ERROR_QUEUE = "RECEAICFR002"; // FC Async Queue 메시지 송신 오류
public static final String FRROUTER_ERROR_TOPIC = "RECEAICFR003"; // SA 패턴의 응답메시지 전송 오류
private static String instPostfix = "";
static {
String serverName = System.getProperty(Keys.SERVER_KEY);
if(serverName != null && serverName.length() > 2) {
instPostfix = "_" + EAIServerManager.getInstance().getInstId();
}
}
/**
* 1. 기능 : Inbound Layer에서 FlowControl로 라우팅하는 기능을 제공
* 2. 처리 개요 :
* - Inbound Layer에서 정의한 Properties를 통해 전달한 값을 기반으로
* FlowControl로 JMS Queue/JMS Topic/JPDProxy 방식으로 EAIMessage를 전달한다.
* 3. 주의사항
*
* @param eaiMessage Inbound에서 생성한 EAI표준메시지
* @param prop 라우팅을 위한 환경값
* @return EAIMessage FlowControl로부터 처리된 결과가 리턴됨
* @exception
**/
public static EAIMessage process(EAIMessage eaiMessage, Properties prop) throws Exception {
RoutingVO routingVO = RoutingManager.getInstance().getRoutingVO(eaiMessage.getFlwCntlRtnNm());
EAIMessage rtnMsg = null;
String route_type = prop.getProperty(RouteKeys.ROUTING_TYPE);
// String guidLogPrefix = "FlowRouter] GUID["+eaiMessage.getKbMsg().getKBHeader().getGuIdNo()+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
String guidLogPrefix = "FlowRouter] GUID["+eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage())+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
if(RouteKeys.ROUT_CALL.equals(route_type)) {
String serviceURI = routingVO.getSyncRoutingPath();
boolean isLocal = true;
try {
rtnMsg = ElinkESBProcessProxy.callElinkESBProcess(serviceURI, eaiMessage, isLocal, prop);
} catch(Exception e) {
if (logger.isError()) logger.error(guidLogPrefix + " process.JPD Error. JPD Name ["+serviceURI+"]- " + e.getMessage(), e);
//throw new Exception(FRROUTER_ERROR_JPD);
throw new Exception(ExceptionUtil.getErrorCode(e,FRROUTER_ERROR_JPD));
}
}
else if(RouteKeys.ROUT_QUEUE.equals(route_type)) {
// send Queue
PropManager propManager = PropManager.getInstance();
String queueConFactory = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_QUEUE_CONNECTION_FACTORY);
//--------------------------------------------------------------------------
// 요청거래와 응답거래의 QUEUE를 분리한다 : 2008.10.29
//--------------------------------------------------------------------------
// String telgmDmndDstcd = eaiMessage.getKbMsg().getKBHeader().getTelgmDmndDstcd();
// String telgmDmndDstcd = eaiMessage.getExtMsg().getSendRecv();
String telgmDmndDstcd = eaiMessage.getMapper().getSendRecvDivision(eaiMessage.getStandardMessage()); // S|R
String routeQueueName = "";
routeQueueName = routingVO.getAsynRoutingPath();
// 새로 설정한 Queue로 RoutingPath가 정의된 경우
// 룰 설정이 안된 경우 - 20081111
if(routeQueueName == null || routeQueueName.trim().length() == 0) {
routeQueueName = "FlowRouterQueue";
}
else if(routeQueueName.startsWith("com.elink.eai.common")) {
if( STDMessageKeys.SEND_RECV_CD_SEND.equals(telgmDmndDstcd)) {
routeQueueName = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_QUEUE);
}
else {
routeQueueName = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_RESQUEUE);
}
}
else {
// 2009.12.22
// 다른 인스턴스로 송신하는 부분을 막는다.
// TODO : 적용여부 확인 필요
// routeQueueName = routeQueueName + instPostfix;
// Local Queue 방식으로 수정함
if (logger.isDebug()) {
logger.debug(guidLogPrefix + "RoutingPath Async Queue Name - " + routeQueueName);
}
}
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " telgmDmndDstcd[" + telgmDmndDstcd + "] = Async Queue Name - " + routeQueueName);
}
try {
//--------------------------------------------------------
// 2009.03.30 - Queue 분리관련 추가 로직
// EAI 업무그룹코드와 EAI 서비스코드, 표준의 대외기관코드 를 설정
//--------------------------------------------------------
prop.setProperty("EAIBWKCLS", eaiMessage.getBwkCls().trim());
prop.setProperty("EAISVCCD", eaiMessage.getEAISvcCd().trim());
// prop.setProperty("OSIDINSTCD", eaiMessage.getKbMsg().getKBCommon().getOsidInstiCd().trim());
// prop.setProperty("OSIDINSTCD", eaiMessage.getExtMsg().getInstitutionCode().trim());
prop.setProperty("OSIDINSTCD", eaiMessage.getMapper().getInstCode(eaiMessage.getStandardMessage()).trim());
//--------------------------------------------------------
}
catch(Exception ex) {
if (logger.isWarn()) logger.debug(guidLogPrefix + "JMS Property set Error - " + ex.getMessage());
}
try {
JMSSender.sendToQueue(eaiMessage, queueConFactory, routeQueueName, prop);
} catch(Exception e) {
if (logger.isError()) logger.error(guidLogPrefix +" process.Queue Error. Queue Name[" + routeQueueName + "]- " + e.getMessage(), e);
//throw new Exception(FRROUTER_ERROR_QUEUE);
throw new Exception(ExceptionUtil.getErrorCode(e,FRROUTER_ERROR_QUEUE));
}
}
else if(RouteKeys.ROUT_TOPIC.equals(route_type)) {
// send Topic
String traceKey = prop.getProperty(RouteKeys.TRACE_KEY);
PropManager propManager = PropManager.getInstance();
String topicConFactory = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_TOPIC_CONNECTION_FACTORY);
String routeTopicName = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_TOPIC);
String sTTL = propManager.getProperty(RouteKeys.GROUP_NAME, RouteKeys.ROUTING_TOPIC_TTL);
long ttl = 60000; // Default Set 60secs
try {
if(sTTL != null && sTTL.length() > 0) {
ttl = Long.parseLong(sTTL);
}
}
catch(Exception e) {
if (logger.isDebug()) logger.debug(guidLogPrefix + " TTL Not Set - "
+ RouteKeys.ROUTING_TOPIC_TTL + ":"+ e.getMessage());
}
try {
if (ElinkConfig.isUseCacheTopic()) {
SessionManager.getInstance().putTopic(traceKey, eaiMessage);
}
else {
JMSSender.sendToTopic(eaiMessage, topicConFactory, routeTopicName, null, traceKey, ttl);
}
} catch(Exception e) {
if (logger.isError()) logger.error(guidLogPrefix + " process.Topic Error. Topic Name ["+routeTopicName+"]- " + e.getMessage(), e);
//throw new Exception(FRROUTER_ERROR_TOPIC);
throw new Exception(ExceptionUtil.getErrorCode(e,FRROUTER_ERROR_TOPIC));
}
}
else {
if (logger.isError()) logger.error(guidLogPrefix + " Invalid ROUTING INFO TYPE[" + route_type + "]");
throw new Exception( FRROUTER_ERROR_INVALID );
}
return rtnMsg;
}
}
@@ -0,0 +1,137 @@
package com.eactive.eai.common.routing;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.server.RMISocketFactory;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.time.StopWatch;
import org.springframework.remoting.RemoteConnectFailureException;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
import com.eactive.eai.common.property.PropManager;
import com.eactive.eai.common.routing.rmi.GWRemoteProxy;
import com.eactive.eai.common.routing.rmi.TimeoutRmiClientSocketFactory;
import com.eactive.eai.common.util.Logger;
public class GWRemoteProxyClient {
static Logger logger = Logger.getLogger(Logger.LOGGER_SIFT);
private static String SERVICE_URL = "%s/RemoteProxy"; // rmi://%s:1099
private static ConcurrentHashMap<String, RmiProxyFactoryBean> factoryMap = new ConcurrentHashMap<String, RmiProxyFactoryBean>();
private static RmiProxyFactoryBean getFactory(String remoteUrl) {
RmiProxyFactoryBean factory = factoryMap.get(remoteUrl);
return factory;
}
private synchronized static RmiProxyFactoryBean initFactory(String remoteUrl, int connectTimeout, int timeout) {
RmiProxyFactoryBean factory = factoryMap.get(remoteUrl);
if(factory != null) return factory;
factory = new RmiProxyFactoryBean();
factory.setServiceInterface(GWRemoteProxy.class);
factory.setServiceUrl(String.format(SERVICE_URL, remoteUrl));
TimeoutRmiClientSocketFactory registryClientSocketFactory = new TimeoutRmiClientSocketFactory();
try {
RMISocketFactory f = RMISocketFactory.getSocketFactory();
if(f == null) {
RMISocketFactory.setSocketFactory(new RMISocketFactory() {
public Socket createSocket(String host, int port) throws IOException {
int timeout = 120 *1000; // 타임아웃을 기본 120초로 설정
Socket socket = new Socket(host, port);
socket.setSoTimeout(timeout);
socket.setSoLinger(false, 0);
// System.out.println("RMISocketFactory timeout >> " + timeout);
return socket;
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
}
);
}
else {
logger.warn("initFactory RMISocketFactory already defined : " + f.toString());
}
registryClientSocketFactory.setConnectTimeout(connectTimeout);
registryClientSocketFactory.setTimeout(timeout);
factory.setRegistryClientSocketFactory(registryClientSocketFactory);
factory.setRefreshStubOnConnectFailure(true);
factory.afterPropertiesSet();
factoryMap.put(remoteUrl, factory);
return factory;
} catch (Exception e) {
logger.error("initFactory Exception - " + remoteUrl, e);
return null;
}
}
public static Object callProxyBean(Object message, Properties prop) throws Exception {
Object response = null;
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String remoteUrl = prop.getProperty(RouteKeys.REMOTE_CALL_URL);
Properties properties = PropManager.getInstance().getProperties(RouteKeys.REMOTE_CALL);
String connectionTimeout = properties.getProperty(RouteKeys.REMOTE_CALL_CONNECTION_TIMEOUT ,"1000");
// String readTimeoutAsync = properties.getProperty(RouteKeys.REMOTE_CALL_READ_TIMEOUT_ASYNC ,"4000");
// String readTimeoutSync = properties.getProperty(RouteKeys.REMOTE_CALL_READ_TIMEOUT_SYNC ,"60000");
int connectTimeout = Integer.parseInt(connectionTimeout);
int timeout = 2000;
if(logger.isDebug()) {
logger.debug("GWRemoteProxyClient] remoteUrl - " + remoteUrl);
logger.debug("GWRemoteProxyClient] connectionTimeout - " + connectionTimeout);
}
// if( EAIMessageKeys.ASYNC_SVC.equals(psvItfTp) ) {
// timeout = Integer.parseInt(readTimeoutAsync);
// }
// else {
// timeout = Integer.parseInt(readTimeoutSync);
// }
RmiProxyFactoryBean factory = null;
try {
if(logger.isDebug()) {
logger.debug("GWRemoteProxyClient] Get RemoteProxy/call Service");
}
if(remoteUrl == null) {
throw new Exception("remoteUrl is NULL");
}
factory = getFactory(remoteUrl);
if(factory == null) {
factory = initFactory(remoteUrl, connectTimeout, timeout);
if(factory == null) {
logger.error("GWRemoteProxyClient] initFactory Error : " + remoteUrl);
}
}
GWRemoteProxy service = (GWRemoteProxy) factory.getObject();
response = service.callService(message, prop);
} catch(RemoteConnectFailureException ie) {
logger.warn("GWRemoteProxyClient] Reset RMI Factory : "+ ie.getMessage());
factory = initFactory(remoteUrl, connectTimeout, timeout);
GWRemoteProxy service = (GWRemoteProxy) factory.getObject();
response = service.callService(message, prop);
} catch(Exception e) {
logger.error("GWRemoteProxyClient] Get RemoteProxy/call Service Error : "+ e.getMessage(),e);
throw e;
} catch(Throwable t) {
logger.error("GWRemoteProxyClient] Get RemoteProxy/call Service Error : "+ t.getMessage(),t);
throw new Exception("GWRemoteProxyClient] Get RemoteProxy/call Service Error : "+ t.getMessage());
} finally{
}
stopWatch.stop();
return response;
}
}
@@ -0,0 +1,262 @@
package com.eactive.eai.common.routing;
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.AdapterVO;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.message.EAIMessageKeys;
import com.eactive.eai.common.message.ServiceMessage;
import com.eactive.eai.common.property.PropManager;
import com.eactive.eai.common.server.EAIServerManager;
import com.eactive.eai.common.server.EAIServerVO;
import com.eactive.eai.common.server.Keys;
import com.eactive.eai.common.util.Logger;
/**
* 1. 기능 : Flow Control에서 Outbound 를 호출하기 위한 Router
* 2. 처리 개요 :
* * - FlowControl에서 Outbound 를 호출한다.
* 3. 주의사항
*
* @author :
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public class IFRouter
{
public static final String IFROUTER_ERROR_LOCAL = "RECEAICIR001"; // Local JPD 호출 오류
public static final String IFROUTER_ERROR_LOCK = "RECEAICIR002"; // Error발생하여 Failover가 불가능함(FailOver Flag=false)
public static final String IFROUTER_ERROR_REMOTE = "RECEAICIR003"; // FailOver증 JPD 호출 오류
public static final String IFROUTER_INVALID_ROUT = "RECEAICIR099"; // Outbound 이외의 Process를 호출하고록 설정된 경우
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
/**
* 1. 기능 : FlowCOntrol에서 Outbound Process로 라우팅하는 기능을 제공
* 2. 처리 개요 :
* - FlowControl에서 전달받은 EAIMessage의 Routing명을 통해 JPDProxy 방식으로 EAIMessage를 전달한다.
* 3. 주의사항
*
* @param eaiMessage Inbound에서 생성한 EAI표준메시지
* @param callProp 라우팅을 위한 환경값(추가적으로 보낼 인자가 있을 경우 사용)
* @return EAIMessage Outbound Process로부터 처리된 결과가 리턴됨
* @exception
**/
public static EAIMessage process(EAIMessage eaiMessage, Properties callProp) throws Exception {
ServiceMessage service = ((ServiceMessage)eaiMessage.getSvcMsgs().get( eaiMessage.getSvcPssSeq() - 1 ));
String routingName = service.getOutbRtnNm();
boolean isLocal = true; // EAIMessage내의 수동시스템인터페이스유형(AdapterGroupName)
// String guidLogPrefix = "IFRouter] GUID["+eaiMessage.getKbMsg().getKBHeader().getGuIdNo()+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
String guidLogPrefix = "IFRouter] GUID["+eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage())+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
// TAS 거래는 Local Call 로 처리하도록 한다. (2019.03.04)
EAIServerManager eaiServerManager = EAIServerManager.getInstance();
if(eaiServerManager.isTASEnabledEAIServer()) {
AdapterManager adapterManager = AdapterManager.getInstance();
AdapterGroupVO adptGrpVO = adapterManager.getAdapterGroupVO(service.getPsvSysItfTp());
if( EAIMessageKeys.TRANTYPE_TAS.equals(eaiMessage.getTranType())
// RESTAdapter는 교체하지 않는다
&& !StringUtils.equals(adptGrpVO.getType(), "RST")) {
// isLocal = true;
// if (logger.isInfo()) logger.info(guidLogPrefix + " TRANTYPE TAS [" + eaiMessage.getTranType() + "]");
PropManager manager = PropManager.getInstance();
Properties prop = manager.getProperties(RouteKeys.SIM);
routingName = prop.getProperty(RouteKeys.SIM_ROUTING,"HTTPOUT");
String simAdapterGroupName ="";
if (service.isSyncItfTp()){
simAdapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_SYNC,"_SIM_OU_HTT_SyC");
}else{
simAdapterGroupName = prop.getProperty(RouteKeys.SIM_ADAPTER_ASYNC,"_SIM_OU_HTT_AsC");
}
isLocal = isAlive(simAdapterGroupName);
}
else if( EAIMessageKeys.TRANTYPE_DUMMYROUT.equals(eaiMessage.getTranType()) ) {
isLocal = false;
if (logger.isInfo()) logger.info(guidLogPrefix + " TRANTYPE_DUMMYROUT [" + eaiMessage.getTranType() + "] Route to Other Domain - Local ["+System.getProperty(Keys.EAI_SYSTEMMODE)+"]");
}
else {
isLocal= isAlive( service.getPsvSysItfTp()); // EAIMessage내의 수동시스템인터페이스유형(AdapterGroupName)
}
}
else {
isLocal = isAlive( service.getPsvSysItfTp()); // EAIMessage내의 수동시스템인터페이스유형(AdapterGroupName)
}
RoutingVO routingUrl = RoutingManager.getInstance().getRoutingVO( routingName );
if (logger.isInfo()) {
logger.info(guidLogPrefix + "ROUTING NAME [" + routingName + "]");
logger.info(guidLogPrefix + "ROUTING URI [" + routingUrl + "]");
logger.info(guidLogPrefix + "TRANTYPE [" + eaiMessage.getTranType() + "]");
logger.info(guidLogPrefix + "isLocal [" + isLocal + "]");
}
//-----------------------------------------------------
// IFRouter에서는 Outbound Process만 호출할 수 있도록 체크(무한 Loop방지)
// 2006.02.24 - DHLEE
//-----------------------------------------------------
if(! "O".equals(routingUrl.getLayerDstcd()) ) {
throw new Exception(IFROUTER_INVALID_ROUT);
}
EAIMessage message = null;
if ( eaiMessage.getSvcPssTp().equals( EAIMessage.SINGLE_PROCESS )
|| eaiMessage.getSvcPssTp().equals( EAIMessage.COMPLEX_PROCESS ) ) {
// 단일 수동인터페이스 또는 복합거래 유형인 경우
if(!eaiServerManager.isPEAIServer() && EAIMessageKeys.TRANTYPE_DUMMYROUT.equals(eaiMessage.getTranType()) ) {
StringBuffer urlBuf = new StringBuffer();
EAIServerManager mgr = EAIServerManager.getInstance();
EAIServerVO server = mgr.getEAIServer( mgr.getLocalServerName());
// get Routing server info
PropManager propManager = PropManager.getInstance();
String remote_url = propManager.getProperty(RouteKeys.DUMMY_ROUTE_INFO, server.getName());
if(logger.isWarn()) {
logger.warn(guidLogPrefix + " : DUMMY ROUTE CALL - EAISvcCd="+ eaiMessage.getEAISvcCd()
+", remote_url : " +remote_url);
}
if(remote_url == null) {
String errorMsg = " Dummy Route info not found : Property Group[" + RouteKeys.DUMMY_ROUTE_INFO + "] Property["+server.getName()+"}";
logger.error(guidLogPrefix + errorMsg);
throw new Exception(errorMsg);
}
urlBuf.append( EAIServerVO.IIOP_PROTOCOL ).append("://");
urlBuf.append( remote_url );
callProp.setProperty( RouteKeys.REMOTE_CALL_URL, urlBuf.toString() );
if (logger.isInfo()) {
logger.info(guidLogPrefix + " DummyRoute Remote Call [" + urlBuf.toString() + "] RemoteProxyClient");
}
try {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " DummyRoute RemoteProxyClient call");
}
message = RemoteProxyClient.callProxyBean(eaiMessage, callProp);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " DummyRoute RemoteProxyClient result : "+message);
}
} catch(Exception e) {
logger.error(guidLogPrefix + " DummyRoute Remote Call Error", e);
//throw new Exception(IFROUTER_ERROR_REMOTE);
throw new Exception(ExceptionUtil.getErrorCode(e,IFROUTER_ERROR_REMOTE));
}
}
else if ( isLocal ) {
try {
message = ElinkESBProcessProxy.callElinkESBProcess( routingUrl.getSyncRoutingPath(), eaiMessage, true, callProp );
} catch(Exception e) {
//throw new Exception( IFROUTER_ERROR_LOCAL );
throw new Exception(ExceptionUtil.getErrorCode(e,IFROUTER_ERROR_LOCAL));
}
} else {
EAIServerManager mgr = EAIServerManager.getInstance();
EAIServerVO server = mgr.getEAIServer( mgr.getLocalServerName());
EAIServerVO backupSvr = mgr.getEAIServer( server.getFailoverSvr() );
if ( service.getFlOvrCls().equals( EAIMessage.YES_FLAG ) && backupSvr != null) {
//Properties prop = new Properties();
StringBuffer urlBuf = new StringBuffer();
urlBuf.append( EAIServerVO.IIOP_PROTOCOL ).append("://");
urlBuf.append( backupSvr.getAddress() ).append(":");
urlBuf.append( backupSvr.getRmiPort() );
callProp.setProperty( RouteKeys.REMOTE_CALL_URL, urlBuf.toString() );
if (logger.isInfo()) {
logger.info(guidLogPrefix + " FailOver Remote Call [" + urlBuf.toString() + "] RemoteProxyClient");
}
try {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " FailOver RemoteProxyClient call");
}
message = RemoteProxyClient.callProxyBean(eaiMessage, callProp);
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " FailOver RemoteProxyClient result : "+message);
}
} catch(Exception e) {
logger.error(guidLogPrefix + " FailOver Remote Call Error - " + e.getMessage());
// e.printStackTrace();
//throw new Exception(IFROUTER_ERROR_REMOTE);
throw new Exception(ExceptionUtil.getErrorCode(e,IFROUTER_ERROR_REMOTE));
}
}
else {
throw new Exception( ExceptionUtil.make(IFROUTER_ERROR_LOCK , new String[1]) );
}
}
} else {
try {
if (logger.isDebug()) {
logger.debug(guidLogPrefix + " PCOMPLEX [" + routingUrl.getSyncRoutingPath() + "]");
}
message = ElinkESBProcessProxy.callElinkESBProcess( routingUrl.getSyncRoutingPath(), eaiMessage, true, callProp );
} catch(Exception e) {
//throw new Exception( IFROUTER_ERROR_LOCAL );
throw new Exception(ExceptionUtil.getErrorCode(e,IFROUTER_ERROR_LOCAL));
}
}
return message;
}
/**
* 1. 기능 : Adapter그룹명의 Adapter들의 상태정보를 확인하는 메소드
* 2. 처리 개요 :
* - AdapterManager를 통해 해당 Adapter그룹의 Adapter의 상태를 확인하여
* 정상적인 Adapter가 있는지 여부를 리턴한다.
* 3. 주의사항
*
* @param adapterGroupName Adapter그룹명
* @return boolean
* @exception Exception
**/
public static boolean isAlive(String adapterGroupName) throws Exception {
//-------------------------------------------------
// CISCO Router에 대한 처리로직 추가 : 2007.06.15 DHLEE
//-------------------------------------------------
String cadapterGroupName = "";
String cadapterName = "";
if (adapterGroupName.indexOf('.') != -1) {
cadapterName = adapterGroupName.substring(adapterGroupName.indexOf('.')+1);
cadapterGroupName = adapterGroupName.substring(0, adapterGroupName.indexOf('.'));
}
else {
cadapterGroupName = adapterGroupName;
}
AdapterGroupVO adapterGroup = AdapterManager.getInstance().getAdapterGroupVO( cadapterGroupName );
if(adapterGroup==null) {
throw new Exception("IFRouter] Cannot find the AdapterGroupVO. - "+ cadapterGroupName);
}
if (adapterGroupName.indexOf('.') != -1) {
AdapterVO vo = adapterGroup.getAdapterVO(cadapterName);
if (vo == null) {
return false;
}else{
//라우팅 특정 포트 매핑시 어댑터 업무 이름 선택시 오류 수정
//isStarted 체크는 node를 변경한경우 대비
if (vo.isStarted() && vo.isStatus()){
return true;
}else{
return false;
}
}
}else{
return adapterGroup.isAlive();
}
}
}
@@ -0,0 +1,171 @@
package com.eactive.eai.common.routing;
import java.util.Properties;
import com.eactive.eai.adapter.AdapterGroupVO;
import com.eactive.eai.adapter.AdapterManager;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.message.MessageType;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.message.StandardMessage;
import com.eactive.eai.message.manager.StandardMessageManager;
import com.eactive.eai.message.parser.StandardReader;
import com.eactive.eai.message.service.InterfaceMapper;
import com.ext.eai.common.stdmessage.STDMessageKeys;
public abstract class Process {
public static final String ADAPTER_TIMEOUT = "ADAPTER_TIMEOUT";
public static final String ADAPTER_DEFAULT_TIMEOUT = "ADAPTER_DEFAULT_TIMEOUT";
public static final String HTTP_ADAPTER_TIMEOUT_PROP = "HTTP_ADAPTER_TIMEOUT_PROP";
public static final String SOCKET_ADAPTER_TIMEOUT_PROP = "SOCKET_ADAPTER_TIMEOUT_PROP";
public static final String INTERFACE_TIME_OUT = "INTERFACE_TIME_OUT";
public abstract void callService(EAIMessage message, Properties prop) throws Exception;
public abstract EAIMessage clientReturn() throws Exception;
protected Object makeStandardMessageData(EAIMessage eaiMessage, String msgType
, Object bizObject, String charset) throws Exception{
StandardMessage standardMessage = eaiMessage.getStandardMessage();
String outboundAdapterGroupName = eaiMessage.getCurrentSvcMsg().getPsvSysItfTp();
AdapterGroupVO outboundAdapterGvo = AdapterManager.getInstance().getAdapterGroupVO(outboundAdapterGroupName);
standardMessage.setBizData(bizObject, outboundAdapterGvo.getMessageEncode());
if(MessageType.JSON.equals(msgType)) {
return standardMessage.toJson();
}
else if(MessageType.XML.equals(msgType)) {
return standardMessage.toXML();
}
else if(MessageType.ASC.equals(msgType)) {
return standardMessage.toByteArray(charset);
}
else {
throw new Exception("Unsupported msgType - " + msgType);
}
}
protected String getGuidSeq(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getGuidSeq(standardMessage);
}
protected String getGuid(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getGuid(standardMessage);
}
protected String getOrgGuid(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getOrgGuid(standardMessage);
}
protected String getReqSysCode(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getReqSysCode(standardMessage);
}
protected String getTimeout(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getTimeout(standardMessage);
}
protected void setTimeout(EAIMessage eaiMessage, String timeout) {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessage standardMessage = eaiMessage.getStandardMessage();
mapper.setTimeout(standardMessage, timeout);
}
protected String getRecoverYn(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getRecoverYn(standardMessage);
}
protected String getInstCode(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getInstCode(standardMessage);
}
protected String getOperationEnv(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getOperationEnv(standardMessage);
}
protected String getFirstRequestSysIp(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getFirstReqIp(standardMessage);
}
protected String getServiceId(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getServiceId(standardMessage);
}
protected String getReturnType(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
if(mapper == null) return null;
StandardMessage standardMessage = eaiMessage.getStandardMessage();
return mapper.getSendRecvDivision(standardMessage);
}
protected void setReturnType(EAIMessage eaiMessage, String returnType) {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessage standardMessage = eaiMessage.getStandardMessage();
mapper.setSendRecvDivision(standardMessage, returnType);
}
protected EAIMessage setResponseForOutbound(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessage standardMessage = eaiMessage.getStandardMessage();
mapper.setSendRecvDivision(standardMessage, STDMessageKeys.SEND_RECV_CD_RECV);
return eaiMessage;
}
protected EAIMessage setSendTime(EAIMessage eaiMessage) {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessage standardMessage = eaiMessage.getStandardMessage();
mapper.setSendTime(standardMessage, DatetimeUtil.getCurrentTimeMillis());
return eaiMessage;
}
protected EAIMessage setRcvLogInfo(EAIMessage eaiMessage, String msgType, Object message, String charset)
throws Exception {
InterfaceMapper mapper = eaiMessage.getMapper();
StandardMessageManager standardManager = StandardMessageManager.getInstance();
StandardMessage standardMessage = standardManager.getStandardMessage();
StandardReader reader = standardManager.getReader(msgType);
if (reader == null) {
throw new Exception("StandardReader not found, msgType - " + msgType);
}
reader.parse(standardMessage, message);
standardMessage.setBizDataCharset(charset);
standardManager.getMessageCoordinator().coordinateAfterParsing(standardMessage, null, new Properties());
eaiMessage.setStandardMessage(standardMessage);
mapper.setRecvTime(standardMessage, DatetimeUtil.getCurrentTimeMillis());
return eaiMessage;
}
}
@@ -0,0 +1,91 @@
package com.eactive.eai.common.routing;
/**
* 1. 기능 : Process 초기화 하기 위한 Factory Class
* 2. 처리 개요 :
* - 초기화 된 Process 인스턴스를 HashMap 객체에 담는다.
* - 해당 어댑터의 Process 인스턴스를 반환 한다.
* 3. 주의사항
*
* @author :
* @version : v 1.0.0
* @see : Process
* @since :
*/
public class ProcessFactory
{
// private static final String BaseFCProcess = "com.eactive.eai.flowcontroller.BaseFCProcess";
// private static final String B2BFCProcess = "com.eactive.eai.flowcontroller.B2BFCProcess";
// private static final String C2RFCProcess = "com.eactive.eai.flowcontroller.C2RFCProcess";
//
//
// private static final String SocketProcess = "com.eactive.eai.outbound.SocketProcess";
// private static final String HTTPProcess = "com.eactive.eai.outbound.HTTPProcess";
// private static final String SIMHTTPProcess = "com.eactive.eai.outbound.SIMHTTPProcess";
// private static final String LoopBackProcess = "com.eactive.eai.outbound.LoopBackProcess";
/**
* ProcessFactory instance
*/
private static final ProcessFactory factory = new ProcessFactory();
/**
* 1. 기능 : Default Constructor
* 2. 처리 개요 :
* - 타입 별 Process instance를 어댑터 HashMap에 담는다.
* 3. 주의사항
*
**/
private ProcessFactory() {
}
/**
* 1. 기능 : ProcessFactory Object를 반환하는 getter method
* 2. 처리 개요 : ProcessFactory Object를 반환한다.
* 3. 주의사항
*
* @return ProcessFactory object
**/
public static ProcessFactory newInstance() {
return factory;
}
/**
* 1. 기능 : 해당 프로세스의 Process Object를 반환
* 2. 처리 개요 :
* - Process instance HashMap으로 부터 해당 어댑터의 Process Object를 반환 한다.
* 3. 주의사항
*
* @param serviceURI URI
* @return Process object
**/
public Process getProcess(String serviceURI) throws Exception {
if(serviceURI==null) return null;
Process process = null;
// if(serviceURI.equals(BaseFCProcess)) {
// process = new com.eactive.eai.flowcontroller.BaseFCProcess();
// } else if(serviceURI.equals(B2BFCProcess)) {
// process = new com.eactive.eai.flowcontroller.B2BFCProcess();
// } else if(serviceURI.equals(C2RFCProcess)) {
// process = new com.eactive.eai.flowcontroller.C2RFCProcess();
// } else if(serviceURI.equals(SocketProcess)) {
// process = new com.eactive.eai.outbound.SocketProcess();
// } else if(serviceURI.equals(HTTPProcess)) {
// process = new com.eactive.eai.outbound.HTTPProcess();
// } else if(serviceURI.equals(SIMHTTPProcess)) {
// process = new com.eactive.eai.outbound.SIMHTTPProcess();
// } else if(serviceURI.equals(LoopBackProcess)) {
// process = new com.eactive.eai.outbound.LoopBackProcess();
// }
if(process==null) {
throw new RuntimeException("Process not found. - "+serviceURI);
}
return process;
}
}
@@ -0,0 +1,152 @@
package com.eactive.eai.common.routing;
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.routing.rmi.RemoteProxy;
import com.eactive.eai.common.routing.rmi.TimeoutRmiClientSocketFactory;
import com.eactive.eai.common.util.Logger;
import org.apache.commons.lang3.time.StopWatch;
import org.springframework.remoting.RemoteConnectFailureException;
import org.springframework.remoting.rmi.RmiProxyFactoryBean;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.rmi.server.RMISocketFactory;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
public class RemoteProxyClient {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
private static String SERVICE_URL = "%s/RemoteProxy"; // rmi://%s:1099
// private static factory = null;
// private static String currentUrl = null;
// FailOver인스턴스 이외에도 호출할 수 있도록 Map으로 수정함. 2021-04-05
private static ConcurrentHashMap<String, RmiProxyFactoryBean> factoryMap = new ConcurrentHashMap<String, RmiProxyFactoryBean>();
private static RmiProxyFactoryBean getFactory(String remoteUrl) {
RmiProxyFactoryBean factory = factoryMap.get(remoteUrl);
return factory;
}
private synchronized static RmiProxyFactoryBean initFactory(String remoteUrl, int connectTimeout, int timeout) {
RmiProxyFactoryBean factory = factoryMap.get(remoteUrl);
if(factory != null) return factory;
factory = new RmiProxyFactoryBean();
factory.setServiceInterface(RemoteProxy.class);
factory.setServiceUrl(String.format(SERVICE_URL, remoteUrl));
TimeoutRmiClientSocketFactory registryClientSocketFactory = new TimeoutRmiClientSocketFactory();
try {
RMISocketFactory f = RMISocketFactory.getSocketFactory();
if(f == null) {
RMISocketFactory.setSocketFactory(new RMISocketFactory() {
public Socket createSocket(String host, int port) throws IOException {
int timeout = 120 *1000; // 타임아웃을 기본 120초로 설정
Socket socket = new Socket(host, port);
socket.setSoTimeout(timeout);
socket.setSoLinger(false, 0);
// System.out.println("RMISocketFactory timeout >> " + timeout);
return socket;
}
public ServerSocket createServerSocket(int port) throws IOException {
return new ServerSocket(port);
}
}
);
}
else {
logger.warn("initFactory RMISocketFactory already defined : " + f.toString());
}
registryClientSocketFactory.setConnectTimeout(connectTimeout);
registryClientSocketFactory.setTimeout(timeout);
factory.setRegistryClientSocketFactory(registryClientSocketFactory);
factory.setRefreshStubOnConnectFailure(true);
factory.afterPropertiesSet();
factoryMap.put(remoteUrl, factory);
return factory;
} catch (Exception e) {
logger.error("initFactory Exception - " + remoteUrl, e);
return null;
}
}
public static EAIMessage callProxyBean(EAIMessage eaiMessage, Properties prop) throws Exception {
EAIMessage response = null;
// Object obj = null;
if(logger.isDebug()) {
// logger.debug("RemoteProxyClient] Start - GUID(" + eaiMessage.getKbMsg().getKBHeader().getGuIdNo()+"), IFseq("+ eaiMessage.getSvcOgNo()+")" );
logger.debug("RemoteProxyClient] Start - GUID(" + eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage()) +"), IFseq("+ eaiMessage.getSvcOgNo()+")" );
}
StopWatch stopWatch = new StopWatch();
stopWatch.start();
String psvItfTp = eaiMessage.getCurrentSvcMsg().getPsvItfTp();
String remoteUrl = prop.getProperty(RouteKeys.REMOTE_CALL_URL);
Properties properties = PropManager.getInstance().getProperties(RouteKeys.REMOTE_CALL);
// String user = properties.getProperty(RouteKeys.REMOTE_CALL_USER);
// String pwd = properties.getProperty(RouteKeys.REMOTE_CALL_PWD);
String connectionTimeout = properties.getProperty(RouteKeys.REMOTE_CALL_CONNECTION_TIMEOUT ,"1000");
String readTimeoutAsync = properties.getProperty(RouteKeys.REMOTE_CALL_READ_TIMEOUT_ASYNC ,"4000");
String readTimeoutSync = properties.getProperty(RouteKeys.REMOTE_CALL_READ_TIMEOUT_SYNC ,"60000");
int connectTimeout = Integer.parseInt(connectionTimeout);
int timeout = 2000;
if(logger.isDebug()) {
logger.debug("RemoteProxyClient] remoteUrl - " + remoteUrl);
logger.debug("RemoteProxyClient] connectionTimeout - " + connectionTimeout);
}
if( EAIMessageKeys.ASYNC_SVC.equals(psvItfTp) ) {
timeout = Integer.parseInt(readTimeoutAsync);
}
else {
timeout = Integer.parseInt(readTimeoutSync);
}
RmiProxyFactoryBean factory = null;
try {
if(logger.isDebug()) {
logger.debug("RemoteProxyClient] Get RemoteProxy/call Service");
}
if(remoteUrl == null) {
throw new Exception("remoteUrl is NULL");
}
factory = getFactory(remoteUrl);
if(factory == null) {
factory = initFactory(remoteUrl, connectTimeout, timeout);
if(factory == null) {
logger.error("RemoteProxyClient] initFactory Error : "+remoteUrl);
}
}
RemoteProxy service = (RemoteProxy) factory.getObject();
response = service.callService(eaiMessage, prop);
} catch(RemoteConnectFailureException ie) {
logger.warn("RemoteProxyClient] Reset RMI Factory : "+ ie.getMessage());
factory = initFactory(remoteUrl, connectTimeout, timeout);
RemoteProxy service = (RemoteProxy) factory.getObject();
response = service.callService(eaiMessage, prop);
} catch(Exception e) {
logger.error("RemoteProxyClient] Get RemoteProxy/call Service Error : "+ e.getMessage(),e);
throw e;
} catch(Throwable t) {
logger.error("RemoteProxyClient] Get RemoteProxy/call Service Error : "+ t.getMessage(),t);
throw new Exception("RemoteProxyClient] Get RemoteProxy/call Service Error : "+ t.getMessage());
} finally{
}
stopWatch.stop();
if(logger.isDebug()) {
// logger.debug("RemoteProxyClient] End - GUID(" + eaiMessage.getKbMsg().getKBHeader().getGuIdNo()+"), IFseq("+ eaiMessage.getSvcOgNo() +"), time=("+stopWatch.getTime()+")" );
logger.debug("RemoteProxyClient] End - GUID(" + eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage()) +"), IFseq("+ eaiMessage.getSvcOgNo() +"), time=("+stopWatch.getTime()+")" );
}
return response;
}
}
@@ -0,0 +1,61 @@
package com.eactive.eai.common.routing;
/**
* 1. 기능 : routing 패키지에서 사용하는 상수값들을 정의한 Interface Class
* 2. 처리 개요 :
* * - routing 패키지에서 사용하는 상수값들을 정의한 Interface Class
* 3. 주의사항
*
* @author :
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public interface RouteKeys
{
public static final String REMOTE_CALL = "REMOTE_CALL";
public static final String REMOTE_CONTAINER_ID = "REMOTE_CONTAINER_ID";
public static final String REMOTE_CALL_URL = "REMOTE_CALL_URL";
public static final String REMOTE_CALL_CONNECTION_TIMEOUT = "REMOTE_CALL_CONNECTION_TIMEOUT";
public static final String REMOTE_CALL_READ_TIMEOUT_ASYNC = "REMOTE_CALL_READ_TIMEOUT_ASYNC";
public static final String REMOTE_CALL_READ_TIMEOUT_SYNC = "REMOTE_CALL_READ_TIMEOUT_SYNC";
public static final String GROUP_NAME = "FlowRouter";
public static final String ROUTING_QUEUE_CONNECTION_FACTORY = "routing.queue.connection.factory";
public static final String ROUTING_TOPIC_CONNECTION_FACTORY = "routing.topic.connection.factory";
public static final String ROUTING_QUEUE = "routing.queue";
public static final String ROUTING_RESQUEUE = "routing.resqueue"; // 비동기응답거래를 위한 Queue : 2008.10.29
public static final String ROUTING_TOPIC = "routing.topic";
public static final String ROUTING_TOPIC_TTL = "routing.topic.ttl";
// ActiveMQ AmqPooledConnectionFactory configuration
public static final String ROUTING_QUEUE_CONNECTION_FACTORY_MAXCONNECTION = "routing.queue.connection.factory.maxconnection";
public static final String ROUTING_QUEUE_CONNECTION_FACTORY_EXPIRYTIMEOUT = "routing.queue.connection.factory.expirytimeout";
public static final String ROUTING_QUEUE_CONNECTION_FACTORY_IDLETIMEOUT = "routing.queue.connection.factory.idletimeout";
// RequestProcessor에서 FlowRouter로 전달하는 Routing 방식 정의
public static final String ROUTING_TYPE = "ROUTING_TYPE";
public static final String ROUT_QUEUE = "ROUT_QUEUE";
public static final String ROUT_TOPIC = "ROUT_TOPIC";
public static final String ROUT_CALL = "ROUT_CALL";
// 동기-비동기의 응답메시지에 대한 TOPIC JMSCorrelationID
public static final String TRACE_KEY = "TRACE_KEY";
// 더미단말(연수단말) 거래를 위한 라우팅 정보저장
public static final String DUMMY_ROUTE_INFO = "DUMMY_ROUTE_INFO";
public static final String REMOTE_URL = "REMOTE_URL"; // 사용하지 않을 수 있음
//시뮬레이터 prop 관련
public static final String SIM = "SIM";
public static final String SIM_ROUTING = "sim.routing";
public static final String SIM_ADAPTER_SYNC = "sim.adapter.sync";
public static final String SIM_ADAPTER_ASYNC = "sim.adapter.async";
public static final String SIM_REST_MOCKSERVER = "sim.rest.mockserver";
}
@@ -0,0 +1,56 @@
package com.eactive.eai.common.routing;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.routing.loader.RoutingLoader;
import com.eactive.eai.common.routing.mapper.RoutingMapper;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.data.entity.onl.routing.Routing;
@Service
@Transactional
public class RoutingDAO extends BaseDAO {
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
@Autowired
private RoutingLoader routingLoader;
@Autowired
private RoutingMapper routingMapper;
public Map<String, RoutingVO> getAllRoutings() throws DAOException {
try {
Map<String, RoutingVO> routingMap = new HashMap<>();
List<Routing> routings = routingLoader.findAllByOrderByDefault();
if(logger.isInfo()) logger.info("[ @@ Load Routing Configuration - starting >>>>>>>>>>>>>>>>> ]");
for (Routing routing : routings) {
RoutingVO routingVO = routingMapper.toVo(routing);
routingMap.put(routingVO.getName(), routingVO);
}
if(logger.isInfo()) logger.info("[>>Load Routing Configuration - ended ]");
return routingMap;
} catch (Exception e) {
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICRT101"));
}
}
public RoutingVO getRouting(String routingName) throws DAOException {
try {
Routing routing = routingLoader.getById(routingName);
RoutingVO routingVO = routingMapper.toVo(routing);
if(logger.isInfo()) logger.info("@ " + routingVO.toString());
return routingVO;
} catch (Exception e) {
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICRT101"));
}
}
}
@@ -0,0 +1,121 @@
package com.eactive.eai.common.routing;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.lifecycle.Lifecycle;
import com.eactive.eai.common.lifecycle.LifecycleException;
import com.eactive.eai.common.lifecycle.LifecycleListener;
import com.eactive.eai.common.lifecycle.LifecycleSupport;
import com.eactive.eai.common.util.ApplicationContextProvider;
import com.eactive.eai.common.util.Logger;
@Component
public class RoutingManager implements Lifecycle {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
private Map<String, RoutingVO> routings;
private boolean started;
@Autowired
private RoutingDAO routingDAO;
private LifecycleSupport lifecycle = new LifecycleSupport(this);
public static RoutingManager getInstance() {
return ApplicationContextProvider.getContext().getBean(RoutingManager.class);
}
public void start() throws LifecycleException {
if (started) {
throw new LifecycleException("RECEAICRT201");
}
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
try {
init();
} catch (Exception e) {
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICRT202"));
}
started = true;
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
}
private void init() throws Exception {
this.routings = routingDAO.getAllRoutings();
}
public synchronized void reload() throws Exception {
if (logger.isWarn()) {
logger.warn("RoutingManager] reload all Started ...");
}
init();
if (logger.isWarn()) {
logger.warn("RoutingManager] reload all finished ...");
}
}
public synchronized void reload(String routingName) throws Exception {
RoutingVO vo = routingDAO.getRouting(routingName);
if (vo != null) {
this.routings.put(routingName, vo);
} else {
throw new Exception("Routing not found in Database : key[" + routingName + "]");
}
}
public void stop() throws LifecycleException {
if (!started) {
throw new LifecycleException("RECEAICRT203");
}
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
started = false;
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
}
public void addLifecycleListener(LifecycleListener listener) {
lifecycle.addLifecycleListener(listener);
}
public LifecycleListener[] findLifecycleListeners() {
return lifecycle.findLifecycleListeners();
}
public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
public boolean isStarted() {
return this.started;
}
public RoutingVO getRoutingVO(String name) {
return (RoutingVO) routings.get(name);
}
public String[] getAllRoutingNames() {
Iterator<String> it = this.routings.keySet().iterator();
String[] routingNames = new String[this.routings.size()];
for (int i = 0; it.hasNext(); i++) {
routingNames[i] = it.next();
}
Arrays.sort(routingNames);
return routingNames;
}
public Iterator<RoutingVO> getAllRoutingVOs() {
return this.routings.values().iterator();
}
public void setRoutingVO(RoutingVO vo) {
routings.put(vo.getName(), vo);
}
public void removeRoutingVO(String name) {
routings.remove(name);
}
}
@@ -0,0 +1,85 @@
package com.eactive.eai.common.routing;
import java.io.Serializable;
/**
* 1. 기능 : Routing Rule 정보를 표현하는 Java Value Object 클래스.
* 2. 처리 개요 : Layer간 호출을 담당하는 Routing Rule 정보를 정의한다.
* 3. 주의사항
*
* @author :
* @version : v 1.0.0
* @see : 관련 기능을 참조
* @since :
* :
*/
public class RoutingVO implements Serializable
{
private String name; //라우팅명 [TSEAIFR02.RoutName] - RoutingName
private String syncRoutingPath; //동기라우팅URI명 [TSEAIFR02.NonMotivRoutURIName] - SynchronousRoutingURIName
private String asynRoutingPath; //비동기라우팅URI명 [TSEAIFR02.MotivRoutURIName] - AsynchronousRoutingURI
//migration by kscheon
private String layerDstcd; //레이어구분코드 [TSEAIFR02.LayerDstcd] - LayerClassificationCode
public RoutingVO() {
}
public RoutingVO(String name, String syncRoutingPath, String asynRoutingPath, String layerDstcd) {
this.name = name;
this.syncRoutingPath = syncRoutingPath;
this.asynRoutingPath = asynRoutingPath;
this.layerDstcd = layerDstcd;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setSyncRoutingPath(String syncRoutingPath) {
this.syncRoutingPath = syncRoutingPath;
}
public String getSyncRoutingPath() {
return this.syncRoutingPath;
}
public void setAsynRoutingPath(String asynRoutingPath) {
this.asynRoutingPath = asynRoutingPath;
}
public String getAsynRoutingPath() {
return this.asynRoutingPath;
}
//migration by kscheon - start
public String getLayerDstcd() {
return this.layerDstcd;
}
public void setLayerDstcd(String layerDstcd) {
this.layerDstcd = layerDstcd;
}
//migration by kscheon - end
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("RoutingVO[ name=").append(name);
sb.append(", syncRoutingPath=").append(syncRoutingPath);
sb.append(", asynRoutingPath=").append(asynRoutingPath);
sb.append(" ]");
return sb.toString();
}
}
@@ -0,0 +1,23 @@
package com.eactive.eai.common.routing.mapper;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import com.eactive.eai.common.routing.RoutingVO;
import com.eactive.eai.data.entity.onl.routing.Routing;
import com.eactive.eai.data.mapper.GenericMapper;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface RoutingMapper extends GenericMapper<RoutingVO, Routing> {
@Mapping(source = "id", target = "name")
@Mapping(source = "layerdstcd", target = "layerDstcd")
@Mapping(source = "motivrouturiname", target = "syncRoutingPath")
@Mapping(source = "nonmotivrouturiname", target = "asynRoutingPath")
@Override
RoutingVO toVo(Routing entity);
@InheritInverseConfiguration
Routing toEntity(RoutingVO vo);
}
@@ -0,0 +1,46 @@
package com.eactive.eai.common.routing.pool;
import java.util.Properties;
import org.apache.commons.lang.time.StopWatch;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.routing.RemoteProxyClient;
import com.eactive.eai.common.routing.RouteKeys;
import com.eactive.eai.common.util.Logger;
public class PublishThread implements Runnable {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
private java.util.Properties callProp;
private com.eactive.eai.common.message.EAIMessage eaiMessage;
public PublishThread(Properties callProp, EAIMessage eaiMessage) {
this.callProp = callProp;
this.eaiMessage = eaiMessage;
}
public void run(){
// RemoteProxyClient로 Remote의 EJB 호출
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if (logger.isInfo()) {
logger.info("PublishThread] RemoteProxyClient call - " + callProp.getProperty(RouteKeys.REMOTE_CONTAINER_ID) + " "
+ callProp.getProperty(RouteKeys.REMOTE_CALL_URL));
}
try {
RemoteProxyClient.callProxyBean(eaiMessage, callProp);
} catch (Exception e) {
if (logger.isError())
logger.error("PublishThread] RemoteProxyClient call ERROR." + e.getMessage(), e);
} finally {
;
}
stopWatch.stop();
if (logger.isInfo()) {
logger.info("PublishThread] RemoteProxyClient result time(" + stopWatch.getTime()
+ ")");
}
}
}
@@ -0,0 +1,35 @@
package com.eactive.eai.common.routing.pool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class RoutingThreadPoolExecutor {
private static RoutingThreadPoolExecutor instance = new RoutingThreadPoolExecutor();
/**
* 기동 여부
*/
private boolean started = false;
private static ExecutorService executor = Executors.newFixedThreadPool(10);
/**
* 1. 기능 : Default Constructor
* 2. 처리 개요 :
* 3. 주의사항
**/
private RoutingThreadPoolExecutor() {
}
public static RoutingThreadPoolExecutor getInstance() {
return instance;
}
public ExecutorService getExecutor(){
return executor;
}
public static void destroy(){
instance = null;
executor.shutdownNow();
}
}
@@ -0,0 +1,7 @@
package com.eactive.eai.common.routing.rmi;
import java.util.Properties;
public interface GWRemoteProxy {
public Object callService(Object message, Properties callProp) ;
}
@@ -0,0 +1,30 @@
package com.eactive.eai.common.routing.rmi;
import java.util.Properties;
import com.eactive.eai.adapter.socket2.common.StopWatch;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.inbound.processor.GWRequestProcessor;
public class GWRemoteProxyImpl implements GWRemoteProxy {
static Logger logger = Logger.getLogger(Logger.LOGGER_SIFT);
@Override
public Object callService(Object message, Properties callProp) {
Object response = null;
try {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
response = GWRequestProcessor.callService(message, callProp);
stopWatch.stop();
} catch(Exception e) {
logger.error("GWRemoteProxy called service Error : " + e.getMessage(), e);
}
return response;
}
}
@@ -0,0 +1,9 @@
package com.eactive.eai.common.routing.rmi;
import com.eactive.eai.common.message.EAIMessage;
import java.util.Properties;
public interface RemoteProxy {
public EAIMessage callService(EAIMessage eaiMessage, Properties callProp) ;
}
@@ -0,0 +1,50 @@
package com.eactive.eai.common.routing.rmi;
import com.eactive.eai.adapter.socket2.common.StopWatch;
import com.eactive.eai.common.message.EAIMessage;
import com.eactive.eai.common.message.ServiceMessage;
import com.eactive.eai.common.routing.ElinkESBProcessProxy;
import com.eactive.eai.common.routing.RoutingManager;
import com.eactive.eai.common.routing.RoutingVO;
import com.eactive.eai.common.util.Logger;
import java.util.Properties;
public class RemoteProxyImpl implements RemoteProxy {
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
// private String name = this.getClass().getName();
@Override
public EAIMessage callService(EAIMessage eaiMessage, Properties callProp) {
EAIMessage message = null;
String guidLogPrefix = "RemoteProxyImpl] ";
try {
// guidLogPrefix = "RemoteProxyImpl] GUID["+eaiMessage.getKbMsg().getKBHeader().getGuIdNo()+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
guidLogPrefix = "RemoteProxyImpl] GUID["+eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage())+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
StopWatch stopWatch = new StopWatch();
stopWatch.start();
if(logger.isDebug()) {
logger.debug(guidLogPrefix + " called service["+eaiMessage.getEAISvcCd()+ "] UUID["+eaiMessage.getSvcOgNo()+"]");
}
ServiceMessage service = (eaiMessage.getSvcMsgs().get( eaiMessage.getSvcPssSeq() - 1 ));
String routingName = service.getOutbRtnNm();
RoutingVO routingUrl = RoutingManager.getInstance().getRoutingVO( routingName );
message = ElinkESBProcessProxy.callElinkESBProcess( routingUrl.getSyncRoutingPath(), eaiMessage, true, callProp );
stopWatch.stop();
if(logger.isDebug()) {
logger.debug(guidLogPrefix + " called service["+eaiMessage.getEAISvcCd()+ "] time("+stopWatch.getTime()+") ");
}
}
catch(Exception e) {
if(logger.isError() && eaiMessage != null) {
logger.error(guidLogPrefix+ " called service["+eaiMessage.getEAISvcCd()+
"] UUID["+eaiMessage.getSvcOgNo()+"] Error : "+e.getMessage(),e);
}
}
return message;
}
}
@@ -0,0 +1,42 @@
package com.eactive.eai.common.routing.rmi;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.rmi.server.RMIClientSocketFactory;
public class TimeoutRmiClientSocketFactory implements RMIClientSocketFactory {
private int connectTimeout = 2000;
private int timeout = 2000;
public TimeoutRmiClientSocketFactory() {
super();
}
public TimeoutRmiClientSocketFactory(int timeout) {
super();
this.timeout = timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
@Override
public Socket createSocket(String host, int port) throws IOException {
final Socket socket = new Socket();
socket.setSoTimeout(timeout);
socket.setSoLinger(false, 0);
socket.connect(new InetSocketAddress(host, port), connectTimeout);
// System.out.println("CreateSocket : " + socket +": timeout = " +socket.getSoTimeout());
return socket;
}
}