init
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package com.eactive.eai.common;
|
||||
|
||||
/**
|
||||
* 거래 별 Context 정보를 저장 할 상수 클래스
|
||||
*/
|
||||
public interface TransactionContextKeys {
|
||||
public static final String TRANSACTION_PROP = "TRANSACTION_PROP";
|
||||
public static final String GUID = "GUID";
|
||||
public static final String INTERFACE_ID = "INTERFACE_ID";
|
||||
public static final String TRANSACTION_UUID = "TRANSACTION_UUID";
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.eactive.eai.common;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
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.routing.ElinkESBProcessProxy;
|
||||
import com.eactive.eai.common.routing.RouteKeys;
|
||||
import com.eactive.eai.common.routing.RoutingManager;
|
||||
import com.eactive.eai.common.routing.RoutingVO;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class WarmupManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private static WarmupManager instance;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
private boolean started;
|
||||
|
||||
private WarmupManager() {
|
||||
}
|
||||
|
||||
public static synchronized WarmupManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new WarmupManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICWM001");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
RoutingManager manager = RoutingManager.getInstance();
|
||||
Iterator<RoutingVO> it = manager.getAllRoutingVOs();
|
||||
|
||||
if (it == null) {
|
||||
logger.warn("RoutingManager getAllRoutingVOs is NULL");
|
||||
} else {
|
||||
Properties p = new Properties();
|
||||
p.put(EAIKeys.CALL_MODE_KEY, EAIKeys.CALL_MODE_WARMUP);
|
||||
p.setProperty(RouteKeys.ROUTING_TYPE, RouteKeys.ROUT_CALL);
|
||||
while (it.hasNext()) {
|
||||
RoutingVO vo = it.next();
|
||||
try {
|
||||
if (vo == null)
|
||||
continue;
|
||||
if (vo.getSyncRoutingPath() != null) {
|
||||
ElinkESBProcessProxy.callElinkESBProcess(vo.getSyncRoutingPath(), null, true, p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("WarmupManager] warming up the routing process. - " + vo.getSyncRoutingPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICWM002");
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.eactive.eai.common.activemq;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.pool.PooledConnectionFactory;
|
||||
|
||||
import com.eactive.eai.common.property.PropManager;
|
||||
import com.eactive.eai.common.routing.RouteKeys;
|
||||
|
||||
public class AmqPooledConnectionFactory {
|
||||
public static String CONNECTION_URI = "vm://localhost?broker.persistent=false&broker.useJmx=true&jms.useAsyncSend=true&jms.prefetchPolicy.all=0";
|
||||
|
||||
private static final AmqPooledConnectionFactory instance = new AmqPooledConnectionFactory();
|
||||
|
||||
private PooledConnectionFactory pooledConnectionFactory;
|
||||
|
||||
public static AmqPooledConnectionFactory getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private AmqPooledConnectionFactory() {
|
||||
createNewFactory();
|
||||
}
|
||||
|
||||
public Connection getConnection() throws JMSException {
|
||||
return pooledConnectionFactory.createConnection();
|
||||
}
|
||||
|
||||
private void createNewFactory() {
|
||||
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(CONNECTION_URI);
|
||||
connectionFactory.setTrustAllPackages(true);
|
||||
|
||||
// Create a PooledConnectionFactory and set some configuration options
|
||||
pooledConnectionFactory = new PooledConnectionFactory();
|
||||
pooledConnectionFactory.setConnectionFactory(connectionFactory);
|
||||
|
||||
setConnectionProperties();
|
||||
|
||||
pooledConnectionFactory.start();
|
||||
}
|
||||
|
||||
private PooledConnectionFactory setConnectionProperties() {
|
||||
Properties props = PropManager.getInstance().getProperties(RouteKeys.GROUP_NAME);
|
||||
int maxConnection = Integer
|
||||
.parseInt(props.getProperty(RouteKeys.ROUTING_QUEUE_CONNECTION_FACTORY_MAXCONNECTION, "5"));
|
||||
|
||||
long expiryTimeout = Long
|
||||
.parseLong(props.getProperty(RouteKeys.ROUTING_QUEUE_CONNECTION_FACTORY_EXPIRYTIMEOUT, "0"));
|
||||
|
||||
int idleTimeout = Integer
|
||||
.parseInt(props.getProperty(RouteKeys.ROUTING_QUEUE_CONNECTION_FACTORY_IDLETIMEOUT, "30000"));
|
||||
|
||||
pooledConnectionFactory.setMaxConnections(maxConnection);
|
||||
pooledConnectionFactory.setIdleTimeout(idleTimeout);
|
||||
pooledConnectionFactory.setExpiryTimeout(expiryTimeout);
|
||||
|
||||
return pooledConnectionFactory;
|
||||
}
|
||||
|
||||
public PooledConnectionFactory reload() {
|
||||
return setConnectionProperties();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.eactive.eai.common.activemq;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class AmqQueueProducer {
|
||||
|
||||
private Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private String queueName = null;
|
||||
|
||||
public AmqQueueProducer(String connectionUrl, String queueName) {
|
||||
this.queueName = queueName;
|
||||
}
|
||||
|
||||
public void sendMessage(Serializable object, Properties prop) throws JMSException {
|
||||
Connection connection = null;
|
||||
Session session = null;
|
||||
MessageProducer producer = null;
|
||||
|
||||
try {
|
||||
// Create a Connection
|
||||
connection = AmqPooledConnectionFactory.getInstance().getConnection();
|
||||
|
||||
// Create a Session
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
// Create the destination (Topic or Queue)
|
||||
Destination destination = session.createQueue(queueName);
|
||||
producer = session.createProducer(destination);
|
||||
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
ObjectMessage message = session.createObjectMessage(object);
|
||||
if (prop != null) {
|
||||
for(Object key : prop.keySet()) {
|
||||
message.setObjectProperty(key.toString(), prop.get(key));
|
||||
}
|
||||
}
|
||||
producer.send(message);
|
||||
} catch (JMSException ex) {
|
||||
logger.error("Send Error = " + ex.getMessage(), ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
if (producer != null) {
|
||||
try {
|
||||
producer.close();
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
if (session != null)
|
||||
try {
|
||||
session.close();
|
||||
} catch (JMSException e) {
|
||||
// ignored
|
||||
}
|
||||
if (connection != null)
|
||||
try {
|
||||
connection.close();
|
||||
} catch (JMSException e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.eactive.eai.common.activemq;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.Connection;
|
||||
import javax.jms.DeliveryMode;
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class AmqTopicProducer {
|
||||
|
||||
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
Connection connection = null;
|
||||
Session session = null;
|
||||
MessageProducer producer = null;
|
||||
String connectionUrl = null;
|
||||
String topicName = null;
|
||||
String correlationID = null;
|
||||
|
||||
public AmqTopicProducer(String connectionUrl, String topicName, String correlationID) {
|
||||
this.connectionUrl = connectionUrl;
|
||||
this.topicName = topicName;
|
||||
this.correlationID = correlationID;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void sendMessage(Serializable object, Properties prop, long ttl) throws JMSException {
|
||||
try {
|
||||
// Create a Connection
|
||||
connection = AmqPooledConnectionFactory.getInstance().getConnection();
|
||||
|
||||
// Create a Session
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
// Create the destination (Topic or Queue)
|
||||
Destination destination = session.createTopic(topicName);
|
||||
producer = session.createProducer(destination);
|
||||
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
||||
ObjectMessage message = session.createObjectMessage(object);
|
||||
|
||||
if(ttl > 0) {
|
||||
producer.setTimeToLive(ttl);
|
||||
}
|
||||
|
||||
if (correlationID != null) {
|
||||
message.setJMSCorrelationID(correlationID);
|
||||
}
|
||||
|
||||
if (prop != null) {
|
||||
Iterator it = prop.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = prop.getProperty(key);
|
||||
message.setStringProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
producer.send(message);
|
||||
}
|
||||
catch(JMSException ex) {
|
||||
logger.error("Send Error = " + ex.getMessage(), ex);
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
if (producer != null) {
|
||||
try {
|
||||
producer.close();
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
if (session != null)
|
||||
try {
|
||||
session.close();
|
||||
} catch (JMSException e) {
|
||||
// ignored
|
||||
}
|
||||
if (connection != null)
|
||||
try {
|
||||
connection.close();
|
||||
} catch (JMSException e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
package com.eactive.eai.common.authoutbound;
|
||||
|
||||
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.authoutbound.OutboundOAuthCredentialDao;
|
||||
import com.eactive.eai.authoutbound.OutboundOAuthCredentialVo;
|
||||
import com.eactive.eai.authoutbound.client.HttpClientAccessTokenServiceByDB;
|
||||
import com.eactive.eai.authoutbound.client.HttpClientAccessTokenServiceFactoryByDB;
|
||||
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;
|
||||
import com.openbanking.eai.common.token.AccessTokenVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Access 토큰 정보를 DB로 부터 로딩하고 만료시 재발급 정보를 메모리에 관리하는 Manager 클래스
|
||||
* 2. 처리 개요 : DB 프로퍼티 정보에 저장된 Access 토큰 정보를 메모리에 로딩하거나 재발급 관리한다.
|
||||
* * -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since :
|
||||
* :
|
||||
*/
|
||||
@Component
|
||||
public class AccessTokenManagerByDB implements Lifecycle {
|
||||
/**
|
||||
* Default Logger
|
||||
*/
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
/**
|
||||
* AccessTokenManager Single Instance
|
||||
*/
|
||||
private static AccessTokenManagerByDB instance = new AccessTokenManagerByDB();
|
||||
|
||||
/**
|
||||
* LifecyleSupport object
|
||||
*/
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
/**
|
||||
* 기동 여부
|
||||
*/
|
||||
private boolean started;
|
||||
|
||||
/**
|
||||
* 토큰 정보를 저장하는 collection
|
||||
*/
|
||||
private HashMap<String, AccessTokenVO> tokens;
|
||||
|
||||
/**
|
||||
* 인증 정보를 저장하는 Map
|
||||
*/
|
||||
private Map<String, OutboundOAuthCredentialVo> outboundOAuthCredentialVos;
|
||||
|
||||
@Autowired
|
||||
OutboundOAuthCredentialDao outboundOAuthCredentialDao;
|
||||
|
||||
private ScheduledExecutorService scheduler;
|
||||
private Map<String, ScheduledFuture<?>> scheduledTasks;
|
||||
private Set<String> runningTasks;
|
||||
private static final long TASK_TIMEOUT_SECONDS = 30;
|
||||
|
||||
private static final int TOKEN_SCHEDULER_THREAD_POOL_SIZE = 30;
|
||||
|
||||
public AccessTokenManagerByDB() {
|
||||
tokens = new HashMap<>();
|
||||
scheduledTasks = new ConcurrentHashMap<>();
|
||||
outboundOAuthCredentialVos = new HashMap<>();
|
||||
runningTasks = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
scheduler = Executors.newScheduledThreadPool(TOKEN_SCHEDULER_THREAD_POOL_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : AccessTokenManager Singleton Object를 반환하는 getter method
|
||||
* 2. 처리 개요 : AccessTokenManager Singleton Object를 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
* @exception
|
||||
**/
|
||||
public static AccessTokenManagerByDB getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(AccessTokenManagerByDB.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : AccessTokenManager의 초기화 여부를 반환하는 getter 메서드
|
||||
* 2. 처리 개요 : AccessTokenManager의 초기화 여부를 반환한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return 초기화 여부
|
||||
**/
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICPM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
tokens.clear();
|
||||
init();
|
||||
} catch(Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e,"RECEAICPM201"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
if (logger.isWarn()){
|
||||
logger.warn("Service started successfully");
|
||||
}
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
List<OutboundOAuthCredentialVo> OutboundOAuthCredentialVos = outboundOAuthCredentialDao.getAllOutboundOAuthCredentials();
|
||||
logger.info("Initializing with {} credential configurations", OutboundOAuthCredentialVos.size());
|
||||
|
||||
for (OutboundOAuthCredentialVo outboundOAuthCredentialVo : OutboundOAuthCredentialVos) {
|
||||
startToken(outboundOAuthCredentialVo);
|
||||
outboundOAuthCredentialVos.put(outboundOAuthCredentialVo.getAdapterGroupName(), outboundOAuthCredentialVo);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICPM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
// 모든 스케줄된 작업 중지
|
||||
scheduledTasks.forEach((name, future) -> {
|
||||
future.cancel(true);
|
||||
logger.warn("Task stopped for adapter group: {}", name);
|
||||
});
|
||||
scheduledTasks.clear();
|
||||
|
||||
// 실행 중인 작업 세트 클리어
|
||||
runningTasks.clear();
|
||||
|
||||
// 스케줄러 종료
|
||||
scheduler.shutdown();
|
||||
try {
|
||||
if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||
scheduler.shutdownNow();
|
||||
logger.warn("Forced shutdown of scheduler after timeout");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
scheduler.shutdownNow();
|
||||
logger.error("Scheduler shutdown interrupted", e);
|
||||
}
|
||||
|
||||
this.tokens = null;
|
||||
started = false;
|
||||
|
||||
if (logger.isWarn()){
|
||||
logger.warn("Service stopped successfully");
|
||||
}
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
public synchronized void refresh(OutboundOAuthCredentialVo outboundOAuthCredentialVo) throws Exception {
|
||||
String adapterGroupName = outboundOAuthCredentialVo.getAdapterGroupName();
|
||||
logger.info("Starting refresh for adapter group: {}", adapterGroupName);
|
||||
|
||||
// 기존 스케줄러 작업 취소
|
||||
stopToken(adapterGroupName);
|
||||
|
||||
// 인증 정보 갱신
|
||||
outboundOAuthCredentialVos.put(adapterGroupName, outboundOAuthCredentialVo);
|
||||
|
||||
if("N".equals(outboundOAuthCredentialVo.getUseYn())) {
|
||||
logger.info("Token task disabled for adapter group: {}", adapterGroupName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Y인 경우 새로운 스케줄러 작업 시작
|
||||
logger.info("Restarting token task for adapter group: {}", adapterGroupName);
|
||||
startToken(outboundOAuthCredentialVo);
|
||||
}
|
||||
|
||||
public void startToken(final OutboundOAuthCredentialVo outboundOAuthCredentialVo) {
|
||||
if (!"Y".equals(outboundOAuthCredentialVo.getUseYn())) {
|
||||
logger.debug("Token task not started - disabled for adapter group: {}",
|
||||
outboundOAuthCredentialVo.getAdapterGroupName());
|
||||
return;
|
||||
}
|
||||
|
||||
final String adapterGroupName = outboundOAuthCredentialVo.getAdapterGroupName();
|
||||
if (scheduledTasks.containsKey(adapterGroupName)) {
|
||||
logger.warn("Token task not started - already scheduled for adapter group: {}", adapterGroupName);
|
||||
return;
|
||||
}
|
||||
|
||||
long interval = outboundOAuthCredentialVo.getIntervalSec() > 0 ?
|
||||
outboundOAuthCredentialVo.getIntervalSec() : 24 * 60 * 60;
|
||||
|
||||
logger.info("Starting token task for adapter group: {} with interval: {} seconds",
|
||||
adapterGroupName, interval);
|
||||
|
||||
Runnable periodicTask = () -> executeTokenTask(adapterGroupName, outboundOAuthCredentialVo);
|
||||
|
||||
ScheduledFuture<?> scheduledTask = scheduler.scheduleAtFixedRate(
|
||||
periodicTask,
|
||||
0, // 즉시 첫 실행
|
||||
interval,
|
||||
TimeUnit.SECONDS
|
||||
);
|
||||
|
||||
scheduledTasks.put(adapterGroupName, scheduledTask);
|
||||
}
|
||||
|
||||
private void executeTokenTask(String adapterGroupName, OutboundOAuthCredentialVo credential) {
|
||||
if (!runningTasks.add(adapterGroupName)) {
|
||||
logger.info("Task skipped - already running for adapter group: {}", adapterGroupName);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug("Starting token task for adapter group: {}", adapterGroupName);
|
||||
try {
|
||||
Future<?> future = scheduler.submit(() -> {
|
||||
try {
|
||||
logger.debug("Executing token issuance for adapter group: {}", adapterGroupName);
|
||||
|
||||
// 현재 토큰 가져오기
|
||||
AccessTokenVO accessToken = tokens.get(adapterGroupName);
|
||||
|
||||
// 다음 스케줄 시간 계산
|
||||
long intervalTime = System.currentTimeMillis() + (credential.getIntervalSec() * 1000);
|
||||
// 토큰이 없거나, 다음 스케줄 시간 전에 만료될 경우 재발급
|
||||
if (accessToken == null) {
|
||||
issueToken(credential, false);
|
||||
} else if(accessToken.getExpiration() != null) {
|
||||
// 토큰이 있고 만료시간이 설정 된 경우
|
||||
if(accessToken.getExpiration().before(new Date(intervalTime))){
|
||||
// 다음 스케줄 전에 토큰이 만료되는 경우 재발급
|
||||
issueToken(credential, true);
|
||||
} else {
|
||||
// 토큰이 아직 유효한 경우
|
||||
logger.debug("Token still valid until next schedule for adapter group: {}, expiration date: {}", adapterGroupName, accessToken.getExpiration());
|
||||
}
|
||||
} else {
|
||||
//토큰이 있지만 만료 시간이 없는 경우
|
||||
logger.debug("Token exists but expiration time is null for adapter group: {}", adapterGroupName);
|
||||
}
|
||||
|
||||
logger.debug("Token issuance completed for adapter group: {}", adapterGroupName);
|
||||
} catch (Exception e) {
|
||||
logger.error("Token issuance failed for adapter group: {}", adapterGroupName, e);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
future.get(TASK_TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
} catch (TimeoutException e) {
|
||||
logger.error("Task timed out for adapter group: {}", adapterGroupName);
|
||||
future.cancel(true);
|
||||
} catch (Exception e) {
|
||||
logger.error("Task execution failed for adapter group: {}", adapterGroupName, e);
|
||||
}
|
||||
} finally {
|
||||
runningTasks.remove(adapterGroupName);
|
||||
logger.debug("Token task completed for adapter group: {}", adapterGroupName);
|
||||
}
|
||||
}
|
||||
|
||||
private void issueToken(OutboundOAuthCredentialVo outboundOAuthCredentialVo, boolean isTokenExpiredWithinInterval) throws Exception {
|
||||
String adapterGroupName = outboundOAuthCredentialVo.getAdapterGroupName();
|
||||
boolean isExpired = true;
|
||||
|
||||
if (tokens.containsKey(adapterGroupName)) {
|
||||
AccessTokenVO accessToken = tokens.get(adapterGroupName);
|
||||
isExpired = accessToken.isExpired();
|
||||
}
|
||||
logger.debug("Token status for adapter group: {}, expired: {}, isTokenExpiredWithinInterval: {}", adapterGroupName, isExpired, isTokenExpiredWithinInterval);
|
||||
|
||||
if (isExpired || isTokenExpiredWithinInterval) {
|
||||
logger.info("Issuing new token for adapter group: {}", adapterGroupName);
|
||||
tokens.remove(adapterGroupName);
|
||||
|
||||
AdapterGroupVO gvo = AdapterManager.getInstance().getAdapterGroupVO(adapterGroupName);
|
||||
|
||||
if (gvo != null && gvo.getAdapters().hasNext()) {
|
||||
AdapterVO avo = gvo.getAdapters().next();
|
||||
Properties properties = AdapterPropManager.getInstance().getProperties(avo.getPropGroupName());
|
||||
String type = properties.getProperty("ADAPTER_TOKEN_ISSUING_CLIENT_TYPE");
|
||||
|
||||
HttpClientAccessTokenServiceByDB service = HttpClientAccessTokenServiceFactoryByDB.createFactory(type);
|
||||
if(service != null) {
|
||||
logger.debug("Executing token service of type: {} for adapter group: {}", type, adapterGroupName);
|
||||
AccessTokenVO accessToken = (AccessTokenVO) service.execute(adapterGroupName, properties, outboundOAuthCredentialVo);
|
||||
this.tokens.put(adapterGroupName, accessToken);
|
||||
logger.info("New token issued successfully for adapter group: {}", adapterGroupName);
|
||||
} else {
|
||||
logger.warn("Token service not found for type: {} and adapter group: {}", type, adapterGroupName);
|
||||
}
|
||||
} else {
|
||||
logger.warn("No valid adapter configuration found for adapter group: {}", adapterGroupName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stopToken(String adapterGroupName) {
|
||||
ScheduledFuture<?> task = scheduledTasks.remove(adapterGroupName);
|
||||
if (task != null) {
|
||||
task.cancel(true);
|
||||
logger.warn("Token task stopped for adapter group: {}", adapterGroupName);
|
||||
}
|
||||
tokens.remove(adapterGroupName);
|
||||
logger.debug("Token removed for adapter group: {}", adapterGroupName);
|
||||
}
|
||||
|
||||
public void refresh(String adapterGroupName) throws Exception {
|
||||
refresh(outboundOAuthCredentialDao.getOutboundOAuthCredential(adapterGroupName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : LifecycleListener를 등록하는 메서드
|
||||
* 2. 처리 개요 : LifecycleListener를 등록한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param listener LifecycleEvent를 수신한 LifecycleListener
|
||||
**/
|
||||
public void addLifecycleListener(LifecycleListener listener)
|
||||
{
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 등록된 LifecycleListener 리스트를 반환하는 메서드
|
||||
* 2. 처리 개요 : 등록된 LifecycleListener 리스트를 반환하다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return 등록된 LifecycleListener 리스트
|
||||
**/
|
||||
public LifecycleListener[] findLifecycleListeners()
|
||||
{
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 등록된 LifecycleListener를 삭제하는 메서드
|
||||
* 2. 처리 개요 : 파라미터의 LifecycleListener를 삭제한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param listener 삭제할 LifecycleListener
|
||||
**/
|
||||
public void removeLifecycleListener(LifecycleListener listener)
|
||||
{
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public boolean isOAuthCredentialRegistered(String adapterGroupName){
|
||||
OutboundOAuthCredentialVo outboundOAuthCredentialVo = outboundOAuthCredentialVos.get(adapterGroupName);
|
||||
return outboundOAuthCredentialVo != null && "Y".equals(outboundOAuthCredentialVo.getUseYn());
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Access 토큰 정보를 반환하는 메서드
|
||||
* 2. 처리 개요 : Access 토큰 정보를 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return Access 토큰 정보
|
||||
**/
|
||||
public AccessTokenVO getAccessTokenVO(String adapterGroupName) {
|
||||
AccessTokenVO accessToken = null;
|
||||
|
||||
try {
|
||||
accessToken = tokens.get(adapterGroupName);
|
||||
} catch(Exception e) {
|
||||
if (logger.isError()) logger.error("토큰을 찾을 수 없습니다. ["+adapterGroupName+"] ", e);
|
||||
}
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Access 토큰 값를 반환하는 메서드
|
||||
* 2. 처리 개요 : Access 토큰 값를 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return accessToken 값
|
||||
**/
|
||||
public String getAccessToken(String adapterGroupName) {
|
||||
String accessToken = null;
|
||||
|
||||
try {
|
||||
accessToken = tokens.get(adapterGroupName).getAccessToken();
|
||||
} catch(Exception e) {
|
||||
if (logger.isError()) logger.error("토큰을 찾을 수 없습니다. ["+adapterGroupName+"] ", e);
|
||||
}
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : Access 토큰를 삭제하는 메서드
|
||||
* 2. 처리 개요 : Access 토큰를 삭제한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
**/
|
||||
public void removeAccessTokenVO(String adapterGroupName) {
|
||||
// 스케줄러 작업 중지 및 토큰 제거
|
||||
stopToken(adapterGroupName);
|
||||
// OAuth 인증 정보 제거
|
||||
outboundOAuthCredentialVos.remove(adapterGroupName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Access 토큰를 재발급하는 메서드
|
||||
* 2. 처리 개요 : Access 토큰를 재발급한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
**/
|
||||
public synchronized AccessTokenVO retryAccessTokenVO(String adapterGroupName, Properties properties, String oldToken) throws Exception {
|
||||
|
||||
AccessTokenVO accessToken = getAccessTokenVO(adapterGroupName);
|
||||
|
||||
// 동시 요청이 발생할 경우 synchronized 처리를 했기때문에 토큰을 다시 한번 체크한다.
|
||||
if (accessToken == null || accessToken.isExpired()
|
||||
|| StringUtils.equals(accessToken.getAccessToken(), oldToken)) {
|
||||
|
||||
if(isOAuthCredentialRegistered(adapterGroupName) == false){
|
||||
throw new Exception("There is no OAuthCredentialRegistered information, or whether to use it is 'N'.");
|
||||
}
|
||||
String type = properties.getProperty("ADAPTER_TOKEN_ISSUING_CLIENT_TYPE");
|
||||
|
||||
HttpClientAccessTokenServiceByDB service = HttpClientAccessTokenServiceFactoryByDB.createFactory(type);
|
||||
OutboundOAuthCredentialVo outboundOAuthCredentialVo = outboundOAuthCredentialVos.get(adapterGroupName);
|
||||
if(service != null) {
|
||||
accessToken = (AccessTokenVO) service.execute(adapterGroupName, properties, outboundOAuthCredentialVo);
|
||||
}
|
||||
tokens.put(adapterGroupName, accessToken);
|
||||
}
|
||||
|
||||
return accessToken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import java.util.Collection;
|
||||
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.b2badaptermapping.loader.B2BAdapterMapLoader;
|
||||
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.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.b2badaptermapping.B2BAdapterMap;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class B2BAdapterMapDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private B2BAdapterMapLoader b2bAdapterMapEntityService;
|
||||
|
||||
public Map<String, B2BAdapterMapVO> getAllB2BAdapterMaps(String eaiInstCd) throws DAOException {
|
||||
try {
|
||||
|
||||
List<B2BAdapterMap> adapterMaps = b2bAdapterMapEntityService
|
||||
.findByIdEaisevrinstncnameOrderByDefault(eaiInstCd);
|
||||
Map<String, B2BAdapterMapVO> msgKeys = new HashMap<>();
|
||||
logger.info("[ @@ Load B2BAdapterMap Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (B2BAdapterMap adapterMap : adapterMaps) {
|
||||
B2BAdapterMapVO vo = new B2BAdapterMapVO();
|
||||
vo.setEaiInstCd(eaiInstCd);
|
||||
vo.setEaiSvcCd(adapterMap.getId().getEaisvcname());
|
||||
|
||||
msgKeys.put(adapterMap.getId().getEaisvcname(), vo);
|
||||
|
||||
vo.addB2BAdapterMapFld( adapterMap.getId().getExtnlinstiidnfiname(),
|
||||
adapterMap.getId().getDmnddtalsbzwkdsticname(),
|
||||
adapterMap.getPsvsysadptrbzwkgroupname(),
|
||||
adapterMap.getAdptrbzwkname());
|
||||
|
||||
logger.info("B2BAdapterMapFldVO in getAllB2BAdapterMaps():");
|
||||
for (B2BAdapterMapFldVO fldVO : vo.getB2BAdapterMapFlds()) {
|
||||
logger.info("@ B2BAdapterMapFld toString >> " + fldVO.toString());
|
||||
}
|
||||
}
|
||||
return msgKeys;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBA101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, B2BAdapterMapVO> getB2BAdapterMap(String eaiInstCd, String eaiSvcCd) throws DAOException {
|
||||
try {
|
||||
|
||||
HashMap<String, B2BAdapterMapVO> msgKeys = new HashMap<>();
|
||||
Collection<B2BAdapterMap> adapterMaps = b2bAdapterMapEntityService
|
||||
.findByIdEaisevrinstncnameAndIdEaisvcname(eaiInstCd, eaiSvcCd);
|
||||
logger.info("[ @@ Load B2BAdapterMap Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (B2BAdapterMap adapterMap : adapterMaps) {
|
||||
B2BAdapterMapVO vo = new B2BAdapterMapVO();
|
||||
|
||||
msgKeys.put(eaiSvcCd, vo);
|
||||
|
||||
vo.addB2BAdapterMapFld( adapterMap.getId().getExtnlinstiidnfiname(),
|
||||
adapterMap.getId().getDmnddtalsbzwkdsticname(),
|
||||
adapterMap.getPsvsysadptrbzwkgroupname(),
|
||||
adapterMap.getAdptrbzwkname());
|
||||
|
||||
logger.info("B2BAdapterMapFldVO in getB2BAdapterMap():");
|
||||
for (B2BAdapterMapFldVO fldVO : vo.getB2BAdapterMapFlds()) {
|
||||
logger.info("@ B2BAdapterMapFld getB2BAdapterMap >> " + fldVO.toString());
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("[>>Load B2BAdapterMap Configuration - ended ]");
|
||||
return msgKeys;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBA205"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
public class B2BAdapterMapFldVO implements Serializable {
|
||||
private String b2bExtnlInstiCd; // id.extnlinstiidnfiname 외부기관식 별명
|
||||
private String bzwkVal; // id.dmnddtalsbzwkdsticname 요청 세부 업무 구분명
|
||||
private String adapterGroupName; // psvsysadptrbzwkgroupname 수동시스템어댑터업무그룹명
|
||||
private String adapterName; // adptrbzwkname 어댑터 이름
|
||||
|
||||
public B2BAdapterMapFldVO(String b2bExtnlInstiCd, String bzwkVal, String adapterGroupName, String adapterName) {
|
||||
this.b2bExtnlInstiCd = b2bExtnlInstiCd;
|
||||
this.bzwkVal = bzwkVal;
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
this.adapterName = adapterName;
|
||||
}
|
||||
|
||||
public String getB2bExtnlInstiCd() {
|
||||
return this.b2bExtnlInstiCd;
|
||||
}
|
||||
|
||||
public void setB2bExtnlInstiCd(String b2bExtnlInstiCd) {
|
||||
this.b2bExtnlInstiCd = b2bExtnlInstiCd;
|
||||
}
|
||||
|
||||
public void setBzwkVal(String bzwkVal) {
|
||||
this.bzwkVal = bzwkVal;
|
||||
}
|
||||
|
||||
public String getBzwkVal() {
|
||||
return this.bzwkVal;
|
||||
}
|
||||
|
||||
public void setAdapterGroupName(String adapterGroupName) {
|
||||
this.adapterGroupName = adapterGroupName;
|
||||
}
|
||||
|
||||
public String getAdapterGroupName() {
|
||||
return this.adapterGroupName;
|
||||
}
|
||||
|
||||
public void setAdapterName(String adapterName) {
|
||||
this.adapterName = adapterName;
|
||||
}
|
||||
|
||||
public String getAdapterName() {
|
||||
return this.adapterName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
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.server.EAIServerManager;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
@Component
|
||||
public class B2BAdapterMapManager implements Lifecycle {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private boolean started;
|
||||
|
||||
private Map<String, B2BAdapterMapVO> messages = new HashMap<>();
|
||||
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
@Autowired
|
||||
private B2BAdapterMapDAO b2bAdapterMapDAO;
|
||||
|
||||
public static B2BAdapterMapManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(B2BAdapterMapManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICBA201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICBA202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
public void init() throws DAOException {
|
||||
String eaiInstCd = EAIServerManager.getInstance().getLocalServerName();
|
||||
messages = b2bAdapterMapDAO.getAllB2BAdapterMaps(eaiInstCd);
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BAdapterMapManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BAdapterMapManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String eaiSvcCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload Started ...");
|
||||
}
|
||||
Map<String, B2BAdapterMapVO> map = b2bAdapterMapDAO
|
||||
.getB2BAdapterMap(EAIServerManager.getInstance().getLocalServerName(), eaiSvcCd);
|
||||
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = "";
|
||||
while (it.hasNext()) {
|
||||
key = (String) it.next();
|
||||
messages.put(key, map.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void remove(String eaiSvcCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] remove Started ...");
|
||||
}
|
||||
messages.remove(eaiSvcCd);
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] remove finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICBA203");
|
||||
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
messages.clear();
|
||||
|
||||
started = false;
|
||||
// Notify our interested LifecycleListeners
|
||||
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 B2BAdapterMapVO getB2BAdapterMap(String eaiSvcCd) {
|
||||
return messages.get(eaiSvcCd);
|
||||
}
|
||||
|
||||
public void setB2BAdapterMap(String eaiSvcCd, B2BAdapterMapVO msg) {
|
||||
String currentInstCd = EAIServerManager.getInstance().getLocalServerName();
|
||||
|
||||
if (currentInstCd != null && currentInstCd.equals(msg.getEaiInstCd())) {
|
||||
B2BAdapterMapVO current = messages.get(eaiSvcCd);
|
||||
|
||||
if (current == null) {
|
||||
messages.put(eaiSvcCd, msg);
|
||||
} else {
|
||||
String[] keys = msg.getAllKeyNames();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
B2BAdapterMapFldVO fvo = msg.getB2BAdapterMapFld(keys[i]);
|
||||
if (fvo == null)
|
||||
continue;
|
||||
current.addB2BAdapterMapFld(fvo.getB2bExtnlInstiCd(), fvo.getBzwkVal(), fvo.getAdapterGroupName(),
|
||||
fvo.getAdapterName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateB2BAdapterMap(String eaiSvcCd, B2BAdapterMapVO msg) {
|
||||
String currentInstCd = EAIServerManager.getInstance().getLocalServerName();
|
||||
if (currentInstCd != null && currentInstCd.equals(msg.getEaiInstCd())) {
|
||||
B2BAdapterMapVO current = messages.get(eaiSvcCd);
|
||||
if (current == null) {
|
||||
messages.put(eaiSvcCd, msg);
|
||||
} else {
|
||||
String[] keys = msg.getAllKeyNames();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
B2BAdapterMapFldVO fvo = msg.getB2BAdapterMapFld(keys[i]);
|
||||
if (fvo == null) {
|
||||
continue;
|
||||
}
|
||||
current.addB2BAdapterMapFld(fvo.getB2bExtnlInstiCd(), fvo.getBzwkVal(), fvo.getAdapterGroupName(),
|
||||
fvo.getAdapterName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeB2BAdapterMap(String eaiSvcCd) {
|
||||
messages.remove(eaiSvcCd);
|
||||
}
|
||||
|
||||
public void removeB2BAdapterMap(String eaiSvcCd, B2BAdapterMapVO msg) {
|
||||
String currentInstCd = EAIServerManager.getInstance().getLocalServerName();
|
||||
if (currentInstCd != null && currentInstCd.equals(msg.getEaiInstCd())) {
|
||||
B2BAdapterMapVO current = messages.get(eaiSvcCd);
|
||||
if (current != null) {
|
||||
String[] keys = msg.getAllKeyNames();
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
B2BAdapterMapFldVO fvo = msg.getB2BAdapterMapFld(keys[i]);
|
||||
if (fvo == null) {
|
||||
logger.warn("B2BAdapterMapFldVO is null key=" + keys[i]);
|
||||
continue;
|
||||
}
|
||||
current.deleteB2BAdapterMapFld(fvo.getB2bExtnlInstiCd(), fvo.getBzwkVal());
|
||||
}
|
||||
|
||||
if (current.getB2BAdapterMapFldLength() == 0) {
|
||||
messages.remove(eaiSvcCd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAllKeyNames() {
|
||||
Set<String> keySet = this.messages.keySet();
|
||||
String[] name = keySet.toArray(new String[keySet.size()]);
|
||||
Arrays.sort(name);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class B2BAdapterMapVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String eaiInstCd; // EAI 서버인스턴스명 [TSEAIFR07.EAISevrInstncName]
|
||||
private String eaiSvcCd; // EAI 서비스명 [TSEAIFR07.EAISvcName]
|
||||
|
||||
private HashMap<String, B2BAdapterMapFldVO> msgFlds;
|
||||
|
||||
public B2BAdapterMapVO() {
|
||||
this("", "");
|
||||
}
|
||||
|
||||
public B2BAdapterMapVO(String eaiInstCd, String eaiSvcCd) {
|
||||
this.eaiInstCd = eaiInstCd;
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
this.msgFlds = new HashMap<>();
|
||||
}
|
||||
|
||||
public void setEaiInstCd(String eaiInstCd) {
|
||||
this.eaiInstCd = eaiInstCd;
|
||||
}
|
||||
|
||||
public String getEaiInstCd() {
|
||||
return this.eaiInstCd;
|
||||
}
|
||||
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getEaiSvcCd() {
|
||||
return this.eaiSvcCd;
|
||||
}
|
||||
|
||||
public B2BAdapterMapFldVO getB2BAdapterMapFld(String b2bExtnlInstiCd, String bzwkVal) {
|
||||
return getB2BAdapterMapFld(b2bExtnlInstiCd + bzwkVal);
|
||||
}
|
||||
|
||||
public B2BAdapterMapFldVO getB2BAdapterMapFld(String key) {
|
||||
B2BAdapterMapFldVO vo = msgFlds.get(key);
|
||||
if (vo == null)
|
||||
return null;
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
public void addB2BAdapterMapFld(String b2bExtnlInstiCd, String bzwkVal, String adapterGroupName,
|
||||
String adapterName) {
|
||||
this.msgFlds.put(b2bExtnlInstiCd + bzwkVal,
|
||||
new B2BAdapterMapFldVO(b2bExtnlInstiCd, bzwkVal, adapterGroupName, adapterName));
|
||||
}
|
||||
|
||||
public void deleteB2BAdapterMapFld(String b2bExtnlInstiCd, String bzwkVal) {
|
||||
this.msgFlds.remove(b2bExtnlInstiCd + bzwkVal);
|
||||
}
|
||||
|
||||
public int getB2BAdapterMapFldLength() {
|
||||
return this.msgFlds.size();
|
||||
}
|
||||
|
||||
public String[] getAllKeyNames() {
|
||||
Iterator<String> it = this.msgFlds.keySet().iterator();
|
||||
String[] name = new String[this.msgFlds.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
name[i] = it.next();
|
||||
}
|
||||
Arrays.sort(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
public Collection<B2BAdapterMapFldVO> getB2BAdapterMapFlds() {
|
||||
return msgFlds.values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
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.b2bextractor.loader.B2BExtractLoader;
|
||||
import com.eactive.eai.common.b2bextractor.mapper.B2BExtractMapper;
|
||||
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.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.b2bextractor.B2BExtract;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class B2BExtractDAO extends BaseDAO {
|
||||
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private B2BExtractLoader b2bExtractEntityService;
|
||||
@Autowired
|
||||
private B2BExtractMapper b2bExtractMapper;
|
||||
|
||||
public Map<String, B2BExtractVO> getAllB2BExtracts() throws DAOException {
|
||||
|
||||
try {
|
||||
HashMap<String, B2BExtractVO> b2bMap = new HashMap<>();
|
||||
List<B2BExtract> b2bExtracts = b2bExtractEntityService.findAllOrderByEaisvcname();
|
||||
logger.info("[ @@ Load B2BExtract Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (B2BExtract b2bExtract : b2bExtracts) {
|
||||
B2BExtractVO vo = b2bExtractMapper.toVo(b2bExtract);
|
||||
b2bMap.put(b2bExtract.getId().getEaisvcname() + b2bExtract.getId().getSvcprcssno(), vo);
|
||||
}
|
||||
logger.info("[>>Load B2BExtract Configuration - ended ]");
|
||||
return b2bMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, B2BExtractVO> getB2BExtract(String eaisvcname) throws DAOException {
|
||||
try {
|
||||
HashMap<String, B2BExtractVO> map = new HashMap<>();
|
||||
B2BExtract b2bExtract = b2bExtractEntityService.findByIdEaisvcname(eaisvcname);
|
||||
logger.info("[ @@ Load B2BExtract Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
if (b2bExtract != null) {
|
||||
B2BExtractVO vo = b2bExtractMapper.toVo(b2bExtract);
|
||||
String key = b2bExtract.getId().getEaisvcname() + b2bExtract.getId().getSvcprcssno();
|
||||
logger.info("@ " + vo.toString());
|
||||
map.put(key, vo);
|
||||
}
|
||||
|
||||
logger.info("[>>Load B2BExtract Configuration - ended ]");
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM205"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
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 B2BExtractManager implements Lifecycle {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
private Map<String, B2BExtractVO> messages = new HashMap<>();
|
||||
|
||||
private boolean started;
|
||||
|
||||
@Autowired
|
||||
B2BExtractDAO b2bExtractDAO;
|
||||
|
||||
public static B2BExtractManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(B2BExtractManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICKM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICKM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
messages = b2bExtractDAO.getAllB2BExtracts();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String eaiSvcCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload Started ...");
|
||||
}
|
||||
Map<String, B2BExtractVO> map = b2bExtractDAO.getB2BExtract(eaiSvcCd);// eaiSvcCd
|
||||
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = null;
|
||||
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
messages.put(key, map.get(key));
|
||||
}
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BExtractManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICKM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
messages.clear();
|
||||
|
||||
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 B2BExtractVO getB2BExtract(String code) {
|
||||
return messages.get(code);
|
||||
}
|
||||
|
||||
public void setB2BExtract(String code, B2BExtractVO msg) {
|
||||
messages.put(code, msg);
|
||||
}
|
||||
|
||||
public void removeB2BExtract(String code) {
|
||||
messages.remove(code);
|
||||
}
|
||||
|
||||
public String[] getAllKeyNames() {
|
||||
Set<String> keySet = this.messages.keySet();
|
||||
String[] names = keySet.toArray(new String[keySet.size()]);
|
||||
Arrays.sort(names);
|
||||
return names;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class B2BExtractVO implements Serializable {
|
||||
private String eaiSvcCd; // EAI 서비스명 : TSEAIFR06.EAISvcName
|
||||
private int svcPssSeq; // 서비스처리번호[TSEAIFR06.SvcPrcssNo]
|
||||
private String routeActionName; // RouteAction Class : TSEAIFR06.routeActionName
|
||||
private String adapterActionName; // AdapterAction Class : TSEAIFR06.adapterActionName
|
||||
|
||||
public B2BExtractVO(String eaiSvcCd, int svcPssSeq, String routeActionName, String adapterActionName) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
this.svcPssSeq = svcPssSeq;
|
||||
this.routeActionName = routeActionName;
|
||||
this.adapterActionName = adapterActionName;
|
||||
}
|
||||
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getEaiSvcCd() {
|
||||
return this.eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getAdapterActionName() {
|
||||
return adapterActionName;
|
||||
}
|
||||
|
||||
public void setAdapterActionName(String adapterActionName) {
|
||||
this.adapterActionName = adapterActionName;
|
||||
}
|
||||
|
||||
public String getRouteActionName() {
|
||||
return routeActionName;
|
||||
}
|
||||
|
||||
public void setRouteActionName(String routeActionName) {
|
||||
this.routeActionName = routeActionName;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq() {
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int svcPssSeq) {
|
||||
this.svcPssSeq = svcPssSeq;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eactive.eai.common.b2bextractor.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.b2bextractor.B2BExtractVO;
|
||||
import com.eactive.eai.data.entity.onl.b2bextractor.B2BExtract;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface B2BExtractMapper extends GenericMapper<B2BExtractVO, B2BExtract> {
|
||||
|
||||
@Mapping(source = "id.eaisvcname", target = "eaiSvcCd")
|
||||
@Mapping(source = "id.svcprcssno", target = "svcPssSeq")
|
||||
@Mapping(source = "svcroutclsname", target = "routeActionName")
|
||||
@Mapping(source = "adptrroutclsname", target = "adapterActionName")
|
||||
@Override
|
||||
B2BExtractVO toVo(B2BExtract entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
B2BExtract toEntity(B2BExtractVO vo);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.eactive.eai.common.b2bservice;
|
||||
|
||||
import java.util.Collection;
|
||||
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.b2bservice.loader.B2BServiceLoader;
|
||||
import com.eactive.eai.common.b2bservice.mapper.B2BServiceMapper;
|
||||
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.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.b2bservice.B2BService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class B2BServiceDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private B2BServiceLoader b2bServiceEntityService;
|
||||
|
||||
@Autowired
|
||||
private B2BServiceMapper b2bServiceMapper;
|
||||
|
||||
public Map<String, B2BServiceVO> getAllB2BServices() throws DAOException {
|
||||
String useyn = "1";
|
||||
try {
|
||||
HashMap<String, B2BServiceVO> b2bServiceMap = new HashMap<>(); // B2BService Table
|
||||
List<B2BService> b2bServices = b2bServiceEntityService.findByUseynOrderByDefault(useyn);
|
||||
logger.info("[ @@ Load B2BService Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
String key = null;
|
||||
for (B2BService b2bService : b2bServices) {
|
||||
B2BServiceVO vo = b2bServiceMapper.toVo(b2bService);
|
||||
key = b2bService.getId().getExtnlinstiidnfiname() + b2bService.getId().getSvcprcssno();
|
||||
b2bServiceMap.put(key, vo);
|
||||
}
|
||||
logger.info("[>>Load B2BService Configuration - ended ]");
|
||||
return b2bServiceMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, B2BServiceVO> getB2BService(String b2bExtnlInstiCd) throws DAOException {
|
||||
try {
|
||||
HashMap<String, B2BServiceVO> map = new HashMap<>();
|
||||
Collection<B2BService> b2bServices = b2bServiceEntityService
|
||||
.findByIdExtnlinstiidnfinameOrderByDefault(b2bExtnlInstiCd);
|
||||
logger.info("[ @@ Load B2BService getB2BService Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
String key = null;
|
||||
for (B2BService b2bService : b2bServices) {
|
||||
B2BServiceVO vo = b2bServiceMapper.toVo(b2bService);
|
||||
logger.debug("@ " + vo.toString());
|
||||
key = b2bService.getId().getExtnlinstiidnfiname() + b2bService.getId().getSvcprcssno();
|
||||
map.put(key, vo);
|
||||
}
|
||||
logger.info("[>>Load B2BService getB2BService Configuration - ended ]");
|
||||
return map;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package com.eactive.eai.common.b2bservice;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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.dao.DAOException;
|
||||
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;
|
||||
import com.eactive.eai.common.util.ObjectUtil;
|
||||
|
||||
@Component
|
||||
public class B2BServiceManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private Map<String, B2BServiceVO> b2bsMsgs = new HashMap<>();
|
||||
private boolean started;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
@Autowired
|
||||
private B2BServiceDAO b2bServiceDAO;
|
||||
|
||||
public static synchronized B2BServiceManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(B2BServiceManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICMM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICMM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
b2bsMsgs = null;
|
||||
b2bsMsgs = b2bServiceDAO.getAllB2BServices();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BServiceManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BServiceManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String b2bExtnlInstiCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BServiceManager] reload Started ...");
|
||||
}
|
||||
Map<String, B2BServiceVO> map = b2bServiceDAO.getB2BService(b2bExtnlInstiCd);
|
||||
if (map != null) {
|
||||
for (Map.Entry<String, B2BServiceVO> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
B2BServiceVO vo = entry.getValue();
|
||||
if ("1".equals(vo.getUseYn())) {
|
||||
b2bsMsgs.put(key, vo);
|
||||
} else {
|
||||
b2bsMsgs.remove(key);
|
||||
logger.warn("B2BServiceManager] reload key[" + key + "] useYn[0] removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("B2BServiceManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICMM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
b2bsMsgs.clear();
|
||||
|
||||
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 B2BServiceVO getB2BServiceVO(String b2bExtnlInstiCd, int svcPssSeq) {
|
||||
String key = b2bExtnlInstiCd + svcPssSeq;
|
||||
return getB2BServiceVO(key);
|
||||
}
|
||||
|
||||
public B2BServiceVO getB2BServiceVO(String key) {
|
||||
B2BServiceVO aMsg = b2bsMsgs.get(key);
|
||||
if (aMsg != null) {
|
||||
try {
|
||||
return (B2BServiceVO) ObjectUtil.deepCopy(aMsg);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(ExceptionUtil.getErrorCode(e, "RECEAICMM204"));
|
||||
}
|
||||
} else {
|
||||
return aMsg;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAllKeys() {
|
||||
Iterator<String> it = this.b2bsMsgs.keySet().iterator();
|
||||
String[] svcCd = new String[this.b2bsMsgs.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
svcCd[i] = it.next();
|
||||
}
|
||||
Arrays.sort(svcCd);
|
||||
return svcCd;
|
||||
}
|
||||
|
||||
public void setB2BServiceVO(String code, B2BServiceVO msg) {
|
||||
b2bsMsgs.put(code, msg);
|
||||
}
|
||||
|
||||
// db update 필요
|
||||
public void updateB2BServiceVO(String b2bExtnlInstiCd, int svcPssSeq, B2BServiceVO msg) {
|
||||
String key = b2bExtnlInstiCd + svcPssSeq;
|
||||
b2bsMsgs.put(key, msg);
|
||||
}
|
||||
|
||||
public void removeB2BServiceVO(String b2bExtnlInstiCd, int svcPssSeq, B2BServiceVO msg) {
|
||||
String key = b2bExtnlInstiCd + svcPssSeq;
|
||||
b2bsMsgs.remove(key);
|
||||
}
|
||||
|
||||
public void removeB2BServiceVO(String key) {
|
||||
b2bsMsgs.remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.eactive.eai.common.b2bservice;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
|
||||
public class B2BServiceVO implements EAIMessageKeys, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String b2bExtnlInstiCd; // 기관코드[TSEAIHE03.ExtnlInstiIdnfiName]
|
||||
private int svcPssSeq; // 서비스처리번호[TSEAIHE03.SvcPrcssNo]
|
||||
private String psvItfTp; // 수동인터페이스구분명[TSEAIHE03.PsvIntfacDsticName] - PassiveInterfaceType -
|
||||
// [SYNC|ASYN|AKON]
|
||||
private String psvBwkSysNm; // 수동시스템업무구분코드[TSEAIHE03.PsvSysBzwkDstcd] - PassiveBusinessWorkSystemName - [
|
||||
// 3|4 자리 KB표준업무시스템명 사용 ]
|
||||
private String psvSysID; // 수동시스템ID명[TSEAIHE03.PsvSysIDName] - PassiveSystemIdentifier - KB표준시스템ID Naming
|
||||
// Rule을 따른다.
|
||||
private String psvSysSvcCd; // 수동시스템서비스구분명[TSEAIHE03.PsvSysSvcDsticName] - PassiveSystemServiceCode -
|
||||
private String psvSysItfTp; // 수동시스템어댑터업무그룹명[TSEAIHE03.PsvSysAdptrBzwkGroupName] -
|
||||
// PassiveSystemInterfaceType -[Adapter_업무명_OUT]
|
||||
private String flOvrCls; // 장애극복여부[TSEAIHE03.FlovrYn] - FailOverClassification -[Y|N]
|
||||
private String cnvEn; // 변환유무[TSEAIHE03.ChngEonot] - ConversionExistenceOrNot -[Y|N]
|
||||
private String cnvMsgID; // 변환메시지ID명[TSEAIHE03.ChngMsgIDName] - ConversionMessageIdentifier
|
||||
private String bsRspMsgCprVl; // 기본응답메시지비교내용[TSEAIHE03.BascRspnsMsgCmprCtnt] -
|
||||
// BasisResponseMessageCompareValue
|
||||
private String bsRspCnvEn; // 기본응답변환유무[TSEAIHE03.BascRspnsChngEonot] -
|
||||
// BasisResponseConversionExistenceOrNot -[Y|N]
|
||||
private String bsRspCnvMsgID; // 기본응답변환메시지ID명[TSEAIHE03.BascRspnsChngMsgIDName] -
|
||||
// BasisResponseConversionMessageIdentifier
|
||||
private String errRspMsgCprVl; // 오류응답메시지비교내용[TSEAIHE03.ErrRspnsMsgCmprCtnt] - ErrorResponseMessageCompareValue
|
||||
private String errRspCnvEn; // 오류응답변환유무[TSEAIHE03.ErrRspnsChngEonot] - ErrorResponseConversionExistenceOrNot
|
||||
// -[Y|N]
|
||||
private String errRspCnvMsgID; // 오류응답변환메시지ID명[TSEAIHE03.ErrRspnsChngMsgIDName] -
|
||||
// ErrorResposneConversionIdentifier
|
||||
private int nxtSvcPssSeq; // 다음서비스처리번호[TSEAIHE03.NextSvcPrcssNo] - NextServiceProcessSequence
|
||||
private String outbRtnNm; // 아웃바운드라우팅명[TSEAIHE03.OutbndRoutName] - OutboundRoutingName
|
||||
private int tmoVl; // 타임아웃값[TSEAIHE03.ToutVal] - TimeoutValue(단위: 초)
|
||||
private String cpnsSvcPssCd; // 보상서비스처리구분명[TSEAIHE03.CmpenSvcPrcssDsticName] - CompensationServiceProcessCode
|
||||
|
||||
// 추가됨 - ServiceMessage에 추가됨에 따라 수정
|
||||
private String supplDelYn; // 추가삭제여부[TSEAIHE03.SupplDelYn] -[Y/N]
|
||||
private String hdrCtrlDstcd; // 헤더제어구분코드[TSEAIHE03.HdrCtrlDstcd] -[01/02]삭제제추가/추가삭제
|
||||
private String hdrRefClsName; // 참고틀래스명[TSEAIHE03.HdrRefClsName] -com.eactive.eai.common.header.PPSHeaderUtil
|
||||
private String useYn; // 사용여부[TSEAIHE03.UseYn] -[1/0]
|
||||
|
||||
public String getSupplDelYn() {
|
||||
return supplDelYn;
|
||||
}
|
||||
|
||||
public void setSupplDelYn(String supplDelYn) {
|
||||
this.supplDelYn = supplDelYn;
|
||||
}
|
||||
|
||||
public String getHdrCtrlDstcd() {
|
||||
return hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public void setHdrCtrlDstcd(String hdrCtrlDstcd) {
|
||||
this.hdrCtrlDstcd = hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public String getHdrRefClsName() {
|
||||
return hdrRefClsName;
|
||||
}
|
||||
|
||||
public void setHdrRefClsName(String hdrRefClsName) {
|
||||
this.hdrRefClsName = hdrRefClsName;
|
||||
}
|
||||
// END 추가됨 - ServiceMessage에 추가됨에 따라 수정
|
||||
|
||||
public String getB2bExtnlInstiCd() {
|
||||
return this.b2bExtnlInstiCd;
|
||||
}
|
||||
|
||||
public void setB2bExtnlInstiCd(String b2bExtnlInstiCd) {
|
||||
this.b2bExtnlInstiCd = b2bExtnlInstiCd;
|
||||
}
|
||||
|
||||
public String getBsRspCnvEn() {
|
||||
return bsRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isBsRspCnvEn() {
|
||||
return this.bsRspCnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setBsRspCnvEn(String bsRspCnvEn) {
|
||||
this.bsRspCnvEn = bsRspCnvEn;
|
||||
}
|
||||
|
||||
public String getBsRspCnvMsgID() {
|
||||
return bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setBsRspCnvMsgID(String bsRspCnvMsgID) {
|
||||
this.bsRspCnvMsgID = bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getBsRspMsgCprVl() {
|
||||
return bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setBsRspMsgCprVl(String bsRspMsgCprVl) {
|
||||
this.bsRspMsgCprVl = bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getCnvEn() {
|
||||
return cnvEn;
|
||||
}
|
||||
|
||||
public boolean isCnvEn() {
|
||||
return this.cnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setCnvEn(String cnvEn) {
|
||||
this.cnvEn = cnvEn;
|
||||
}
|
||||
|
||||
public String getCnvMsgID() {
|
||||
return cnvMsgID;
|
||||
}
|
||||
|
||||
public void setCnvMsgID(String cnvMsgID) {
|
||||
this.cnvMsgID = cnvMsgID;
|
||||
}
|
||||
|
||||
public String getCpnsSvcPssCd() {
|
||||
return cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public void setCpnsSvcPssCd(String cpnsSvcPssCd) {
|
||||
this.cpnsSvcPssCd = cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public String getErrRspCnvEn() {
|
||||
return errRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isErrRspCnvEn() {
|
||||
return this.errRspCnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setErrRspCnvEn(String errRspCnvEn) {
|
||||
this.errRspCnvEn = errRspCnvEn;
|
||||
}
|
||||
|
||||
public String getErrRspCnvMsgID() {
|
||||
return errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setErrRspCnvMsgID(String errRspCnvMsgID) {
|
||||
this.errRspCnvMsgID = errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getErrRspMsgCprVl() {
|
||||
return errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setErrRspMsgCprVl(String errRspMsgCprVl) {
|
||||
this.errRspMsgCprVl = errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getFlOvrCls() {
|
||||
return flOvrCls;
|
||||
}
|
||||
|
||||
public boolean hasFailOver() {
|
||||
return this.flOvrCls.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setFlOvrCls(String flOvrCls) {
|
||||
this.flOvrCls = flOvrCls;
|
||||
}
|
||||
|
||||
public int getNxtSvcPssSeq() {
|
||||
return nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public void setNxtSvcPssSeq(int nxtSvcPssSeq) {
|
||||
this.nxtSvcPssSeq = nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public String getOutbRtnNm() {
|
||||
return outbRtnNm;
|
||||
}
|
||||
|
||||
public void setOutbRtnNm(String outbRtnNm) {
|
||||
this.outbRtnNm = outbRtnNm;
|
||||
}
|
||||
|
||||
public String getPsvBwkSysNm() {
|
||||
return psvBwkSysNm;
|
||||
}
|
||||
|
||||
public void setPsvBwkSysNm(String psvBwkSysNm) {
|
||||
this.psvBwkSysNm = psvBwkSysNm;
|
||||
}
|
||||
|
||||
public String getPsvItfTp() {
|
||||
return psvItfTp;
|
||||
}
|
||||
|
||||
public boolean isSyncItfTp() {
|
||||
return this.psvItfTp.equals(SYNC_SVC);
|
||||
}
|
||||
|
||||
public boolean isAckItfTp() {
|
||||
return this.psvItfTp.equals(ACKONLY_SVC);
|
||||
}
|
||||
|
||||
public void setPsvItfTp(String psvItfTp) {
|
||||
this.psvItfTp = psvItfTp;
|
||||
}
|
||||
|
||||
public String getPsvSysID() {
|
||||
return psvSysID;
|
||||
}
|
||||
|
||||
public void setPsvSysID(String psvSysID) {
|
||||
this.psvSysID = psvSysID;
|
||||
}
|
||||
|
||||
public String getPsvSysItfTp() {
|
||||
return psvSysItfTp;
|
||||
}
|
||||
|
||||
public void setPsvSysItfTp(String psvSysItfTp) {
|
||||
this.psvSysItfTp = psvSysItfTp;
|
||||
}
|
||||
|
||||
public String getPsvSysSvcCd() {
|
||||
return psvSysSvcCd;
|
||||
}
|
||||
|
||||
public void setPsvSysSvcCd(String psvSysSvcCd) {
|
||||
this.psvSysSvcCd = psvSysSvcCd;
|
||||
}
|
||||
|
||||
public int getTmoVl() {
|
||||
return tmoVl;
|
||||
}
|
||||
|
||||
public boolean hasTimeOut() {
|
||||
return (this.tmoVl > 0);
|
||||
}
|
||||
|
||||
public void setTmoVl(int tmoVl) {
|
||||
this.tmoVl = tmoVl;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq() {
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int seq) {
|
||||
svcPssSeq = seq;
|
||||
}
|
||||
|
||||
public String getUseYn() {
|
||||
return useYn;
|
||||
}
|
||||
|
||||
public void setUseYn(String useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "B2BServiceVO [b2bExtnlInstiCd=" + b2bExtnlInstiCd + ", svcPssSeq=" + svcPssSeq + ", psvItfTp="
|
||||
+ psvItfTp + ", psvBwkSysNm=" + psvBwkSysNm + ", psvSysID=" + psvSysID + ", psvSysSvcCd=" + psvSysSvcCd
|
||||
+ ", psvSysItfTp=" + psvSysItfTp + ", flOvrCls=" + flOvrCls + ", cnvEn=" + cnvEn + ", cnvMsgID="
|
||||
+ cnvMsgID + ", bsRspMsgCprVl=" + bsRspMsgCprVl + ", bsRspCnvEn=" + bsRspCnvEn + ", bsRspCnvMsgID="
|
||||
+ bsRspCnvMsgID + ", errRspMsgCprVl=" + errRspMsgCprVl + ", errRspCnvEn=" + errRspCnvEn
|
||||
+ ", errRspCnvMsgID=" + errRspCnvMsgID + ", nxtSvcPssSeq=" + nxtSvcPssSeq + ", outbRtnNm=" + outbRtnNm
|
||||
+ ", tmoVl=" + tmoVl + ", cpnsSvcPssCd=" + cpnsSvcPssCd + ", supplDelYn=" + supplDelYn
|
||||
+ ", hdrCtrlDstcd=" + hdrCtrlDstcd + ", hdrRefClsName=" + hdrRefClsName + ", useYn=" + useYn + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.eactive.eai.common.b2bservice.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.b2bservice.B2BServiceVO;
|
||||
import com.eactive.eai.data.entity.onl.b2bservice.B2BService;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface B2BServiceMapper extends GenericMapper<B2BServiceVO, B2BService> {
|
||||
|
||||
@Mapping(source = "id.extnlinstiidnfiname", target = "b2bExtnlInstiCd")
|
||||
@Mapping(source = "id.svcprcssno", target = "svcPssSeq")
|
||||
@Mapping(source = "psvintfacdsticname", target = "psvItfTp")
|
||||
@Mapping(source = "psvsysbzwkdstcd", target = "psvBwkSysNm")
|
||||
@Mapping(source = "psvsysidname", target = "psvSysID")
|
||||
@Mapping(source = "psvsyssvcdsticname", target = "psvSysSvcCd")
|
||||
@Mapping(source = "psvsysadptrbzwkgroupname", target = "psvSysItfTp")
|
||||
@Mapping(source = "flovryn", target = "flOvrCls")
|
||||
@Mapping(source = "chngeonot", target = "cnvEn")
|
||||
@Mapping(source = "chngmsgidname", target = "cnvMsgID")
|
||||
@Mapping(source = "bascrspnsmsgcmprctnt", target = "bsRspMsgCprVl")
|
||||
@Mapping(source = "bascrspnschngeonot", target = "bsRspCnvEn")
|
||||
@Mapping(source = "bascrspnschngmsgidname", target = "bsRspCnvMsgID")
|
||||
@Mapping(source = "errrspnsmsgcmprctnt", target = "errRspMsgCprVl")
|
||||
@Mapping(source = "errrspnschngeonot", target = "errRspCnvEn")
|
||||
@Mapping(source = "errrspnschngmsgidname", target = "errRspCnvMsgID")
|
||||
@Mapping(source = "nextsvcprcssno", target = "nxtSvcPssSeq")
|
||||
@Mapping(source = "outbndroutname", target = "outbRtnNm")
|
||||
@Mapping(source = "toutval", target = "tmoVl")
|
||||
@Mapping(source = "cmpensvcprcssdsticname", target = "cpnsSvcPssCd")
|
||||
@Mapping(source = "suppldelyn", target = "supplDelYn")
|
||||
@Mapping(source = "hdrctrldstcd", target = "hdrCtrlDstcd")
|
||||
@Mapping(source = "hdrrefclsname", target = "hdrRefClsName")
|
||||
@Mapping(source = "useyn", target = "useYn")
|
||||
@Override
|
||||
B2BServiceVO toVo(B2BService entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
B2BService toEntity(B2BServiceVO vo);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import java.util.Collection;
|
||||
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.bizkey.loader.BizKeyLoader;
|
||||
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.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.bizkey.BizKey;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class BizKeyDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private BizKeyLoader bizKeyLoader;
|
||||
|
||||
public Map<String, BizKeyVO> getAllBizKeys() throws Exception {
|
||||
|
||||
try {
|
||||
List<BizKey> bizKeys = bizKeyLoader.findAllOrderByDefault();
|
||||
Map<String, BizKeyVO> msgKeys = new HashMap<>();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("[ @@ Load BizKey Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
}
|
||||
for (BizKey bizKey : bizKeys) {
|
||||
String key = bizKey.getId().getEaisvcname() + bizKey.getId().getEtractdstcd();
|
||||
BizKeyVO vo = msgKeys.get(key);
|
||||
|
||||
if (vo == null) {
|
||||
vo = new BizKeyVO(bizKey.getId().getEaisvcname(), bizKey.getId().getEtractdstcd());
|
||||
msgKeys.put(key, vo);
|
||||
}
|
||||
|
||||
vo.addBizKeyFld(bizKey.getMsgdstcd(), bizKey.getBzwkfldname());
|
||||
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("[>>Load BizKey Configuration - ended ]");
|
||||
}
|
||||
return msgKeys;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, BizKeyVO> getBizKey(String eaiSvcCd, String exrClsNm) throws Exception {
|
||||
try {
|
||||
Map<String, BizKeyVO> msgKeys = new HashMap<>();
|
||||
Collection<BizKey> bizKeys = bizKeyLoader.findByIdEaisvcnameAndIdEtractdstcd(eaiSvcCd, exrClsNm);
|
||||
logger.info("[ @@ Load BizKey getBizKey Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (BizKey bizKey : bizKeys) {
|
||||
String key = bizKey.getId().getEaisvcname() + bizKey.getId().getEtractdstcd();
|
||||
BizKeyVO vo = msgKeys.get(key);
|
||||
|
||||
if (vo == null) {
|
||||
vo = new BizKeyVO(eaiSvcCd, exrClsNm);
|
||||
msgKeys.put(key, vo);
|
||||
}
|
||||
|
||||
vo.addBizKeyFld(bizKey.getId().getFldprcssno(), bizKey.getMsgdstcd(), bizKey.getBzwkfldname());
|
||||
}
|
||||
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("BizKeyFldVO in getBizKey():");
|
||||
for (BizKeyVO vo : msgKeys.values()) {
|
||||
for (BizKeyFldVO fldVO : vo.getAlMsgFlds()) {
|
||||
logger.info("BizKeyFld getBizKey --->> " + fldVO.toString());
|
||||
}
|
||||
}
|
||||
logger.info("[>>Load BizKey getBizKey Configuration - ended ]");
|
||||
}
|
||||
return msgKeys;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICBM205"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BizKeyFldVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int colPssSeq; // 순번 [TSEAIFR03.FldPrcssNo]
|
||||
private String msgTp; // 메시지유형 [TSEAIFR03.MsgDstcd]
|
||||
private String bwkColNm; // 업무필드명 [TSEAIFR03.BzwkFldName]
|
||||
|
||||
public BizKeyFldVO(int colPssSeq, String msgTp, String bwkColNm) {
|
||||
this.colPssSeq = colPssSeq;
|
||||
this.msgTp = msgTp;
|
||||
this.bwkColNm = bwkColNm;
|
||||
}
|
||||
|
||||
public void setColPssSeq(int colPssSeq) {
|
||||
this.colPssSeq = colPssSeq;
|
||||
}
|
||||
|
||||
public int getColPssSeq() {
|
||||
return this.colPssSeq;
|
||||
}
|
||||
|
||||
public void setMsgTp(String msgTp) {
|
||||
this.msgTp = msgTp;
|
||||
}
|
||||
|
||||
public String getMsgTp() {
|
||||
return this.msgTp;
|
||||
}
|
||||
|
||||
public void setBwkColNm(String bwkColNm) {
|
||||
this.bwkColNm = bwkColNm;
|
||||
}
|
||||
|
||||
public String getBwkColNm() {
|
||||
return this.bwkColNm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("BizKeyFldVO {")
|
||||
.append("colPssSeq=").append(colPssSeq).append(", ")
|
||||
.append("msgTp='").append(msgTp).append("', ")
|
||||
.append("bwkColNm='").append(bwkColNm).append("'")
|
||||
.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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 BizKeyManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private Map<String, BizKeyVO> messages = new HashMap<>();
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
private boolean started;
|
||||
|
||||
@Autowired
|
||||
private BizKeyDAO bizKeyDAO;
|
||||
|
||||
public static BizKeyManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(BizKeyManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICBM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICBM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
messages = null;
|
||||
messages = bizKeyDAO.getAllBizKeys();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("BizKeyManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("BizKeyManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String eaiSvcCd, String exrClsNm) throws Exception {
|
||||
Map<String, BizKeyVO> map = bizKeyDAO.getBizKey(eaiSvcCd, exrClsNm);
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
|
||||
String key = "";
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
messages.put(key, map.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICBM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
messages.clear();
|
||||
|
||||
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 BizKeyVO getBizKey(String code) {
|
||||
return messages.get(code);
|
||||
}
|
||||
|
||||
public BizKeyVO getBizKey(String eaiSvcCd, String exrClsNm) {
|
||||
return messages.get(eaiSvcCd + exrClsNm);
|
||||
}
|
||||
|
||||
public void setBizKey(String code, BizKeyVO msg) {
|
||||
messages.put(code, msg);
|
||||
}
|
||||
|
||||
public void setBizKey(String eaiSvcCd, String exrClsNm, BizKeyVO vo) {
|
||||
messages.put(eaiSvcCd + exrClsNm, vo);
|
||||
}
|
||||
|
||||
public void updateBizKey(String eaiSvcCd, String exrClsNm, BizKeyVO vo) {
|
||||
messages.put(eaiSvcCd + exrClsNm, vo);
|
||||
}
|
||||
|
||||
public void removeBizKey(String code) {
|
||||
messages.remove(code);
|
||||
}
|
||||
|
||||
public String[] getAllKeyNames() {
|
||||
Iterator<String> it = this.messages.keySet().iterator();
|
||||
String[] name = new String[this.messages.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
name[i] = it.next();
|
||||
}
|
||||
Arrays.sort(name);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BizKeyVO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String eaiSvcCd; // EAI 서비스코드 [TSEAIFR03.EAISvcName]
|
||||
private String exrClsNm; // 추출구분 [TSEAIFR03.EtractDstcd] (추적필드(TR) | ALT-KEY(AK))
|
||||
|
||||
private ArrayList<BizKeyFldVO> alMsgFlds;
|
||||
|
||||
public BizKeyVO() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public BizKeyVO(String eaiSvcCd) {
|
||||
this(eaiSvcCd, "");
|
||||
}
|
||||
|
||||
public BizKeyVO(String eaiSvcCd, String exrClsNm) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
this.exrClsNm = exrClsNm;
|
||||
this.alMsgFlds = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setEaiSvcCd(String eaiSvcCd) {
|
||||
this.eaiSvcCd = eaiSvcCd;
|
||||
}
|
||||
|
||||
public String getEaiSvcCd() {
|
||||
return this.eaiSvcCd;
|
||||
}
|
||||
|
||||
public void setExrClsNm(String exrClsNm) {
|
||||
this.exrClsNm = exrClsNm;
|
||||
}
|
||||
|
||||
public String getExrClsNm() {
|
||||
return this.exrClsNm;
|
||||
}
|
||||
|
||||
public BizKeyFldVO getBizKeyFld(int key) {
|
||||
BizKeyFldVO vo = alMsgFlds.get(key);
|
||||
if (vo == null)
|
||||
return null;
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
public void addBizKeyFld(String msgTp, String bwkColNm) {
|
||||
int alSize = this.alMsgFlds.size();
|
||||
this.alMsgFlds.add(new BizKeyFldVO(alSize + 1, msgTp, bwkColNm));
|
||||
}
|
||||
|
||||
public void addBizKeyFld(int colPssSeq, String msgTp, String bwkColNm) {
|
||||
this.alMsgFlds.add(new BizKeyFldVO(colPssSeq, msgTp, bwkColNm));
|
||||
}
|
||||
|
||||
public int getBizKeyFldLength() {
|
||||
return this.alMsgFlds.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BizKeyFldVO [alMsgFlds=" + printMessageFields() + "]";
|
||||
}
|
||||
|
||||
private String printMessageFields() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
alMsgFlds.forEach( field -> sb.append(field.toString()).append("\n | ") );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public List<BizKeyFldVO> getAlMsgFlds() {
|
||||
return alMsgFlds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.eactive.eai.common.bpa;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.message.CondPerRtgInfo;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.transformer.function.util.CodeConversion;
|
||||
import com.eactive.eai.transformer.layout.Layout;
|
||||
import com.eactive.eai.transformer.message.EbcdicMessage;
|
||||
import com.eactive.eai.transformer.message.Message;
|
||||
import com.eactive.eai.transformer.message.MessageFactory;
|
||||
import com.eactive.eai.transformer.message.XMLMessage;
|
||||
import com.eactive.eai.transformer.transform.Transform;
|
||||
import com.eactive.eai.transformer.transform.TransformManager;
|
||||
|
||||
/**
|
||||
* 1. 기능 : 복합거래 FlowControl에서
|
||||
* EAI 서비스메시지에 등록된 조건부 라우팅 룰에 대한 제어(TRUE/FALSE)를 처리하는 기능을 담당한다
|
||||
* 2. 처리 개요 :
|
||||
* - 응답메시지의 특정키갑을 정상값과 비교
|
||||
* - 정상인 경우 결과처리번호(다음처리순번), 오류인경우 -1을 리턴한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public final class RuleManager {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private RuleManager() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 업무메시지에서 추적필드를 추출하는 함수 2. 처리 개요 : - BizKeyManager에서 Rule정보를 조회 - 조회된
|
||||
* Rule을 기반으로 기능 처리 3. 주의사항
|
||||
*
|
||||
* @param eaiSvcCd EAI서비스코드
|
||||
* @param messageID EAI 헤더에 정의된 메시지ID
|
||||
* @param message 업무메시지 Object
|
||||
* @return 결과 String 값(추적필드값)
|
||||
* @exception Exception
|
||||
*/
|
||||
public static int getNextServieSeq(EAIMessage eaiMsg) throws Exception {
|
||||
try {
|
||||
String transformName = eaiMsg.getCurrentSvcMsg().getBsRspCnvMsgID();
|
||||
Object message = eaiMsg.getStandardMessage().getBizData();
|
||||
|
||||
if (message == null) {
|
||||
logger.error("RoutingRuleManager] 응답메시지가 NULL입니다 - " + message);
|
||||
throw new Exception("RECEAICRR003");
|
||||
}
|
||||
|
||||
logger.debug("RoutingRuleManager] 서비스메시지 [ " + eaiMsg.getCurrentSvcMsg().getSvcPssSeq() + " ] 에 대한 변환명은 [ "
|
||||
+ transformName + " ]입니다.");
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Message Object 생성
|
||||
// ----------------------------------------------------
|
||||
TransformManager manager = TransformManager.getManager();
|
||||
Transform info = manager.getTransform(transformName);
|
||||
if (info == null)
|
||||
throw new Exception("변환 정보를 찾을 수 없습니다.. - " + transformName);
|
||||
Layout l = info.getTargetLayout();
|
||||
String messageID = l.getName();
|
||||
if (messageID == null) {
|
||||
logger.error("RoutingRuleManager] Message ID is null.");
|
||||
throw new RuntimeException("RECEAICRR004");
|
||||
}
|
||||
|
||||
Message msg = MessageFactory.getFactory().getMessage(messageID);
|
||||
logger.debug("RoutingRuleManager] layoutType [ " + l.getLayoutType().getName() + " ]");
|
||||
if (l.getLayoutType().getName().equals("XML")) {
|
||||
|
||||
String xmlString = "";
|
||||
if (message instanceof byte[]) {
|
||||
xmlString = new String((byte[]) message);
|
||||
} else {
|
||||
xmlString = (String) message;
|
||||
}
|
||||
String rootItemName = ((XMLMessage) msg).getLayout().getRootItem().getName();
|
||||
|
||||
xmlString = MessageUtil.removeXMLHeader(xmlString);
|
||||
xmlString = "<" + rootItemName + ">" + xmlString + "</" + rootItemName + ">";
|
||||
msg.setData(xmlString);
|
||||
} else if (l.getLayoutType().getName().equals("BYTES") || l.getLayoutType().getName().equals("EBCDIC")) {
|
||||
msg.setData(message);
|
||||
} else {
|
||||
msg.setData(message);
|
||||
}
|
||||
|
||||
// Routing Rule 조회
|
||||
List<CondPerRtgInfo> condPerRtgInfoList = eaiMsg.getCurrentSvcMsg().getCondPerRtgInfo();
|
||||
|
||||
String prcssNo = "-1";
|
||||
if (condPerRtgInfoList != null) {
|
||||
int ruleSize = condPerRtgInfoList.size();
|
||||
|
||||
for (int i = 0; i < ruleSize; i++) {
|
||||
CondPerRtgInfo rtnInfo = condPerRtgInfoList.get(i);
|
||||
|
||||
prcssNo = rtnInfo.getRsultPrcssNo();
|
||||
|
||||
String defVal = rtnInfo.getRuleCprTxt(); // 비교내용
|
||||
String colName = rtnInfo.getRuleColNm(); // 규칙필드명
|
||||
String keyVal = "";
|
||||
if (msg instanceof EbcdicMessage) {
|
||||
keyVal = new String(CodeConversion.seToAsc(msg.getByteArray(colName)));
|
||||
} else {
|
||||
keyVal = msg.getString(colName);
|
||||
}
|
||||
|
||||
if (!defVal.equals(keyVal)) {
|
||||
logger.info("RoutingRuleManager] FALSE RETURN[" + keyVal + " : " + defVal + " ]");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 정상 Routing Rule 리턴
|
||||
int iprcssNo = -1;
|
||||
|
||||
try {
|
||||
iprcssNo = Integer.parseInt(prcssNo);
|
||||
} catch (Exception nfe) {
|
||||
logger.error("RoutingRuleManager] Invalid RsultPrcssNo [" + prcssNo + "]" + nfe.getMessage());
|
||||
throw new Exception("RECEAICRR002");
|
||||
}
|
||||
return iprcssNo;
|
||||
} catch (Exception e) {
|
||||
throw new Exception(ExceptionUtil.getErrorCode(e, "RECEAICRR001"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.eactive.eai.common.c2rservice;
|
||||
|
||||
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.c2rservice.loader.C2RServiceLoader;
|
||||
import com.eactive.eai.common.c2rservice.mapper.C2RServiceMapper;
|
||||
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.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.c2rservice.C2RService;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class C2RServiceDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
C2RServiceLoader c2rServiceEntityService;
|
||||
|
||||
@Autowired
|
||||
C2RServiceMapper c2rServiceMapper;
|
||||
|
||||
public Map<String, C2RServiceVO> getAllC2RServices() throws DAOException {
|
||||
try {
|
||||
HashMap<String, C2RServiceVO> c2rMap = new HashMap<>();
|
||||
List<C2RService> c2rServices = c2rServiceEntityService.findByUseynOrderByDefault("1");
|
||||
logger.info("[ @@ Load C2RService Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (C2RService c2rService : c2rServices) {
|
||||
C2RServiceVO vo = c2rServiceMapper.toVo(c2rService);
|
||||
logger.info("@ " + vo.toString());
|
||||
String key = c2rService.getId().getExtnlinstiidnfiname() + c2rService.getId().getSvcprcssno();
|
||||
c2rMap.put(key, vo);
|
||||
}
|
||||
logger.info("[>>Load C2RService Configuration - ended ]");
|
||||
return c2rMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, C2RServiceVO> getC2RService(String c2rExtnlInstiCd) throws DAOException {
|
||||
try {
|
||||
HashMap<String, C2RServiceVO> c2rMap = new HashMap<>();
|
||||
C2RService c2rService = c2rServiceEntityService.findByIdExtnlinstiidnfinameOrderByDefault(c2rExtnlInstiCd);
|
||||
logger.info("[ @@ Load C2RService getC2RService Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
if (c2rService != null) {
|
||||
C2RServiceVO vo = c2rServiceMapper.toVo(c2rService);
|
||||
logger.info("@ " + vo.toString());
|
||||
String key = c2rService.getId().getExtnlinstiidnfiname() + c2rService.getId().getSvcprcssno();
|
||||
c2rMap.put(key, vo);
|
||||
}
|
||||
|
||||
logger.info("[>>Load C2RService getC2RService Configuration - ended ]");
|
||||
return c2rMap;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.eactive.eai.common.c2rservice;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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.dao.DAOException;
|
||||
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;
|
||||
import com.eactive.eai.common.util.ObjectUtil;
|
||||
|
||||
@Component
|
||||
public class C2RServiceManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
C2RServiceDAO c2rServiceDAO;
|
||||
|
||||
private Map<String, C2RServiceVO> c2rsMsgs = new HashMap<>();
|
||||
private boolean started;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
public static synchronized C2RServiceManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(C2RServiceManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICMM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICMM202"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
c2rsMsgs = null;
|
||||
c2rsMsgs = c2rServiceDAO.getAllC2RServices();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("C2RExtractManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("C2RExtractManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String c2rExtnlInstiCd) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("C2RExtractManager] reload Started ...");
|
||||
}
|
||||
Map<String, C2RServiceVO> map = c2rServiceDAO.getC2RService(c2rExtnlInstiCd);
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = "";
|
||||
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
C2RServiceVO vo = map.get(key);
|
||||
if ("1".equals(vo.getUseYn())) {
|
||||
c2rsMsgs.put(key, map.get(key));
|
||||
} else {
|
||||
c2rsMsgs.remove(key);
|
||||
logger.warn("C2RServiceManager] reload key[" + key + "] useYn[0] removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("C2RExtractManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICMM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
c2rsMsgs.clear();
|
||||
|
||||
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 C2RServiceVO getC2RServiceVO(String c2rExtnlInstiCd, int svcPssSeq) {
|
||||
String key = c2rExtnlInstiCd + svcPssSeq;
|
||||
return getC2RServiceVO(key);
|
||||
}
|
||||
|
||||
public C2RServiceVO getC2RServiceVO(String key) {
|
||||
C2RServiceVO aMsg = c2rsMsgs.get(key);
|
||||
if (aMsg != null) {
|
||||
try {
|
||||
return (C2RServiceVO) ObjectUtil.deepCopy(aMsg);
|
||||
} catch (Exception e) {
|
||||
if (logger.isError())
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new RuntimeException(ExceptionUtil.getErrorCode(e, "RECEAICMM204"));
|
||||
}
|
||||
} else {
|
||||
return aMsg;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAllKeys() {
|
||||
Iterator<String> it = this.c2rsMsgs.keySet().iterator();
|
||||
String[] svcCd = new String[this.c2rsMsgs.size()];
|
||||
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
svcCd[i] = it.next();
|
||||
}
|
||||
Arrays.sort(svcCd);
|
||||
return svcCd;
|
||||
}
|
||||
|
||||
public void setC2RServiceVO(String code, C2RServiceVO vo) {
|
||||
c2rsMsgs.put(code, vo);
|
||||
}
|
||||
|
||||
// db update 필요
|
||||
public void updateC2RServiceVO(String c2rExtnlInstiCd, int svcPssSeq, C2RServiceVO vo) {
|
||||
String key = c2rExtnlInstiCd + svcPssSeq;
|
||||
c2rsMsgs.put(key, vo);
|
||||
}
|
||||
|
||||
public void removeC2RServiceVO(String c2rExtnlInstiCd, int svcPssSeq, C2RServiceVO vo) {
|
||||
String key = c2rExtnlInstiCd + svcPssSeq;
|
||||
c2rsMsgs.remove(key);
|
||||
}
|
||||
|
||||
public void removeC2RServiceVO(String key) {
|
||||
c2rsMsgs.remove(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package com.eactive.eai.common.c2rservice;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
|
||||
|
||||
public class C2RServiceVO implements EAIMessageKeys, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String c2rExtnlInstiCd; // 외부기관식별명 [TSEAIHE04.extnlinstiidnfiname]
|
||||
private int svcPssSeq; // 서비스처리순서 [TSEAIHE04.svcprcssno]
|
||||
private String psvItfTp; // 수동인터페이스유형 [TSEAIHE04.psvintfacdsticname]
|
||||
private String psvBwkSysNm; // 수동업무시스템명 [TSEAIHE04.psvsysbzwkdstcd]
|
||||
private String psvSysID; // 수동시스템ID [TSEAIHE04.psvsysidname]
|
||||
private String psvSysSvcCd; // 수동시스템서비스코드 [TSEAIHE04.psvsyssvcdsticname]
|
||||
private String psvSysItfTp; // 수동시스템어댑터업무그룹명 [TSEAIHE04.psvsysadptrbzwkgroupname]
|
||||
private String flOvrCls; // FailOver여부 [TSEAIHE04.flovryn]
|
||||
private String cnvEn; // 변환유무 [TSEAIHE04.chngeonot]
|
||||
private String cnvMsgID; // 변환메시지ID [TSEAIHE04.chngmsgidname]
|
||||
private String bsRspMsgCprVl; // 기본응답메시지비교값 [TSEAIHE04.bascrspnsmsgcmprctnt]
|
||||
private String bsRspCnvEn; // 기본응답변환유무 [TSEAIHE04.bascrspnschngeonot]
|
||||
private String bsRspCnvMsgID; // 기본응답변환메시지ID [TSEAIHE04.bascrspnschngmsgidname]
|
||||
private String errRspMsgCprVl; // 오류응답메시지비교값 [TSEAIHE04.errrspnsmsgcmprctnt]
|
||||
private String errRspCnvEn; // 오류응답변환유무 [TSEAIHE04.errrspnschngeonot]
|
||||
private String errRspCnvMsgID; // 오류응답변환메시지ID [TSEAIHE04.errrspnschngmsgidname]
|
||||
private int nxtSvcPssSeq; // 다음서비스처리번호 [TSEAIHE04.nextsvcprcssno]
|
||||
private String outbRtnNm; // Outbound라우팅명 [TSEAIHE04.outbndroutname]
|
||||
private int tmoVl; // 타임아웃값 [TSEAIHE04.toutval]
|
||||
private String cpnsSvcPssCd; // 보상서비스처리코드 [TSEAIHE04.cmpensvcprcssdsticname]
|
||||
|
||||
private String supplDelYn; // 추가삭제여부 [TSEAIHE04.suppldelyn]
|
||||
private String hdrCtrlDstcd; // 헤더제어구분코드 [TSEAIHE04.hdrctrldstcd]
|
||||
private String hdrRefClsName; // 참고클래스명 [TSEAIHE04.hdrrefclsname]
|
||||
private String useYn; // 사용여부 [TSEAIHE04.useyn]
|
||||
|
||||
public String getSupplDelYn() {
|
||||
return supplDelYn;
|
||||
}
|
||||
|
||||
public void setSupplDelYn(String supplDelYn) {
|
||||
this.supplDelYn = supplDelYn;
|
||||
}
|
||||
|
||||
public String getHdrCtrlDstcd() {
|
||||
return hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public void setHdrCtrlDstcd(String hdrCtrlDstcd) {
|
||||
this.hdrCtrlDstcd = hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public String getHdrRefClsName() {
|
||||
return hdrRefClsName;
|
||||
}
|
||||
|
||||
public void setHdrRefClsName(String hdrRefClsName) {
|
||||
this.hdrRefClsName = hdrRefClsName;
|
||||
}
|
||||
|
||||
public String getC2rExtnlInstiCd() {
|
||||
return this.c2rExtnlInstiCd;
|
||||
}
|
||||
|
||||
public void setC2rExtnlInstiCd(String c2rExtnlInstiCd) {
|
||||
this.c2rExtnlInstiCd = c2rExtnlInstiCd;
|
||||
}
|
||||
|
||||
public String getBsRspCnvEn() {
|
||||
return bsRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isBsRspCnvEn() {
|
||||
return this.bsRspCnvEn.equals( YES_FLAG );
|
||||
}
|
||||
|
||||
public void setBsRspCnvEn(String bsRspCnvEn) {
|
||||
this.bsRspCnvEn = bsRspCnvEn;
|
||||
}
|
||||
|
||||
public String getBsRspCnvMsgID() {
|
||||
return bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setBsRspCnvMsgID(String bsRspCnvMsgID) {
|
||||
this.bsRspCnvMsgID = bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getBsRspMsgCprVl() {
|
||||
return bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setBsRspMsgCprVl(String bsRspMsgCprVl) {
|
||||
this.bsRspMsgCprVl = bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getCnvEn() {
|
||||
return cnvEn;
|
||||
}
|
||||
|
||||
public boolean isCnvEn() {
|
||||
return this.cnvEn.equals( YES_FLAG );
|
||||
}
|
||||
|
||||
public void setCnvEn(String cnvEn) {
|
||||
this.cnvEn = cnvEn;
|
||||
}
|
||||
|
||||
public String getCnvMsgID() {
|
||||
return cnvMsgID;
|
||||
}
|
||||
|
||||
public void setCnvMsgID(String cnvMsgID) {
|
||||
this.cnvMsgID = cnvMsgID;
|
||||
}
|
||||
|
||||
public String getCpnsSvcPssCd() {
|
||||
return cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public void setCpnsSvcPssCd(String cpnsSvcPssCd) {
|
||||
this.cpnsSvcPssCd = cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public String getErrRspCnvEn() {
|
||||
return errRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isErrRspCnvEn() {
|
||||
return this.errRspCnvEn.equals( YES_FLAG );
|
||||
}
|
||||
|
||||
public void setErrRspCnvEn(String errRspCnvEn) {
|
||||
this.errRspCnvEn = errRspCnvEn;
|
||||
}
|
||||
|
||||
public String getErrRspCnvMsgID() {
|
||||
return errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setErrRspCnvMsgID(String errRspCnvMsgID) {
|
||||
this.errRspCnvMsgID = errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getErrRspMsgCprVl() {
|
||||
return errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setErrRspMsgCprVl(String errRspMsgCprVl) {
|
||||
this.errRspMsgCprVl = errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getFlOvrCls() {
|
||||
return flOvrCls;
|
||||
}
|
||||
|
||||
public boolean hasFailOver() {
|
||||
return this.flOvrCls.equals( YES_FLAG );
|
||||
}
|
||||
|
||||
public void setFlOvrCls(String flOvrCls) {
|
||||
this.flOvrCls = flOvrCls;
|
||||
}
|
||||
|
||||
public int getNxtSvcPssSeq() {
|
||||
return nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public void setNxtSvcPssSeq(int nxtSvcPssSeq) {
|
||||
this.nxtSvcPssSeq = nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public String getOutbRtnNm() {
|
||||
return outbRtnNm;
|
||||
}
|
||||
|
||||
public void setOutbRtnNm(String outbRtnNm) {
|
||||
this.outbRtnNm = outbRtnNm;
|
||||
}
|
||||
|
||||
public String getPsvBwkSysNm() {
|
||||
return psvBwkSysNm;
|
||||
}
|
||||
|
||||
public void setPsvBwkSysNm(String psvBwkSysNm) {
|
||||
this.psvBwkSysNm = psvBwkSysNm;
|
||||
}
|
||||
|
||||
public String getPsvItfTp() {
|
||||
return psvItfTp;
|
||||
}
|
||||
|
||||
public boolean isSyncItfTp() {
|
||||
return this.psvItfTp.equals( SYNC_SVC );
|
||||
}
|
||||
|
||||
public boolean isAckItfTp() {
|
||||
return this.psvItfTp.equals( ACKONLY_SVC );
|
||||
}
|
||||
|
||||
public void setPsvItfTp(String psvItfTp) {
|
||||
this.psvItfTp = psvItfTp;
|
||||
}
|
||||
|
||||
public String getPsvSysID() {
|
||||
return psvSysID;
|
||||
}
|
||||
|
||||
public void setPsvSysID(String psvSysID) {
|
||||
this.psvSysID = psvSysID;
|
||||
}
|
||||
|
||||
public String getPsvSysItfTp() {
|
||||
return psvSysItfTp;
|
||||
}
|
||||
|
||||
|
||||
public void setPsvSysItfTp(String psvSysItfTp) {
|
||||
this.psvSysItfTp = psvSysItfTp;
|
||||
}
|
||||
|
||||
|
||||
public String getPsvSysSvcCd() {
|
||||
return psvSysSvcCd;
|
||||
}
|
||||
|
||||
public void setPsvSysSvcCd(String psvSysSvcCd) {
|
||||
this.psvSysSvcCd = psvSysSvcCd;
|
||||
}
|
||||
|
||||
public int getTmoVl() {
|
||||
return tmoVl;
|
||||
}
|
||||
|
||||
public boolean hasTimeOut() {
|
||||
return ( this.tmoVl > 0 );
|
||||
}
|
||||
|
||||
public void setTmoVl(int tmoVl) {
|
||||
this.tmoVl = tmoVl;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq(){
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int seq){
|
||||
svcPssSeq = seq;
|
||||
}
|
||||
|
||||
public String getUseYn() {
|
||||
return useYn;
|
||||
}
|
||||
|
||||
public void setUseYn(String useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.eactive.eai.common.c2rservice.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.c2rservice.C2RServiceVO;
|
||||
import com.eactive.eai.data.entity.onl.c2rservice.C2RService;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface C2RServiceMapper extends GenericMapper<C2RServiceVO, C2RService> {
|
||||
|
||||
@Mapping(source = "id.extnlinstiidnfiname", target = "c2rExtnlInstiCd")
|
||||
@Mapping(source = "id.svcprcssno", target = "svcPssSeq")
|
||||
@Mapping(source = "bascrspnschngeonot", target = "bsRspCnvEn")
|
||||
@Mapping(source = "bascrspnschngmsgidname", target = "bsRspCnvMsgID")
|
||||
@Mapping(source = "bascrspnsmsgcmprctnt", target = "bsRspMsgCprVl")
|
||||
@Mapping(source = "chngeonot", target = "cnvEn")
|
||||
@Mapping(source = "chngmsgidname", target = "cnvMsgID")
|
||||
@Mapping(source = "cmpensvcprcssdsticname", target = "cpnsSvcPssCd")
|
||||
@Mapping(source = "errrspnschngeonot", target = "errRspCnvEn")
|
||||
@Mapping(source = "errrspnschngmsgidname", target = "errRspCnvMsgID")
|
||||
@Mapping(source = "errrspnsmsgcmprctnt", target = "errRspMsgCprVl")
|
||||
@Mapping(source = "flovryn", target = "flOvrCls")
|
||||
@Mapping(source = "hdrctrldstcd", target = "hdrCtrlDstcd")
|
||||
@Mapping(source = "hdrrefclsname", target = "hdrRefClsName")
|
||||
@Mapping(source = "nextsvcprcssno", target = "nxtSvcPssSeq")
|
||||
@Mapping(source = "outbndroutname", target = "outbRtnNm")
|
||||
@Mapping(source = "psvintfacdsticname", target = "psvItfTp")
|
||||
@Mapping(source = "psvsysadptrbzwkgroupname", target = "psvSysItfTp")
|
||||
@Mapping(source = "psvsysbzwkdstcd", target = "psvBwkSysNm")
|
||||
@Mapping(source = "psvsysidname", target = "psvSysID")
|
||||
@Mapping(source = "psvsyssvcdsticname", target = "psvSysSvcCd")
|
||||
@Mapping(source = "suppldelyn", target = "supplDelYn")
|
||||
@Mapping(source = "toutval", target = "tmoVl")
|
||||
@Mapping(source = "useyn", target = "useYn")
|
||||
@Override
|
||||
C2RServiceVO toVo(C2RService entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
C2RService toEntity(C2RServiceVO vo);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.eactive.eai.common.circuitBreaker;
|
||||
|
||||
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.property.PropManager;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
|
||||
import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig;
|
||||
import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry;
|
||||
import io.github.resilience4j.micrometer.tagged.TaggedCircuitBreakerMetrics;
|
||||
import io.micrometer.prometheus.PrometheusConfig;
|
||||
import io.micrometer.prometheus.PrometheusMeterRegistry;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class CircuitBreakerManager implements Lifecycle {
|
||||
|
||||
PrometheusMeterRegistry meterRegistry;
|
||||
CircuitBreakerRegistry circuitBreakerRegistry;
|
||||
// CircuitBreakerConfig config;
|
||||
|
||||
// Map<String, CircuitBreaker> circuitBreakerMap = new HashMap<>();
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static CircuitBreakerManager INSTANCE ;
|
||||
|
||||
private boolean started;
|
||||
|
||||
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
public static synchronized CircuitBreakerManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new CircuitBreakerManager();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void addLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
public LifecycleListener[] findLifecycleListeners() {
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
public void removeLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
private void init(){
|
||||
meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
||||
|
||||
int failureRateThreshold = NumberUtils.toInt(PropManager.getInstance().getProperty("CircuitBreaker", "failureRateThreshold"), 50);
|
||||
int slidingWindowSize = NumberUtils.toInt(PropManager.getInstance().getProperty("CircuitBreaker", "slidingWindowSize"), 100);
|
||||
int minimumNumberOfCalls = NumberUtils.toInt(PropManager.getInstance().getProperty("CircuitBreaker", "minimumNumberOfCalls"), 100);
|
||||
int waitDurationInOpenState = NumberUtils.toInt(PropManager.getInstance().getProperty("CircuitBreaker", "waitDurationInOpenState"), 60);
|
||||
int permittedNumberOfCallsInHalfOpenState = NumberUtils.toInt(PropManager.getInstance().getProperty("CircuitBreaker", "permittedNumberOfCallsInHalfOpenState"), 10);
|
||||
|
||||
CircuitBreakerConfig config = CircuitBreakerConfig.custom()
|
||||
.failureRateThreshold(failureRateThreshold)
|
||||
.slidingWindowSize(slidingWindowSize)
|
||||
.minimumNumberOfCalls(minimumNumberOfCalls)
|
||||
.waitDurationInOpenState(Duration.ofSeconds(waitDurationInOpenState))
|
||||
.permittedNumberOfCallsInHalfOpenState(permittedNumberOfCallsInHalfOpenState)
|
||||
.slidingWindowType(CircuitBreakerConfig.SlidingWindowType.COUNT_BASED)
|
||||
.build();
|
||||
|
||||
circuitBreakerRegistry = CircuitBreakerRegistry.of(config);
|
||||
|
||||
TaggedCircuitBreakerMetrics.ofCircuitBreakerRegistry(circuitBreakerRegistry).bindTo(meterRegistry);
|
||||
|
||||
logger.info("init CircuitBreaker - "+config);
|
||||
}
|
||||
|
||||
public void reload(){
|
||||
init();
|
||||
}
|
||||
|
||||
public PrometheusMeterRegistry getMeterRegistry(){
|
||||
return meterRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws LifecycleException {
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
init();
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started) {
|
||||
throw new LifecycleException("RECEAICRT203");
|
||||
}
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
started = false;
|
||||
circuitBreakerRegistry = null;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return started;
|
||||
}
|
||||
|
||||
public CircuitBreaker getCircuitBreaker(String apiId){
|
||||
return circuitBreakerRegistry.circuitBreaker(apiId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.eactive.eai.common.circuitBreaker;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class PrometheusController {
|
||||
|
||||
|
||||
public PrometheusController() {
|
||||
System.out.println("init");
|
||||
}
|
||||
|
||||
// @GetMapping("/prometheus")
|
||||
public String scrape() {
|
||||
return CircuitBreakerManager.getInstance().getMeterRegistry().scrape();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.eactive.eai.common.circuitBreaker;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PrometheusServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
resp.getOutputStream().print(CircuitBreakerManager.getInstance().getMeterRegistry().scrape());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.eactive.eai.common.duplication;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DuplicationGuidDataVo {
|
||||
private String recvDatetime;
|
||||
private String uuid;
|
||||
private String channelCode;
|
||||
private String guid;
|
||||
private String instanceName;
|
||||
private String eaisvcname;
|
||||
private String bizData;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.common.duplication;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DuplicationGuidLogVo {
|
||||
private String channelCode;
|
||||
private String guid;
|
||||
private String recvDatetime;
|
||||
private String instanceName;
|
||||
private String eaisvcname;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.eactive.eai.common.duplication.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
import com.eactive.eai.common.duplication.DuplicationGuidDataVo;
|
||||
import com.eactive.eai.data.entity.onl.duplication.DuplicationGuidData;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class, uses = DuplicationGuidLogMapper.class)
|
||||
public interface DuplicationGuidDataMapper extends GenericMapper<DuplicationGuidDataVo, DuplicationGuidData> {
|
||||
|
||||
@Override
|
||||
@Mapping(source = "id.recv_datetime", target = "recvDatetime")
|
||||
@Mapping(source = "id.uuid", target = "uuid")
|
||||
@Mapping(source = "channel_code", target = "channelCode")
|
||||
@Mapping(source = "instance_name", target = "instanceName")
|
||||
@Mapping(source = "biz_data" , target = "bizData")
|
||||
DuplicationGuidDataVo toVo(DuplicationGuidData entity);
|
||||
|
||||
@Override
|
||||
@InheritInverseConfiguration
|
||||
DuplicationGuidData toEntity(DuplicationGuidDataVo vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.eactive.eai.common.duplication.mapper;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
import com.eactive.eai.common.duplication.DuplicationGuidLogVo;
|
||||
import com.eactive.eai.data.entity.onl.duplication.DuplicationGuidLog;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface DuplicationGuidLogMapper extends GenericMapper<DuplicationGuidLogVo, DuplicationGuidLog> {
|
||||
|
||||
@Override
|
||||
@Mapping(source = "id.guid", target = "guid")
|
||||
@Mapping(source = "id.channel_code", target = "channelCode")
|
||||
@Mapping(source = "recv_datetime", target = "recvDatetime")
|
||||
@Mapping(source = "instance_name", target = "instanceName")
|
||||
DuplicationGuidLogVo toVo(DuplicationGuidLog entity);
|
||||
|
||||
@Override
|
||||
@InheritInverseConfiguration
|
||||
DuplicationGuidLog toEntity(DuplicationGuidLogVo vo);
|
||||
|
||||
@AfterMapping
|
||||
default void setCheckIdAndWeekday(@MappingTarget DuplicationGuidLog entity, DuplicationGuidLogVo vo) {
|
||||
DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek(); // 현재 요일
|
||||
int dayOfWeekNumber = dayOfWeek.getValue() % 7 + 1; // 1 (일요일)부터 7 (토요일)까지
|
||||
entity.getId().setWeekday(dayOfWeekNumber);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.eactive.eai.common.ehcache;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.session.SessionManager;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.worker.Future;
|
||||
import com.eactive.eai.common.worker.ResponseMap;
|
||||
|
||||
import net.sf.ehcache.CacheException;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.event.CacheEventListener;
|
||||
|
||||
public class CustomRMICacheEventListener implements CacheEventListener {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
public static final CacheEventListener INSTANCE = new CustomRMICacheEventListener();
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyElementEvicted(Ehcache cache, Element element) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyElementExpired(Ehcache cache, Element element) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyElementPut(Ehcache cache, Element element) throws CacheException {
|
||||
logger.debug("CustomRMICacheEventListener] notifyElementPut : " + element );
|
||||
setEvent(cache, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException {
|
||||
logger.debug("CustomRMICacheEventListener] notifyElementRemoved : " + element );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException {
|
||||
logger.debug("CustomRMICacheEventListener] notifyElementUpdated : " + element );
|
||||
setEvent(cache, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyRemoveAll(Ehcache cache) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException{
|
||||
throw new CloneNotSupportedException("Singleton instance");
|
||||
}
|
||||
|
||||
private void setEvent(Ehcache cache, Element element){
|
||||
if (SessionManager.TOPIC_CAHCE_NAME.equals(cache.getName())){
|
||||
String guidKey = (String)element.getKey();
|
||||
EAIMessage data = (EAIMessage)element.getValue();
|
||||
logger.debug("CustomRMICacheEventListener] setEvent["+guidKey+"]");
|
||||
Future future = ResponseMap.getInstance().get(guidKey);
|
||||
if (future != null){
|
||||
logger.debug("CustomRMICacheEventListener] setEvent["+guidKey+"] put to Future");
|
||||
future.getSlot().put(data);
|
||||
cache.remove(guidKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.eactive.eai.common.ehcache;
|
||||
|
||||
import net.sf.ehcache.event.CacheEventListener;
|
||||
import net.sf.ehcache.event.CacheEventListenerFactory;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public class CustomRMICacheReplicatorFactory extends CacheEventListenerFactory {
|
||||
|
||||
@Override
|
||||
public CacheEventListener createCacheEventListener(Properties properties) {
|
||||
return CustomRMICacheEventListener.INSTANCE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package com.eactive.eai.common.exception;
|
||||
|
||||
import java.util.HashMap;
|
||||
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.ElinkAdapter;
|
||||
import com.eactive.eai.adapter.ElinkAdapterFactory;
|
||||
import com.eactive.eai.adapter.Keys;
|
||||
import com.eactive.eai.adapter.wca.SNAProperties;
|
||||
import com.eactive.eai.common.logger.EAILogSender;
|
||||
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.message.ServiceMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
|
||||
public class ErrorResponseSender {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static HashMap<String,String> errCodeMap = new HashMap();
|
||||
|
||||
static {
|
||||
errCodeMap.put("RECEAIOSA001", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOEP001", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOHP001", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOHP003", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOSP001", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOSP002", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOSP003", "RECEAICEU10");
|
||||
errCodeMap.put("RECEAIOSP004", "RECEAICEU10");
|
||||
errCodeMap.put(EAIMessageKeys.EAI_BLOCKED_CODE, "RECEAICEU30"); // 거래통제 에러
|
||||
errCodeMap.put(EAIMessageKeys.EAI_INFLOW_BLOCKED_CODE, "RECEAICEU30"); // 유량제어 에러
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 에러크드 재조합
|
||||
* 2. 처리 개요 :
|
||||
* - RECEAICEU10X - 호출에러
|
||||
* - RECEAICEU20X - 변환에러
|
||||
* - X (1:취급요청, 2:취급응답, 3:개설요청, 4:개설응답
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static String convertErrorCode(String errCode, String guCode) {
|
||||
String newErrCode = "";
|
||||
newErrCode = errCodeMap.get(errCode);
|
||||
|
||||
if(newErrCode == null) {
|
||||
// 통신에러 코드이거나 TUXEDO 통신에러코드일 경우
|
||||
if( errCode!= null && errCode.startsWith("RECEAIOTC9") ) {
|
||||
newErrCode = "RECEAICEU10";
|
||||
}
|
||||
else {
|
||||
newErrCode = "RECEAICEU20";
|
||||
}
|
||||
}
|
||||
return newErrCode + guCode;
|
||||
}
|
||||
|
||||
private static byte[] makeStandardMessageData(EAIMessage eaiMessage, String msgType
|
||||
, String charset) throws Exception{
|
||||
// InterfaceMapper mapper = eaiMessage.getMapper();
|
||||
StandardMessage standardMessage = eaiMessage.getStandardMessage();
|
||||
// String operationEnv = mapper.getOperationEnv(standardMessage);
|
||||
/*
|
||||
// if(MessageType.JSON.equals(msgType) || MessageType.UJSON.equals(msgType)) {
|
||||
if(MessageType.JSON.equals(msgType)) {
|
||||
return standardMessage.toJson().getBytes(charset);
|
||||
}
|
||||
// else if(MessageType.XML.equals(msgType) || MessageType.UXML.equals(msgType)) {
|
||||
else if(MessageType.XML.equals(msgType)) {
|
||||
return standardMessage.toXML().getBytes(charset);
|
||||
}
|
||||
else if(MessageType.ASC.equals(msgType)) {
|
||||
return standardMessage.toByteArray(charset);
|
||||
}
|
||||
else {
|
||||
throw new Exception("Unsupported msgType - " + msgType);
|
||||
}
|
||||
*/
|
||||
return standardMessage.getDataBytes(msgType, charset);
|
||||
}
|
||||
|
||||
public static void sendErrorResponseMessage(EAIMessage eaiMessage, String charset) {
|
||||
|
||||
boolean isError = false;
|
||||
String errorMsg = "";
|
||||
try {
|
||||
|
||||
// 1. EAI메시지 파싱
|
||||
ServiceMessage smsg = eaiMessage.getCurrentSvcMsg();
|
||||
String adapterGroupName = smsg.getPsvSysItfTp();
|
||||
|
||||
// 2. 송신어댑터 분석
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO adapterGroup = adapterManager.getAdapterGroupVO(adapterGroupName);
|
||||
|
||||
// ASC/EBC/JOB/FML/F32/XML
|
||||
String msgType = adapterGroup.getMessageType();
|
||||
// SNA/SOC/NET/HTT
|
||||
String adapterType = adapterGroup.getType();
|
||||
|
||||
// 3. 송신메시지 생성
|
||||
byte[] reqBytes = null;
|
||||
try {
|
||||
reqBytes = makeStandardMessageData(eaiMessage, msgType, charset);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//ExtMessageConverter.normalAsyncSend(eaiMessage, msgType);
|
||||
|
||||
AdapterVO adptVO = adapterGroup.nextAdapterVO();
|
||||
|
||||
// 가용 Adapter가 없는 경우
|
||||
if(adptVO == null) {
|
||||
String[] msgArgs = new String[1];
|
||||
msgArgs[0] = String.valueOf(adapterGroupName);
|
||||
String resMsg = ExceptionUtil.make("RECEAIOSA900", msgArgs);
|
||||
throw new Exception(resMsg);
|
||||
}
|
||||
Properties prop = null;
|
||||
|
||||
if( Keys.TYPE_HTTP.equals(adapterGroup.getType()) ) {
|
||||
AdapterPropManager manager = AdapterPropManager.getInstance();
|
||||
prop = manager.getProperties(adptVO.getPropGroupName());
|
||||
prop.put("adapterName", adptVO.getName());
|
||||
}
|
||||
else {
|
||||
prop = new Properties();
|
||||
}
|
||||
prop.setProperty("ADAPTER_GROUP_NAME", adapterGroupName);
|
||||
|
||||
//-------------------------------------------
|
||||
// SNA Property 설정 : 2010.02.07
|
||||
prop.setProperty(SNAProperties.TRAN_KEY, eaiMessage.getSvcOgNo()); // UUID
|
||||
prop.setProperty(SNAProperties.ADAPTER_GRP_NAME, adapterGroupName);
|
||||
prop.setProperty(SNAProperties.LU_NAME, " ");
|
||||
prop.setProperty(SNAProperties.DATA_TYPE, SNAProperties.DATA_TYPE_NORMAL);
|
||||
|
||||
|
||||
String adapterName = adptVO.getName();
|
||||
|
||||
prop.setProperty(SNAProperties.ADAPTER_NAME, adapterName);
|
||||
|
||||
prop.setProperty(SNAProperties.TRAN_MODE, SNAProperties.TRAN_MODE_NONRESPONSE);
|
||||
//-------------------------------------------
|
||||
|
||||
// 4. 비동기 송신
|
||||
|
||||
ElinkAdapterFactory factory = ElinkAdapterFactory.newInstance();
|
||||
ElinkAdapter adapter = null;
|
||||
adapter = factory.getElinkAdapter(adapterType);
|
||||
adapter.callService(adapterGroupName, prop, reqBytes, new Properties());
|
||||
} catch(Exception e) {
|
||||
logger.error("sendErrorResponseMessage error", e);
|
||||
errorMsg = e.getMessage();
|
||||
isError = true;
|
||||
}
|
||||
|
||||
// 5. 에러로그(900)저장
|
||||
// 2009.10.06
|
||||
// 송신에러 와 정상일 경우에 대한 로그 처리
|
||||
if(isError) {
|
||||
// eaiMessage.setRspErrCd("RECEAICEU999"); // 에러응답 송신 에러
|
||||
String rspErrMsg = eaiMessage.getRspErrMsg() + errorMsg;
|
||||
// eaiMessage.setRspErrMsg(rspErrMsg);
|
||||
eaiMessage.setRspErr("RECEAICEU999", rspErrMsg);
|
||||
}
|
||||
|
||||
eaiMessage.setLogPssSno(900);
|
||||
try{
|
||||
EAILogSender.send(eaiMessage, null);
|
||||
}catch(Exception e){
|
||||
logger.error("ExceptionHandler] EAILogSender send fail");
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,962 @@
|
||||
package com.eactive.eai.common.exception;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.common.EAIKeys;
|
||||
import com.eactive.eai.common.logger.EAILogSender;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
import com.eactive.eai.common.message.EAIMessageManager;
|
||||
import com.eactive.eai.common.message.MessageType;
|
||||
import com.eactive.eai.common.message.ServiceMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.common.util.SMSLogUtil;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.transformer.engine.TransformEngine;
|
||||
import com.eactive.eai.transformer.engine.Transformer;
|
||||
import com.eactive.eai.transformer.layout.Item;
|
||||
import com.eactive.eai.transformer.layout.Layout;
|
||||
import com.eactive.eai.transformer.layout.LayoutType;
|
||||
import com.eactive.eai.transformer.message.Message;
|
||||
import com.eactive.eai.transformer.message.MessageFactory;
|
||||
import com.eactive.eai.transformer.transform.Transform;
|
||||
import com.eactive.eai.transformer.transform.TransformManager;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Exception의 동기,비동기 방식을 지원하는 클래스 2. 처리 개요 : * - SYNC 방식의 Exception
|
||||
* Handler 처리 * - ASYNC 방식의 Exception Handler 처리 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since : :
|
||||
*/
|
||||
public class ExceptionHandler {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
public ExceptionHandler() {
|
||||
// empty
|
||||
}
|
||||
|
||||
public static String handle(String errMsg) {
|
||||
if (errMsg == null) {
|
||||
return "[errCd][/errCd][errMsg]EAI 내부처리 오류 입니다.[/errMsg][GstatSysAdptrBzwkGroupName][/GstatSysAdptrBzwkGroupName][data][/data]";
|
||||
} else {
|
||||
return "[errCd][/errCd][errMsg]"
|
||||
+ errMsg
|
||||
+ "[/errMsg][GstatSysAdptrBzwkGroupName][/GstatSysAdptrBzwkGroupName][data][/data]";
|
||||
}
|
||||
}
|
||||
|
||||
public static EAIMessage handle(EAIMessage eaiMessage) {
|
||||
String inAdapterGroupName = eaiMessage.getSngSysItfTp();
|
||||
AdapterManager manager = AdapterManager.getInstance();
|
||||
AdapterGroupVO group = manager.getAdapterGroupVO(inAdapterGroupName);
|
||||
String charset = StringUtils.defaultIfBlank(group.getMessageEncode(), Charset.defaultCharset().name());
|
||||
|
||||
String transClassifycation = eaiMessage.getMapper().getSendRecvDivision(eaiMessage.getStandardMessage()); // S|R
|
||||
boolean transClassify = false;
|
||||
if (transClassifycation.equals(STDMessageKeys.SEND_RECV_CD_SEND)) {
|
||||
transClassify = true;
|
||||
}
|
||||
// else if (transClassifycation.equals(STDMessageKeys.SEND_RECV_CD_RECV)) {
|
||||
// transClassify = false;
|
||||
// }
|
||||
return handle(eaiMessage, transClassify, charset);
|
||||
}
|
||||
|
||||
public static EAIMessage handle(EAIMessage eaiMessage, boolean transClassify, String charset) {
|
||||
smsLogging(eaiMessage);
|
||||
|
||||
EAIMessage resultEAIMessage = null;
|
||||
|
||||
// 3. EAI 서비스 정보 추출
|
||||
// 요청오류변환ID명
|
||||
String reqErrTransID = eaiMessage.getDmndErrChngIDName();
|
||||
// 응답오류변환ID명
|
||||
String resErrTransID = eaiMessage.getRspnsErrChngIDName();
|
||||
// 오류EAI서비스명
|
||||
String resEAISvcCode = eaiMessage.getErrEAISvcName();
|
||||
// 요청에러필드명
|
||||
String reqErrPosition = eaiMessage.getDmndErrFldName();
|
||||
// 응답에러필드명
|
||||
String resErrPosition = eaiMessage.getRspnsErrFldName();
|
||||
|
||||
// 서비스동기사용구분코드 //SYNC/ASYNC/AKON
|
||||
String serviceType = eaiMessage.getSvcTsmtUsgTp();
|
||||
|
||||
if (serviceType == null) serviceType = "";
|
||||
// 전문요청구분코드
|
||||
String tmpTrans = eaiMessage.getMapper().getSendRecvDivision(eaiMessage.getStandardMessage()); // S|R
|
||||
// 응답에러코드
|
||||
String errCode = eaiMessage.getRspErrCd();
|
||||
// 응답에러메시지
|
||||
String errMsg = eaiMessage.getRspErrMsg();
|
||||
// 기동시스템어댑터업무그룹명
|
||||
String sngSysItfTp = eaiMessage.getSngSysItfTp();
|
||||
|
||||
// 어댑터메시지구분코드 //ASC/EBC/JOB/FML/F32/XML
|
||||
String messageTypeSource = "";
|
||||
// 수동시스템어댑터업무그룹명
|
||||
String psvSysItfTp = eaiMessage.getCurrentSvcMsg().getPsvSysItfTp();
|
||||
// 수동 어댑터메시지구분코드 //ASC/EBC/JOB/FML/F32/XML
|
||||
String messageTypeTarget = "";
|
||||
// 표준메시지사용구분
|
||||
String stdMsgUsgCls = eaiMessage.getStdMsgUsgCls();
|
||||
// 수동인터페이스구분명 //SYNC/ASYNC/AKON
|
||||
String psvItfTp = eaiMessage.getCurrentSvcMsg().getPsvItfTp();
|
||||
|
||||
String inboundCharset = Charset.defaultCharset().name();
|
||||
String inAdapterGroupName = eaiMessage.getSngSysItfTp();
|
||||
AdapterGroupVO inAdapterGvo = AdapterManager.getInstance().getAdapterGroupVO(inAdapterGroupName);
|
||||
|
||||
if(inAdapterGvo != null) {
|
||||
inboundCharset = StringUtils.defaultIfBlank(inAdapterGvo.getMessageEncode(), Charset.defaultCharset().name());
|
||||
}
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] inboundCharset : {}", inboundCharset);
|
||||
}
|
||||
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 디버그 로그 시작");
|
||||
logger.info("EAI 서비스 코드 = " + eaiMessage.getEAISvcCd());
|
||||
logger.info("서비스동기사용구분코드 = " + eaiMessage.getSvcTsmtUsgTp());
|
||||
logger.info("수동인터페이스구분명 = " + eaiMessage.getCurrentSvcMsg().getPsvItfTp());
|
||||
logger.info("전문요청구분코드 = " + eaiMessage.getMapper().getSendRecvDivision(eaiMessage.getStandardMessage())); // S|R);
|
||||
logger.info("오류EAI서비스명 = " + eaiMessage.getErrEAISvcName());
|
||||
logger.info("요청오류변환ID명 = " + eaiMessage.getDmndErrChngIDName());
|
||||
logger.info("응답오류변환ID명 = " + eaiMessage.getRspnsErrChngIDName());
|
||||
logger.info("요청에러필드명 = " + eaiMessage.getDmndErrFldName());
|
||||
logger.info("응답에러필드명 = " + eaiMessage.getRspnsErrFldName());
|
||||
|
||||
logger.info("응답에러코드 = " + eaiMessage.getRspErrCd());
|
||||
logger.info("응답에러메시지 = " + eaiMessage.getRspErrMsg());
|
||||
logger.info("기동시스템어댑터업무그룹명 = " + eaiMessage.getSngSysItfTp());
|
||||
logger.info("수동시스템어댑터업무그룹명 = " + eaiMessage.getCurrentSvcMsg().getPsvSysItfTp());
|
||||
logger.info("표준메시지사용구분 = " + eaiMessage.getStdMsgUsgCls());
|
||||
}
|
||||
|
||||
String tgtStdMsgUsgCls = "";
|
||||
|
||||
// 4. 업무 데이터 추출
|
||||
String orgBizDataStr = null;
|
||||
try {
|
||||
orgBizDataStr = eaiMessage.getStandardMessage().getBizData();
|
||||
} catch (Exception e) {
|
||||
logger.error("getBizData failed.", e);
|
||||
}
|
||||
|
||||
String data = null;
|
||||
try {
|
||||
AdapterManager adapterManager = null;
|
||||
AdapterGroupVO adapterGroupVoSource = null;
|
||||
AdapterGroupVO adapterGroupVoTarget = null;
|
||||
try {
|
||||
adapterManager = AdapterManager.getInstance();
|
||||
adapterGroupVoSource = adapterManager.getAdapterGroupVO(sngSysItfTp);
|
||||
// 어댑터메시지구분코드 //ASC/EBC/JOB/FML/F32/XML
|
||||
messageTypeSource = adapterGroupVoSource.getMessageType();
|
||||
} catch (Exception ee) {
|
||||
if (logger.isError())
|
||||
logger.error("ExceptionHandler] 기동어댑터그룹명 = " + adapterGroupVoSource);
|
||||
throw new Exception("기동어댑터가 정의되지 않았습니다. - " + adapterGroupVoSource);
|
||||
}
|
||||
try {
|
||||
adapterGroupVoTarget = adapterManager.getAdapterGroupVO(psvSysItfTp);
|
||||
// 수동 어댑터메시지구분코드 //ASC/EBC/JOB/FML/F32/XML
|
||||
messageTypeTarget = adapterGroupVoTarget.getMessageType();
|
||||
tgtStdMsgUsgCls = adapterGroupVoTarget.getAdptrMsgPtrnCd();
|
||||
} catch (Exception ee) {
|
||||
if (logger.isError())
|
||||
logger.error("ExceptionHandler] 수동어댑터그룹명 = " + adapterGroupVoTarget);
|
||||
throw new Exception("수동어댑터가 정의되지 않았습니다. - " + adapterGroupVoTarget);
|
||||
}
|
||||
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 요청거래 = " + transClassify);
|
||||
logger.info("ExceptionHandler] 서비스동기사용구분코드 = " + serviceType);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// 통변환로직 및 Outbound 호출 로직 추가 필요
|
||||
// -----------------------------------------------------
|
||||
if (resEAISvcCode == null || resEAISvcCode.trim().length() == 0) {
|
||||
throw new Exception("ExceptionHandler] 오류EAI서비스명이 등록되지 않았습니다.");
|
||||
}
|
||||
|
||||
if (!emptyRule(transClassify, serviceType, eaiMessage)) {
|
||||
// SS, SA 거래는 기존의 로직으로 처리
|
||||
if (serviceType.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
throw new Exception("Sync Service");
|
||||
}
|
||||
// AS 거래는 요청 업무데이터를 그대로 송신
|
||||
// AA 거래는 기동이 표준인 경우 요청업무데이터를 그대로
|
||||
// -> 메시지 변경없이 그대로 전달한다.2009.11.05
|
||||
else {
|
||||
data = orgBizDataStr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 5. 오류변환 처리
|
||||
// 요청거래 변환
|
||||
if (transClassify) {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 요청오류변환ID명 = " + reqErrTransID);
|
||||
logger.info("ExceptionHandler] 요청에러필드명 = " + reqErrPosition);
|
||||
logger.info("ExceptionHandler] EAI에러코드 = " + errCode);
|
||||
logger.info("ExceptionHandler] makeTrans start request transaction");
|
||||
}
|
||||
data = makeTrans(reqErrTransID, orgBizDataStr, reqErrPosition, errCode, inboundCharset);
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 요청오류변환완료");
|
||||
}
|
||||
}
|
||||
// 응답거래 변환
|
||||
else {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 응답오류변환ID명 = " + resErrTransID);
|
||||
logger.info("ExceptionHandler] 응답에러필드명 = " + resErrPosition);
|
||||
logger.info("ExceptionHandler] EAI에러코드 = " + errCode);
|
||||
logger.info("ExceptionHandler] makeTrans start response transaction");
|
||||
}
|
||||
data = makeTrans(resErrTransID, orgBizDataStr, resErrPosition, errCode, inboundCharset);
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 응답오류변환 완료");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isXML = checkXML(serviceType, psvItfTp, messageTypeSource, messageTypeTarget, transClassify);
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 표준메시지 사용여부 =" + stdMsgUsgCls);
|
||||
logger.info("ExceptionHandler] XML 전문 = " + isXML);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// XML 인터페이스 방식인 경우 : 오류메시지에 대한 XML Tag를 생성한다
|
||||
// ----------------------------------------------------------------------
|
||||
if (isXML) {
|
||||
// String xmlString = null;
|
||||
// if (data instanceof byte[]) {
|
||||
// xmlString = new String((byte[]) data); // TODO check charset
|
||||
//
|
||||
// } else if (data instanceof String) {
|
||||
// xmlString = (String)data;
|
||||
// }
|
||||
String xmlString = data;
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] XML 전문 = " + xmlString);
|
||||
xmlString = MessageUtil.replaceMsgXmlString(xmlString);
|
||||
xmlString = MessageUtil.makeErrMsgXmlString(xmlString);
|
||||
data = xmlString;
|
||||
}
|
||||
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] serviceType=" + serviceType);
|
||||
}
|
||||
// 업무데이타를 EAIMessage에 저장하고
|
||||
// 에러응답메시지를 전송한다.
|
||||
// 기동이 동기(Sync)인 경우
|
||||
// 응답에러로그를 생성하여 전달한다.
|
||||
if (serviceType.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
if (psvItfTp.equals(EAIMessageKeys.ASYNC_SVC) && tmpTrans.equals(EAIKeys.TR_RES)) {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] SA Type 응답거래처리");
|
||||
}
|
||||
errorAsyncSend(eaiMessage);
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] end");
|
||||
return eaiMessage;
|
||||
} else {
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] SS, SA 요청 Type 거래처리");
|
||||
// eaiMessage 에 업무데이타 셋팅
|
||||
resultEAIMessage = normalSyncSend(eaiMessage, data, charset);
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] end");
|
||||
return resultEAIMessage;
|
||||
}
|
||||
}
|
||||
// 기동이 비동기(Async)인 경우
|
||||
// 에러응답을 송신한다.
|
||||
else if (serviceType.equals(EAIMessageKeys.ASYNC_SVC) || serviceType.equals(EAIMessageKeys.ACKONLY_SVC)) {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] AA, AS Type 거래처리");
|
||||
}
|
||||
normalAsyncSend(resEAISvcCode, eaiMessage, data, transClassify, charset);
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] end");
|
||||
return eaiMessage;
|
||||
}
|
||||
|
||||
} catch (Exception e2) {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("ExceptionHandler] 내부 Exception 무응답 처리 거래타입[" + serviceType + "][" + psvItfTp + "] - "
|
||||
+ e2.getMessage());
|
||||
}
|
||||
// 동기일경우 메시지 조립해서 전달
|
||||
// 에러 코드 + 에러 메시지 + 기동서버 아답터 그룹명 + 요청전문
|
||||
// 비동기 일경우 거래로그(900)를 생성하고 SMS보냄
|
||||
if (EAIMessageKeys.SYNC_SVC.equals(serviceType)) {
|
||||
// SA 응답 거래는 900로그 생성 : 정상일 경우 100로그만 생성되는 거래
|
||||
if (psvItfTp.equals(EAIMessageKeys.ASYNC_SVC) && tmpTrans.equals(EAIKeys.TR_RES)) {
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] SA 응답 900 Logging");
|
||||
errorAsyncSend(eaiMessage);
|
||||
return eaiMessage;
|
||||
} else {
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] SS, SA 요청 Type 거래처리");
|
||||
// SS, SA요청 거래일 경우 에러메시지를 생성하여 RETURN
|
||||
resultEAIMessage = errorSyncSend(eaiMessage, transClassify, errCode, errMsg, sngSysItfTp, orgBizDataStr,
|
||||
messageTypeSource, messageTypeTarget, stdMsgUsgCls, serviceType, psvItfTp
|
||||
, charset);
|
||||
return resultEAIMessage;
|
||||
}
|
||||
|
||||
} else if (EAIMessageKeys.ASYNC_SVC.equals(serviceType) || EAIMessageKeys.ACKONLY_SVC.equals(serviceType)) {
|
||||
// AA,AS 거래는 900 에러로그 생성
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] AA, AS 900 Logging");
|
||||
errorAsyncSend(eaiMessage);
|
||||
return eaiMessage;
|
||||
}
|
||||
}
|
||||
return eaiMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI메시지를 생성하는 메소드 2. 처리 개요 : - EAI메시지를 생성한다 3. 주의사항
|
||||
*
|
||||
* @param resEAISvcCode : 응답 EAI서비스명
|
||||
* @param eaiMessage : 요청 EAI메시지
|
||||
* @return 응답EAI메시지
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static EAIMessage makeEAIMessage(String resEAISvcCode, EAIMessage eaiMessage) throws Exception {
|
||||
|
||||
EAIMessageManager eaiMessageManager = EAIMessageManager.getInstance();
|
||||
EAIMessage resultEAIMessage = eaiMessageManager.getEAIMessage(resEAISvcCode);
|
||||
|
||||
// --------------------------------------
|
||||
// 2009.10.05
|
||||
// EAI 서비스메시지의 Outbound 정보를 오류EAI서비스명의 정보로 변경한다.
|
||||
// --------------------------------------
|
||||
// 기동서비스구분
|
||||
eaiMessage.setSngSvcCls("EXCEPTION");
|
||||
|
||||
// AS 거래일 경우 등록된 거래로 송신한다.
|
||||
if (eaiMessage.getSvcMsgs().size() > 1) {
|
||||
String keyMgtMsgVl = eaiMessage.getCurrentSvcMsg().getKeyMgtMsgVl();
|
||||
eaiMessage.setSvcPssSeq(eaiMessage.getSvcPssSeq() + 1);
|
||||
eaiMessage.getCurrentSvcMsg().setKeyMgtMsgVl(keyMgtMsgVl);
|
||||
eaiMessage.getCurrentSvcMsg().setCnvEn("0");
|
||||
eaiMessage.getCurrentSvcMsg().setSupplDelYn("0");
|
||||
return eaiMessage;
|
||||
}
|
||||
|
||||
// 수동업무구분 : psvBwkSysNm
|
||||
// 수동시스템ID : psvSysID
|
||||
// 수동시스템서비스코드 : psvSysSvcCd
|
||||
// 수동시스템인터페이스유형 : psvSysItfTp
|
||||
// Outbound라우팅명 : outbRtnNm
|
||||
// 변환유무 : cnvEn - 없음 (0)
|
||||
// 추가삭제여부 : supplDelYn - 없음 (0)
|
||||
|
||||
ServiceMessage svcMsg = eaiMessage.getCurrentSvcMsg();
|
||||
ServiceMessage errSvcMsg = resultEAIMessage.getCurrentSvcMsg();
|
||||
|
||||
if (svcMsg != null && errSvcMsg != null) {
|
||||
svcMsg.setPsvBwkSysNm(errSvcMsg.getPsvBwkSysNm());
|
||||
svcMsg.setPsvSysID(errSvcMsg.getPsvSysID());
|
||||
svcMsg.setPsvSysSvcCd(errSvcMsg.getPsvSysSvcCd());
|
||||
svcMsg.setPsvSysItfTp(errSvcMsg.getPsvSysItfTp());
|
||||
svcMsg.setOutbRtnNm(errSvcMsg.getOutbRtnNm());
|
||||
svcMsg.setCnvEn("0");
|
||||
svcMsg.setSupplDelYn("0");
|
||||
}
|
||||
// add default values
|
||||
|
||||
return eaiMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 에러 응답으로 변환하는 메소드 2. 처리 개요 : - 에러 응답으로 변환한다 3. 주의사항
|
||||
*
|
||||
* @param errTransID : 변환ID
|
||||
* @param tmpMsg : 업무데이타
|
||||
* @param errPosition : 레이아웃위치
|
||||
* @param errCode : 에러코드값
|
||||
* @return 변환된 업무데이타
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static String makeTrans(String errTransID, Object tmpMsg, String errPosition, String errCode,
|
||||
String charset)
|
||||
throws Exception {
|
||||
// TransformResult result =null;
|
||||
try {
|
||||
TransformEngine engine = TransformEngine.getInstance();
|
||||
Transformer transformer = engine.getTransformer();
|
||||
|
||||
TransformManager manager = TransformManager.getManager();
|
||||
Transform info = manager.getTransform(errTransID);
|
||||
if (info == null) {
|
||||
throw new Exception("Transform is NULL - " + errTransID);
|
||||
}
|
||||
Layout ls = info.getSourceLayout(0);
|
||||
com.eactive.eai.transformer.message.Message source = MessageFactory.getFactory().getMessage(ls.getName());
|
||||
// xml일 경우 root를 만들어야 한다.
|
||||
LayoutType type = ls.getLayoutType();
|
||||
if (type == null) {
|
||||
throw new Exception("Transform getLayoutType is NULL - " + errTransID);
|
||||
}
|
||||
if (MessageType.XML.equals(type.getName())) {
|
||||
if (logger.isInfo())
|
||||
logger.info("makeTrans] is xml , add root tag ");
|
||||
String xmlString = "";
|
||||
if (tmpMsg instanceof byte[]) {
|
||||
xmlString = new String((byte[]) tmpMsg);
|
||||
} else {
|
||||
xmlString = (String) tmpMsg;
|
||||
}
|
||||
Item item = ls.getRootItem();
|
||||
if (item != null) {
|
||||
String rootName = "<" + item.getName() + ">";
|
||||
String rootNameTail = "</" + item.getName() + ">";
|
||||
xmlString = rootName + xmlString + rootNameTail;
|
||||
source.setData(xmlString);
|
||||
} else {
|
||||
source.setData(xmlString);
|
||||
}
|
||||
} else {
|
||||
source.setData(tmpMsg);
|
||||
}
|
||||
|
||||
if (logger.isInfo())
|
||||
logger.info("makeTrans] source => " + source);
|
||||
// 변환
|
||||
Message target = transformer.transform(errTransID, new Message[] { source });
|
||||
|
||||
if (logger.isInfo())
|
||||
logger.info("makeTrans] target => " + target);
|
||||
|
||||
// errorcode setting
|
||||
target.setString(errPosition, errCode);
|
||||
|
||||
if (logger.isInfo())
|
||||
logger.info("makeTrans] errorCode setting => " + target);
|
||||
|
||||
// xml일 경우 root를 제거해야 한다.
|
||||
// if(ls.getLayoutType().getName().equals(MessageType.XML)) {
|
||||
Layout targetLayout = info.getTargetLayout();
|
||||
if (targetLayout == null) {
|
||||
throw new Exception("TargetLayout is NULL");
|
||||
}
|
||||
|
||||
LayoutType targetType = targetLayout.getLayoutType();
|
||||
if (targetType == null) {
|
||||
throw new Exception("TargetLayout Type is NULL");
|
||||
}
|
||||
|
||||
String targetData = null;
|
||||
if (MessageType.XML.equals(targetType.getName())) {
|
||||
if (logger.isInfo())
|
||||
logger.info("makeTrans] is xml , delete root tag ");
|
||||
Layout tls = info.getTargetLayout();
|
||||
String rootNameTarget = "<" + tls.getRootItem().getName() + ">";
|
||||
String rootNameTargetTail = "</" + tls.getRootItem().getName() + ">";
|
||||
|
||||
targetData = target.getData().toString().replaceAll(rootNameTarget, "");
|
||||
targetData = targetData.replaceAll(rootNameTargetTail, "");
|
||||
} else {
|
||||
Object targetObject = target.getData();
|
||||
if(targetObject instanceof String) {
|
||||
targetData = (String)targetObject;
|
||||
}
|
||||
else if(targetObject instanceof byte[]) {
|
||||
targetData = new String((byte[])targetObject, charset);
|
||||
}
|
||||
}
|
||||
return targetData;
|
||||
} catch (Exception e) {
|
||||
throw new Exception(ExceptionUtil.getErrorCode(e, "RECEAICEU104"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 에러 메시지를 조합하는 메소드 2. 처리 개요 : - 에러 메시지를 조합한다. 3. 주의사항
|
||||
*
|
||||
* @param errCode : 에러코드
|
||||
* @param errMsg : 에러메시지
|
||||
* @param sngSysItfTp : 기동시스템어댑터업무그룹명
|
||||
* @param Msg : 업무데이타
|
||||
* @param SourceType : 소스 어댑터메시지구분코드
|
||||
* @param TargetType : 타겟 어댑터메시지구분코드
|
||||
* @return 변환된 업무데이타
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
// private static Object errorTrans(String errCode , String errMsg , String sngSysItfTp, Object msgObject,String SourceType,String TargetType ,String TransID )throws Exception{
|
||||
private static String errorTrans(String errCode, String errMsg, String sngSysItfTp, String msgObject,
|
||||
String SourceType, String TargetType, String TransID) throws Exception {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] errorTrans SourceType=>" + SourceType);
|
||||
logger.info("ExceptionHandler] errorTrans TargetType=>" + TargetType);
|
||||
}
|
||||
// byte[] msg = null;
|
||||
// if(msgObject instanceof byte[]) {
|
||||
// msg = (byte[])msgObject;
|
||||
// }
|
||||
// else if(msgObject instanceof byte[]) {
|
||||
// msg = ((String)msgObject).getBytes();
|
||||
// }
|
||||
String msg = msgObject;
|
||||
String error = null;
|
||||
|
||||
String tmpErrCode = "[errCd]" + errCode + "[/errCd]";
|
||||
String tmpErrMsg = "[errMsg]" + errMsg + "[/errMsg]";
|
||||
String tmpSngSysItfTp = "[GstatSysAdptrBzwkGroupName]" + sngSysItfTp + "[/GstatSysAdptrBzwkGroupName]";
|
||||
String tmpdatafront = "[data]";
|
||||
String tmpdataback = "[/data]";
|
||||
|
||||
if (TargetType.equals(MessageType.ASC) || TargetType.equals(MessageType.EBC)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(tmpErrCode);
|
||||
sb.append(tmpErrMsg);
|
||||
sb.append(tmpSngSysItfTp);
|
||||
sb.append(tmpdatafront);
|
||||
if (msg != null) {
|
||||
sb.append(msg);
|
||||
}
|
||||
sb.append(tmpdataback);
|
||||
error = sb.toString();
|
||||
} else if (TargetType.equals(MessageType.JSON)) {
|
||||
error = MessageUtil.makeJsonErrorMessage(errCode, errMsg);
|
||||
} else if (TargetType.equals(MessageType.XML)) {
|
||||
error = MessageUtil.makeXmlErrorMessage(errCode, errMsg, "UTF-8");
|
||||
} else if (TargetType.equals(MessageType.JOB)) {
|
||||
throw new Exception("not support JOB MessageType ");
|
||||
} else if (TargetType.equals(MessageType.FML)) {
|
||||
throw new Exception("not support FML MessageType ");
|
||||
} else if (TargetType.equals(MessageType.F32)) {
|
||||
// //--------------------------------------------------------------------------
|
||||
// // 에러일 경우 TPURCODE, STATLIN 에 설정한다.
|
||||
// //--------------------------------------------------------------------------
|
||||
// if (logger.isInfo()){
|
||||
// logger.info("ExceptionHandler] FML32 Error Setting START");
|
||||
// }
|
||||
//
|
||||
// TypedFML32 errorFml = new TypedFML32(new CrmFmlTable());
|
||||
//
|
||||
// try {
|
||||
// errorFml.Fchg(CrmFmlTable.TPURCODE , 0, "-1");
|
||||
// errorFml.Fchg(167772165, 0, "[" + errCode + "] " + errMsg);
|
||||
// } catch(Exception e) {
|
||||
// if (logger.isError()){
|
||||
// logger.error("ExceptionHandler] FML32 Setting Error - " + e.toString());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// error = errorFml;
|
||||
//
|
||||
// if (logger.isInfo()){
|
||||
// logger.info("ExceptionHandler] FML32 Error Setting END");
|
||||
// }
|
||||
// //--------------------------------------------------------------------------
|
||||
//
|
||||
// //throw new Exception ("not support F32 MessageType ");
|
||||
// //juns 다시 확인
|
||||
// //error = errCode+errMsg+ sngSysItfTp + (String)tmpMsg;
|
||||
}
|
||||
return error;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 에러 메시지를 조합하는 메소드 2. 처리 개요 : - 에러 메시지를 조합한다. 3. 주의사항
|
||||
*
|
||||
* @param errCode : 에러코드
|
||||
* @param errMsg : 에러메시지
|
||||
* @param sngSysItfTp : 기동시스템어댑터업무그룹명
|
||||
* @param Msg : 업무데이타
|
||||
* @param SourceType : 소스 어댑터메시지구분코드
|
||||
* @param TargetType : 타겟 어댑터메시지구분코드
|
||||
* @return 변환된 업무데이타
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static boolean emptyRule(boolean transClassify, String serviceType, EAIMessage eaiMessage) {
|
||||
|
||||
String prefix = "ExceptionHandler] RuleCheck ";
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + " EAI서비스코드 = " + eaiMessage.getEAISvcCd());
|
||||
|
||||
boolean result = true;
|
||||
// 비동기의 경우
|
||||
if (!serviceType.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + "오류EAI서비스코드명(errEAISvcName) =" + eaiMessage.getErrEAISvcName());
|
||||
// 오류EAI서비스명
|
||||
if (eaiMessage.getErrEAISvcName() == null || eaiMessage.getErrEAISvcName().equals("")) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + "RuleCheck emptyRule 오류EAI서비스코드명 미등록");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 요청거래
|
||||
if (transClassify) {
|
||||
if (logger.isInfo()) {
|
||||
logger.info(prefix + "요청오류변환ID명 (reqErrTransID)=" + eaiMessage.getDmndErrChngIDName());
|
||||
logger.info(prefix + "요청에러필드명 (reqErrPosition)=" + eaiMessage.getDmndErrFldName());
|
||||
}
|
||||
// 요청오류변환ID명
|
||||
if (eaiMessage.getDmndErrChngIDName() == null || eaiMessage.getDmndErrChngIDName().equals("")) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + "emptyRule 요청오류변환ID명 ");
|
||||
return false;
|
||||
}
|
||||
// 요청에러필드명
|
||||
if (eaiMessage.getDmndErrFldName() == null || eaiMessage.getDmndErrFldName().equals("")) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + "emptyRule 요청에러필드명 ");
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (logger.isInfo()) {
|
||||
logger.info(prefix + "응답오류변환ID명 (resErrTransID)=" + eaiMessage.getRspnsErrChngIDName());
|
||||
logger.info(prefix + "응답에러필드명 (resErrPosition)=" + eaiMessage.getRspnsErrFldName());
|
||||
}
|
||||
// 응답 거래
|
||||
// 응답오류변환ID명
|
||||
if (eaiMessage.getRspnsErrChngIDName() == null || eaiMessage.getRspnsErrChngIDName().equals("")) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + "emptyRule 응답오류변환ID명");
|
||||
return false;
|
||||
}
|
||||
// 응답에러필드명
|
||||
if (eaiMessage.getRspnsErrFldName() == null || eaiMessage.getRspnsErrFldName().equals("")) {
|
||||
if (logger.isInfo())
|
||||
logger.info(prefix + " emptyRule 응답에러필드명");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 동기개별 메시지를 셋팅하는 메소드 2. 처리 개요 : - 동기개별 메시지를 셋팅한다. 3. 주의사항
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @param data : 개별메시지
|
||||
* @return 개별메시지가 셋팅된 EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static EAIMessage normalSyncSend(EAIMessage eaiMessage, String data, String charset) {
|
||||
EAIMessage resultEAIMessage = null;
|
||||
resultEAIMessage = eaiMessage;
|
||||
try {
|
||||
resultEAIMessage.getStandardMessage().setBizData(data, charset);
|
||||
} catch (Exception e) {
|
||||
logger.error("setBizData error", e);
|
||||
}
|
||||
// Outbound에서 변환을 하지 못하게 하는 셋팅
|
||||
resultEAIMessage.getCurrentSvcMsg().setCnvEn("0");
|
||||
return resultEAIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 비동기 메시지를 전송하는 메소드 2. 처리 개요 : - 비동기 메시지를 전송한다. 3. 주의사항
|
||||
*
|
||||
* @param resEAISvcCode : 오류EAI서비스명
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @param data : 개별메시지
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static void normalAsyncSend(String resEAISvcCode, EAIMessage eaiMessage, String data
|
||||
, boolean transClassify, String charset)
|
||||
throws Exception {
|
||||
EAIMessage resultEAIMessage = null;
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] 비동기 에러응답 송신 : 오류EAI서비스명 = " + resEAISvcCode);
|
||||
}
|
||||
resultEAIMessage = makeEAIMessage(resEAISvcCode, eaiMessage);
|
||||
try {
|
||||
resultEAIMessage.getStandardMessage().setBizData(data, charset);
|
||||
} catch (Exception e) {
|
||||
logger.error("setBizData error", e);
|
||||
}
|
||||
|
||||
// --------------------------------------
|
||||
// Outbound 호출시 사용됨
|
||||
// 2009.10.06
|
||||
// Outbound를 호출하지 않고 별도의 ErrorResponseSender를
|
||||
// 호출하여 처리하도록 한다.
|
||||
// --------------------------------------
|
||||
// Properties callProp = new Properties();
|
||||
// callProp.setProperty(RouteKeys.ROUTING_TYPE, RouteKeys.ROUT_JPD);
|
||||
// try{
|
||||
// //Outbound에서 변환을 하지 못하게 하는 셋팅
|
||||
// resultEAIMessage.getCurrentSvcMsg().setCnvEn("0");
|
||||
//
|
||||
// // Default error code를 설정하여 에러가 발생한 것을 확인
|
||||
// // 에러코드를 그대로 유지 - 주석처리함 : 2009.10.05
|
||||
// // resultEAIMessage.setRspErrCd(EAIMessageKeys.EAI_DEFAULT_CODE);
|
||||
//
|
||||
// EAIMessage retEaiMsg = IFRouter.process(resultEAIMessage, callProp);
|
||||
// String error = retEaiMsg.getRspErrCd();
|
||||
// if( !MessageUtil.checkRspErrCd(error)){
|
||||
// throw new Exception ("");
|
||||
// }
|
||||
// }catch(Exception e1){
|
||||
// //e1.printStackTrace();
|
||||
// throw new Exception(ExceptionUtil.getErrorCode(e1,"RECEAICEU101"));
|
||||
// }
|
||||
ErrorResponseSender.sendErrorResponseMessage(resultEAIMessage, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : ExceptionHandler에서 에러가 발생한 비동기 거래를 전송하는 메소드 2. 처리 개요 : -
|
||||
* ExceptionHandler에서 에러가 발생한 비동기 거래를 전송한다. 3. 주의사항
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static void errorAsyncSend(EAIMessage eaiMessage) {
|
||||
eaiMessage.setLogPssSno(900);
|
||||
try {
|
||||
EAILogSender.send(eaiMessage, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("ExceptionHandler] EAILogSender send fail", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : ExceptionHandler에서 에러가 발생한 비동기 거래를 전송하는 메소드 2. 처리 개요 : -
|
||||
* ExceptionHandler에서 에러가 발생한 비동기 거래를 전송한다. 3. 주의사항
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static EAIMessage errorSyncSend(EAIMessage eaiMessage, boolean transClassify, String errCode, String errMsg,
|
||||
String sngSysItfTp, String tmpMsg, String messageTypeSource, String messageTypeTarget, String stdMsgUsgCls,
|
||||
String serviceType, String psvItfTp, String charset) {
|
||||
String error = null;
|
||||
EAIMessage resultEAIMessage = null;
|
||||
try {
|
||||
if (transClassify) {
|
||||
if (logger.isInfo()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ExceptionHandler] errorSyncSend errCode=" + errCode);
|
||||
sb.append(", errMsg=" + errMsg);
|
||||
sb.append(", sngSysItfTp=" + sngSysItfTp);
|
||||
sb.append(", messageTypeSource=" + messageTypeSource);
|
||||
sb.append("\n tmpMsg=" + tmpMsg);
|
||||
logger.info(sb.toString());
|
||||
}
|
||||
// 요청거래
|
||||
// messageType 이 source ,messageTypeTarget이 target
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] 요청 에러변환(errorTrans)");
|
||||
error = errorTrans(errCode, errMsg, sngSysItfTp, tmpMsg, messageTypeSource, messageTypeSource,
|
||||
eaiMessage.getCurrentSvcMsg().getCnvMsgID());
|
||||
} else {
|
||||
if (logger.isInfo()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ExceptionHandler] errorSyncSend errCode=" + errCode);
|
||||
sb.append(", errMsg=" + errMsg);
|
||||
sb.append(", sngSysItfTp=" + sngSysItfTp);
|
||||
sb.append(", messageTypeSource=" + messageTypeSource);
|
||||
sb.append(", stdMsgUsgCls=" + stdMsgUsgCls);
|
||||
sb.append(", messageTypeTarget=" + messageTypeTarget);
|
||||
// if (tmpMsg instanceof byte[]) {
|
||||
// sb.append("\n tmpMsg=>" + new String((byte[]) tmpMsg));
|
||||
// } else if (tmpMsg instanceof String) {
|
||||
sb.append("\n tmpMsg=>" + tmpMsg);
|
||||
// }
|
||||
logger.info(sb.toString());
|
||||
}
|
||||
// 응답거래
|
||||
// messageTypeTarget이 이 source ,messageType이 target
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] 응답 에러변환(errorTrans)");
|
||||
error = errorTrans(errCode, errMsg, sngSysItfTp, tmpMsg, messageTypeTarget, messageTypeSource,
|
||||
eaiMessage.getCurrentSvcMsg().getBsRspCnvMsgID());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (logger.isError())
|
||||
logger.error("ExceptionHandler] handler request return", e);
|
||||
error = tmpMsg;
|
||||
}
|
||||
|
||||
if (logger.isInfo()) {
|
||||
logger.info("ExceptionHandler] stdMsgUsgCls=" + stdMsgUsgCls);
|
||||
}
|
||||
|
||||
if (com.eactive.eai.adapter.Keys.IF_STANDARD.equals(stdMsgUsgCls)) {
|
||||
if (MessageType.JSON.equals(messageTypeSource)) {
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] handler byte[] IF_STANDARD JSON");
|
||||
try {
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
boolean isBodyErrorSet = standardManager.getMessageCoordinator().coordinateSetStandardMessageError(eaiMessage.getStandardMessage(), eaiMessage.getMapper(), errCode, errMsg);
|
||||
if(!isBodyErrorSet) {
|
||||
error = null;
|
||||
}
|
||||
//eaiMessage.getMapper().setErrorCode(eaiMessage.getStandardMessage(), errCode);
|
||||
//eaiMessage.getMapper().setErrorMsg(eaiMessage.getStandardMessage(), errMsg);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("ExceptionHandler] handler byte[] IF_STANDARD JSON", e);
|
||||
}
|
||||
} else {
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
standardManager.getMessageCoordinator().coordinateSetStandardMessageError(eaiMessage.getStandardMessage(), eaiMessage.getMapper(), errCode, errMsg);
|
||||
//eaiMessage.getMapper().setErrorCode(eaiMessage.getStandardMessage(), errCode);
|
||||
//eaiMessage.getMapper().setErrorMsg(eaiMessage.getStandardMessage(), errMsg);
|
||||
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] handler String IF_STANDARD : " + error);
|
||||
error = null;
|
||||
}
|
||||
} else {
|
||||
if (checkXML(serviceType, psvItfTp, messageTypeSource, messageTypeTarget, transClassify)) {
|
||||
error = MessageUtil.replaceMsgXmlString(error);
|
||||
error = MessageUtil.makeErrMsgXmlString(error);
|
||||
if (logger.isInfo())
|
||||
logger.info("ExceptionHandler] handler String xml tag add " + error);
|
||||
}
|
||||
}
|
||||
|
||||
resultEAIMessage = eaiMessage;
|
||||
|
||||
try {
|
||||
if(StringUtils.isNotBlank(error))
|
||||
resultEAIMessage.getStandardMessage().setBizData(error, charset);
|
||||
} catch (Exception e) {
|
||||
logger.error("setBizData error", e);
|
||||
}
|
||||
|
||||
resultEAIMessage.getMapper().setResponseType(resultEAIMessage.getStandardMessage(),
|
||||
STDMessageKeys.RESPONSE_TYPE_CODE_E);
|
||||
// TODO 표준관련 확인필요
|
||||
return resultEAIMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : ExceptionHandler에서 에러가 발생한 비동기 거래를 전송하는 메소드 2. 처리 개요 : -
|
||||
* ExceptionHandler에서 에러가 발생한 비동기 거래를 전송한다. 3. 주의사항
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static boolean checkXML(String serviceType, String psvItfTp, String messageTypeSource,
|
||||
String messageTypeTarget, boolean transClassify) {
|
||||
if (logger.isInfo()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ExceptionHandler] checkStandard : serviceType=" + serviceType);
|
||||
sb.append(", psvItfTp=" + psvItfTp);
|
||||
sb.append(", messageTypeSource=" + messageTypeSource);
|
||||
sb.append(", messageTypeTarget=" + messageTypeTarget);
|
||||
sb.append(", transClassify=" + transClassify);
|
||||
logger.info(sb.toString());
|
||||
}
|
||||
|
||||
// 동기-동기 일경우 adptrMsgPtrnCdSource 기준 으로 표준일 경우 tag를 붙인다.
|
||||
// 동기-비동기 일경우 adptrMsgPtrnCdSource 기준 으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-비동기 일경우 요청거래일 경우 adptrMsgPtrnCdSource 기준으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-비동기 일경우 응답거래일 경우 adptrMsgPtrnCdTarget 기준으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-동기 일경우 adptrMsgPtrnCdSource 표준일 경우 tag를 붙인다.
|
||||
|
||||
if (serviceType.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
// if (messageTypeSource.equals(MessageType.XML) || messageTypeSource.equals(MessageType.UXML)) {
|
||||
if (messageTypeSource.equals(MessageType.XML)) {
|
||||
return true;
|
||||
}
|
||||
} else if (serviceType.equals(EAIMessageKeys.ASYNC_SVC) || serviceType.equals(EAIMessageKeys.ACKONLY_SVC)) {
|
||||
if (psvItfTp.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
// if (messageTypeSource.equals(MessageType.XML) || messageTypeSource.equals(MessageType.UXML)) {
|
||||
if (messageTypeSource.equals(MessageType.XML)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (transClassify) {
|
||||
// if (messageTypeSource.equals(MessageType.XML) || messageTypeSource.equals(MessageType.UXML)) {
|
||||
if (messageTypeSource.equals(MessageType.XML)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// if (messageTypeTarget.equals(MessageType.XML) || messageTypeSource.equals(MessageType.UXML)) {
|
||||
if (messageTypeTarget.equals(MessageType.XML)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkJSON(String serviceType, String psvItfTp, String messageTypeSource,
|
||||
String messageTypeTarget, boolean transClassify) {
|
||||
if (logger.isInfo()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("ExceptionHandler] checkStandard : serviceType=" + serviceType);
|
||||
sb.append(", psvItfTp=" + psvItfTp);
|
||||
sb.append(", messageTypeSource=" + messageTypeSource);
|
||||
sb.append(", messageTypeTarget=" + messageTypeTarget);
|
||||
sb.append(", transClassify=" + transClassify);
|
||||
logger.info(sb.toString());
|
||||
}
|
||||
|
||||
// 동기-동기 일경우 adptrMsgPtrnCdSource 기준 으로 표준일 경우 tag를 붙인다.
|
||||
// 동기-비동기 일경우 adptrMsgPtrnCdSource 기준 으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-비동기 일경우 요청거래일 경우 adptrMsgPtrnCdSource 기준으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-비동기 일경우 응답거래일 경우 adptrMsgPtrnCdTarget 기준으로 표준일 경우 tag를 붙인다.
|
||||
// 비동기-동기 일경우 adptrMsgPtrnCdSource 표준일 경우 tag를 붙인다.
|
||||
|
||||
if (serviceType.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
if (messageTypeSource.equals(MessageType.JSON)) {
|
||||
return true;
|
||||
}
|
||||
} else if (serviceType.equals(EAIMessageKeys.ASYNC_SVC) || serviceType.equals(EAIMessageKeys.ACKONLY_SVC)) {
|
||||
if (psvItfTp.equals(EAIMessageKeys.SYNC_SVC)) {
|
||||
if (messageTypeSource.equals(MessageType.JSON)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (transClassify) {
|
||||
if (messageTypeSource.equals(MessageType.JSON)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (messageTypeTarget.equals(MessageType.JSON)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : SMS를 전송하기 위한 로그를 쓰는 메소드 2. 처리 개요 :
|
||||
* - SMS 를 전송 하기 위한 로그를 쓴다.
|
||||
*
|
||||
* @param eaiMessage : EAIMessage
|
||||
* @exception Exception SQLException
|
||||
**/
|
||||
private static void smsLogging(EAIMessage eaiMessage) {
|
||||
// SMS=>[SMS][EAI][E:EAI서비스일련번호][업무구분코드] 에러코드:에러메시지
|
||||
// 에러메시지80byte로 자름
|
||||
SMSLogUtil.loggingSMSWithCode(eaiMessage.getEAISvcCd(), eaiMessage.getRspErrCd());
|
||||
|
||||
logger.error("[SMS] [EAI] [E:" + eaiMessage.getSvcOgNo() + "] [" + eaiMessage.getBwkCls() + "] "
|
||||
+ eaiMessage.getRspErrCd() + ":" + eaiMessage.getRspErrMsg());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.eactive.eai.common.exception;
|
||||
|
||||
public interface ExceptionHandlerKeys
|
||||
{
|
||||
public static final String GROUP_NAME = "ExceptionHandler";
|
||||
|
||||
public static final String EXCEPTION_HANDLER_CONNECTION_FACTORY = "exceptionhandler.connection.factory";
|
||||
public static final String EXCEPTION_HANDLER_QUEUE = "exceptionhandler.queue";
|
||||
public static final String TRANS_CLASSIFY = "transClassify";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.eactive.eai.common.exception;
|
||||
|
||||
import com.eactive.eai.common.errorcode.ErrorCodeHandler;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
/**
|
||||
* 1. 기능 : Exception 발생 시 메시지를 처리하기 위한 Utility 클래스
|
||||
* 2. 처리 개요 : Exception 발생 시 메시지를 처리하는 메서드를 정의한다.
|
||||
* * -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since :
|
||||
* :
|
||||
*/
|
||||
public class ExceptionHandlerServiceImpl implements ExceptionHandleService {
|
||||
/**
|
||||
* Default Logger
|
||||
*/
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
/**
|
||||
* 메시지 코드 자릿수
|
||||
*/
|
||||
public static final int CODE_LENGTH = 12;
|
||||
/**
|
||||
* 메시지 코드 Prefix
|
||||
*/
|
||||
//public static final String CODE_PREFIX = "RECEAI";
|
||||
public static final String CODE_PREFIX_ERROR = "RECEAI";
|
||||
public static final String CODE_PREFIX_FATAL = "RFCEAI";
|
||||
public static final String MSGCODE_PREFIX_ERROR = "[RECEAI";
|
||||
public static final String MSGCODE_PREFIX_FATAL = "[RFCEAI";
|
||||
// public static final String MSGCODE_PREFIX_NEW = "[에러코드:S9";
|
||||
public static final String MSGCODE_PREFIX_NEW = "[ERRCD:";
|
||||
|
||||
/**
|
||||
* 1. 기능 : Exception 발생 시 약속된 메시지 코드를 반환하기 위한 메서드
|
||||
* 2. 처리 개요 : Exception 내 메시지가 메시지 코드 체계인지를 판단해서 메시지 체계이면 Excepiton의 메시지를 반환하고,
|
||||
* 그렇지 않다면 파라미터에 새로 정의한 메시지 코드를 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param cause 발생한 오류
|
||||
* @param code 새로 정의할 메시지 코드
|
||||
* @return 메시지 코드
|
||||
**/
|
||||
public String getErrorCode(Throwable cause, String code) {
|
||||
if(cause==null) {
|
||||
String cd = "RECEAICEU001";
|
||||
if (logger.isWarn()) logger.warn("["+cd+"] "+ErrorCodeHandler.getMessage(cd));
|
||||
return code;
|
||||
}
|
||||
|
||||
logger.error(code, cause);
|
||||
|
||||
String msg = makeExceptionCause(cause);
|
||||
|
||||
if( msg!=null &&
|
||||
(msg.startsWith(CODE_PREFIX_ERROR) || msg.startsWith(CODE_PREFIX_FATAL)) ) {
|
||||
//return msg;
|
||||
return "["+msg+"] " + ErrorCodeHandler.getMessage(msg);
|
||||
}
|
||||
else if( msg!=null
|
||||
&& (msg.startsWith(MSGCODE_PREFIX_NEW)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_ERROR)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_FATAL)) ) {
|
||||
return msg;
|
||||
}
|
||||
else if(msg != null) {
|
||||
return formatErrorCode(code) + ErrorCodeHandler.getMessage(code) + ", " + msg;
|
||||
}
|
||||
else {
|
||||
// cause.printStackTrace();
|
||||
return formatErrorCode(code) + ErrorCodeHandler.getMessage(code);
|
||||
//return code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드 및 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param errorCode 에러 코드
|
||||
* @param errorText 에러 텍스트
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(String errorCode, String errorText) {
|
||||
return formatErrorCode(errorCode) + errorText;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드 및 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param errorCode 에러 코드
|
||||
* @param causeErrorCode 최초 발생한 오류 코드
|
||||
* @param errorText 에러 텍스트
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(String errorCode, String causeErrorCode, String errorText) {
|
||||
return formatErrorCode(errorCode) + errorText
|
||||
+ ", " + causeErrorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드에 대한 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param errorCode 에러 코드
|
||||
* @param args 에러 텍스트에 셋팅할 인수 리스트
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(String errorCode, String[] args) {
|
||||
String errorText = ErrorCodeHandler.getMessage(errorCode, args);
|
||||
return make(errorCode, errorText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드에 대한 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param errorCode 에러 코드
|
||||
* @param causeErrorCode 최초 발생한 오류 코드
|
||||
* @param args 에러 텍스트에 셋팅할 인수 리스트
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(String errorCode, String causeErrorCode, String[] args) {
|
||||
String errorText = ErrorCodeHandler.getMessage(errorCode, args);
|
||||
return make(errorCode, causeErrorCode, errorText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드에 대한 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param cause 발생한 오류
|
||||
* @param errorCode 에러 코드
|
||||
* @param args 에러 텍스트에 셋팅할 인수 리스트
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(Throwable cause, String errorCode, String[] args) {
|
||||
String errorText = ErrorCodeHandler.getMessage(errorCode,args);
|
||||
if(errorText==null) errorText = "메시지 코드 테이블에 등록되지 않은 코드입니다. - "+errorCode;
|
||||
|
||||
String msg = makeExceptionCause(cause);
|
||||
|
||||
if( msg!=null && (msg.startsWith(CODE_PREFIX_ERROR) || msg.startsWith(CODE_PREFIX_FATAL)) ) {
|
||||
return make(errorCode, msg, errorText);
|
||||
}
|
||||
else if( msg!=null
|
||||
&& (msg.startsWith(MSGCODE_PREFIX_NEW)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_ERROR)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_FATAL)) ) {
|
||||
return make(errorCode, msg, errorText);
|
||||
}
|
||||
if(msg != null) {
|
||||
return make(errorCode, errorText + ", " + msg);
|
||||
}
|
||||
else {
|
||||
return make(errorCode, errorText);
|
||||
}
|
||||
} // Controller 용
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : Error 코드에 대한 텍스트를 정의된 포맷으로 만드는 메서드
|
||||
* 2. 처리 개요 : Error 코드 및 텍스트를 정의된 포맷으로 만들어 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param cause 발생한 오류
|
||||
* @param errorCode 에러 코드
|
||||
* @return 에러코드와 텍스트
|
||||
**/
|
||||
public String make(Throwable cause, String errorCode) {
|
||||
String errorText = ErrorCodeHandler.getMessage(errorCode);
|
||||
if(errorText==null) errorText = "메시지 코드 테이블에 등록되지 않은 코드입니다. - "+errorCode;
|
||||
|
||||
String msg = makeExceptionCause(cause);
|
||||
|
||||
if( msg!=null && (msg.startsWith(CODE_PREFIX_ERROR) || msg.startsWith(CODE_PREFIX_FATAL)) ) {
|
||||
return make(errorCode, msg, errorText);
|
||||
}
|
||||
else if( msg!=null
|
||||
&& (msg.startsWith(MSGCODE_PREFIX_NEW)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_ERROR)
|
||||
|| msg.startsWith(MSGCODE_PREFIX_FATAL)) ) {
|
||||
return make(errorCode, msg, errorText);
|
||||
}
|
||||
else {
|
||||
return make(errorCode, errorText);
|
||||
}
|
||||
} // Controller 용
|
||||
|
||||
public String formatErrorCode( String code ) {
|
||||
//TODO S9 을 없앨수 있나?
|
||||
return MSGCODE_PREFIX_NEW +code+ "]";
|
||||
// if(code !=null && code.length() > 6) {
|
||||
// return MSGCODE_PREFIX_NEW + code.substring(6) + "]";
|
||||
// }
|
||||
// else {
|
||||
// return MSGCODE_PREFIX_NEW + code + "]";
|
||||
// }
|
||||
}
|
||||
|
||||
public String makeExceptionCause(Throwable cause) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(cause == null) {
|
||||
return "cause is NULL";
|
||||
}
|
||||
|
||||
sb.append(cause.getMessage());
|
||||
|
||||
Throwable t = cause.getCause();
|
||||
String secondCause = null;
|
||||
String rootCause = null;
|
||||
|
||||
if(t != null) {
|
||||
secondCause = t.getMessage();
|
||||
t = t.getCause();
|
||||
while(t != null) {
|
||||
if(t.getCause() == null) {
|
||||
rootCause = t.getMessage();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
t = t.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(secondCause != null) {
|
||||
sb.append(", ").append(secondCause);
|
||||
}
|
||||
if( rootCause != null ) {
|
||||
sb.append(", ").append(rootCause);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.eactive.eai.common.header;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : 공통부 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 interface
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
|
||||
* 3. 주의사항
|
||||
* - AD 의 경우는 S는 ADD, R 는 DELETE
|
||||
* - DA 의 경우는 S는 DELETE, R 는 ADD
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public interface HeaderAction
|
||||
{
|
||||
public byte[] excute( byte[] orgData, byte[] message, String sendRecv, String commandType);
|
||||
public byte[] deleteHeader(byte[] message, int headerLength) ;
|
||||
|
||||
public byte[] addHeaderDA(byte[] orgData , byte[] message ) ;
|
||||
public byte[] addHeaderAD(byte[] orgData , byte[] message ) ;
|
||||
|
||||
public int getHeaderLength();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.common.header;
|
||||
|
||||
public class HeaderActionException extends Exception
|
||||
{
|
||||
public HeaderActionException() {
|
||||
super("HeaderActionException is occured.");
|
||||
}
|
||||
|
||||
public HeaderActionException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.eactive.eai.common.header;
|
||||
|
||||
/**
|
||||
* 1. 기능 : 공통부 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 Factory Class
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
|
||||
* 3. 주의사항
|
||||
* - AD 의 경우는 S는 ADD, R 는 DELETE
|
||||
* - DA 의 경우는 S는 DELETE, R 는 ADD
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class HeaderActionFactory
|
||||
{
|
||||
|
||||
private HeaderActionFactory() {
|
||||
}
|
||||
|
||||
public static HeaderAction createAction(String actionName) throws HeaderActionException {
|
||||
HeaderAction action = null;
|
||||
try {
|
||||
Class cl = Class.forName(actionName);
|
||||
action = (HeaderAction)cl.newInstance();
|
||||
} catch(Exception e) {
|
||||
throw new HeaderActionException("Cannot create a HeaderAction. - "+actionName);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.eactive.eai.common.header;
|
||||
|
||||
/**
|
||||
* 1. 기능 : 공통부 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 Key
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
|
||||
* 3. 주의사항
|
||||
* - AD 의 경우는 S는 ADD, R 는 DELETE
|
||||
* - DA 의 경우는 S는 DELETE, R 는 ADD
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public class HeaderActionKeys
|
||||
{
|
||||
|
||||
public static final String ADD_DELETE_HEADER = "02";
|
||||
public static final String DELETE_ADD_HEADER = "01";
|
||||
|
||||
public static final String MESSAGE_SEND = "S";
|
||||
public static final String MESSAGE_RECV = "R";
|
||||
|
||||
public static final String SUPPORT_Y= "1";
|
||||
public static final String SUPPORT_N= "0";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.eactive.eai.common.header;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : 공통부 Header를 EAI에서 생성하거나 삭제해야하는 경우를 위한 Utility Class
|
||||
* 2. 처리 개요 :
|
||||
* - 메시지종류에 따라 헤더를 생성하거나 삭제하는 API를 제공
|
||||
* 3. 주의사항
|
||||
* - AD 의 경우는 S는 ADD, R 는 DELETE
|
||||
* - DA 의 경우는 S는 DELETE, R 는 ADD
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see :
|
||||
* @since :
|
||||
*/
|
||||
public abstract class HeaderActionSupport implements HeaderAction
|
||||
{
|
||||
private int HEADER_LENGTH = 0;
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
|
||||
public void HeaderAction(){
|
||||
|
||||
}
|
||||
public int getHeaderLength(){
|
||||
return this.HEADER_LENGTH;
|
||||
}
|
||||
public void setHeaderLength(int headerLength){
|
||||
this.HEADER_LENGTH = headerLength;
|
||||
}
|
||||
/**
|
||||
* input message로 부터 헤더추가 삭제한 메시지를 반환한다.
|
||||
*/
|
||||
public byte[] excute( byte[] orgData, byte[] message, String sendRecv, String commandType){
|
||||
|
||||
// if(logger.isDebug()) {
|
||||
// logger.debug("HeaderActionSupport] orgData=>"+new String(orgData==null?"".getBytes():orgData));
|
||||
// logger.debug("HeaderActionSupport] message=>"+new String(message==null?"".getBytes():message));
|
||||
// logger.debug("HeaderActionSupport] sendRecv=>"+sendRecv);
|
||||
// logger.debug("HeaderActionSupport] commandType=>"+commandType);
|
||||
// }
|
||||
|
||||
if(HeaderActionKeys.ADD_DELETE_HEADER.equals(commandType)) {
|
||||
if(HeaderActionKeys.MESSAGE_SEND.equals(sendRecv)) {
|
||||
return addHeaderAD(orgData , message );
|
||||
}
|
||||
else if(HeaderActionKeys.MESSAGE_RECV.equals(sendRecv)) {
|
||||
return deleteHeaderAD(message, getHeaderLength());
|
||||
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
else if(HeaderActionKeys.DELETE_ADD_HEADER.equals(commandType)) {
|
||||
if(HeaderActionKeys.MESSAGE_SEND.equals(sendRecv)) {
|
||||
return deleteHeaderDA(message, getHeaderLength());
|
||||
}
|
||||
else if(HeaderActionKeys.MESSAGE_RECV.equals(sendRecv)) {
|
||||
return addHeaderDA(orgData , message );
|
||||
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
public byte[] deleteHeaderAD(byte[] message, int headerLength) {
|
||||
return deleteHeader(message,headerLength);
|
||||
}
|
||||
public byte[] deleteHeaderDA(byte[] message, int headerLength) {
|
||||
return deleteHeader(message,headerLength);
|
||||
}
|
||||
|
||||
public byte[] deleteHeader(byte[] message, int headerLength) {
|
||||
int msgLength = message.length - headerLength;
|
||||
if(msgLength > 0) {
|
||||
byte[] retHeader = new byte[msgLength];
|
||||
System.arraycopy(message, headerLength, retHeader, 0, retHeader.length);
|
||||
return retHeader;
|
||||
}
|
||||
else {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
abstract public byte[] addHeaderDA(byte[] orgData , byte[] message ) ;
|
||||
abstract public byte[] addHeaderAD(byte[] orgData , byte[] message ) ;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
public interface Bucket {
|
||||
public boolean isAdapterPass(String adapter);
|
||||
public boolean isInterfacePass(String inter);
|
||||
public InflowTargetVO getAdapterInflowThreashold(String adapter);
|
||||
public InflowTargetVO getInterfaceInflowThreashold(String inter);
|
||||
public InflowTargetVO getInflowThreashold(String inter);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import io.github.bucket4j.local.LocalBucket;
|
||||
|
||||
public class CustomBucket {
|
||||
private InflowTargetVO inflowTargetVo;
|
||||
private LocalBucket localBucket;
|
||||
|
||||
public CustomBucket(LocalBucket localBucket, InflowTargetVO inflowTargetVo) {
|
||||
super();
|
||||
this.inflowTargetVo = inflowTargetVo;
|
||||
this.localBucket = localBucket;
|
||||
}
|
||||
|
||||
public InflowTargetVO getInflowTargetVo() {
|
||||
return inflowTargetVo;
|
||||
}
|
||||
|
||||
public void setInflowTargetVo(InflowTargetVO inflowTargetVo) {
|
||||
this.inflowTargetVo = inflowTargetVo;
|
||||
}
|
||||
|
||||
public LocalBucket getLocalBucket() {
|
||||
return localBucket;
|
||||
}
|
||||
|
||||
public void setLocalBucket(LocalBucket localBucket) {
|
||||
this.localBucket = localBucket;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.inflow.loader.InflowControlLoader;
|
||||
import com.eactive.eai.common.inflow.loader.InflowControlLogLogger;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.inflow.InflowControl;
|
||||
import com.eactive.eai.data.entity.onl.inflow.InflowControlLog;
|
||||
import com.eactive.eai.data.entity.onl.inflow.InflowControlLogId;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class InflowControlDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private InflowControlLoader inflowControlLoader;
|
||||
|
||||
@Autowired
|
||||
private InflowControlLogLogger inflowControlLogLogger;
|
||||
|
||||
public List<InflowTargetVO> getInflowAdapterList() throws DAOException {
|
||||
return getInflowList("01");
|
||||
}
|
||||
|
||||
public List<InflowTargetVO> getInflowInterfaceList() throws DAOException {
|
||||
return getInflowList("02");
|
||||
}
|
||||
|
||||
public Map<String, InflowTargetVO> getInflowTargetByAdater(String name) throws DAOException {
|
||||
return getInflowMap("01", name);
|
||||
}
|
||||
|
||||
public Map<String, InflowTargetVO> getInflowTargetByInterface(String name) throws DAOException {
|
||||
return getInflowMap("02", name);
|
||||
}
|
||||
|
||||
private List<InflowTargetVO> getInflowList(String type) throws DAOException {
|
||||
try {
|
||||
Iterable<InflowControl> inflowControls = inflowControlLoader.findByConditions(type, "");
|
||||
List<InflowTargetVO> targetList = new ArrayList<>();
|
||||
logger.info("[ @@ Load InflowControl Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (InflowControl inflowControl : inflowControls) {
|
||||
InflowTargetVO vo = new InflowTargetVO();
|
||||
vo.setName(inflowControl.getId().getName());
|
||||
vo.setThreshold(inflowControl.getThreshold());
|
||||
vo.setThresholdPerSecond(inflowControl.getThresholdpersecond());
|
||||
vo.setThresholdTimeUnit(inflowControl.getThresholdtimeunit());
|
||||
vo.setActivate(!"0".equals(inflowControl.getUseyn()));
|
||||
targetList.add(vo);
|
||||
}
|
||||
logger.info("[>>Load InflowControl Configuration - ended ]");
|
||||
return targetList;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, InflowTargetVO> getInflowMap(String type, String name) throws DAOException {
|
||||
try {
|
||||
Iterable<InflowControl> inflowControls = inflowControlLoader.findByConditions(type, name);
|
||||
Map<String, InflowTargetVO> targetList = new HashMap<>();
|
||||
logger.info("[ @@ Load InflowControl getInflowMap Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
for (InflowControl inflowControl : inflowControls) {
|
||||
InflowTargetVO vo = new InflowTargetVO();
|
||||
vo.setName(inflowControl.getId().getName());
|
||||
vo.setThreshold(inflowControl.getThreshold());
|
||||
vo.setThresholdPerSecond(inflowControl.getThresholdpersecond());
|
||||
vo.setThresholdTimeUnit(inflowControl.getThresholdtimeunit());
|
||||
vo.setActivate(!"0".equals(inflowControl.getUseyn()));
|
||||
targetList.put(vo.getName(), vo);
|
||||
}
|
||||
logger.info("[>>Load InflowControl getInflowMap Configuration - ended ]");
|
||||
return targetList;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 유량제어 로그를 INSERT하는 메서드 2. 처리 개요 : 파라미터의 코드, 메시지를 테이블에 INSERT한다. - 3.
|
||||
* 주의사항
|
||||
*
|
||||
* @param EAIBzwkDstcd EAI업무구분코드
|
||||
* @param MsgDpstYMS 메시지수신일시
|
||||
* @param EAISvcSerno EAI서비스일련번호
|
||||
* @param EAISevrInstncName EAI서버인스턴스명
|
||||
* @param EAISvcName EAI서비스명
|
||||
* @param EAIOsidInstiCd EAI대외기관코드
|
||||
* @exception DAOException JDBC 관련 오류(SQLException)
|
||||
**/
|
||||
// bzwkDstcd + msgDpstYMS + eAISvcSerno
|
||||
|
||||
// String bzwkDstcd, String msgDpstYMS, String eAISvcSerno,
|
||||
// String eAISevrInstncName, String eAISvcName, String adapterGroupName,
|
||||
// long limitPerSecond, long limit, String timeUnit
|
||||
public void addInflowServicetLog(String bzwkDstcd, String msgDpstYMS, String eAISvcSerno, String eAISevrInstncName,
|
||||
String eAISvcName, String adapterGroupName, long limitPerSecond, long limit, String timeUnit)
|
||||
throws DAOException {
|
||||
try {
|
||||
InflowControlLog inflowControlLog = new InflowControlLog();
|
||||
InflowControlLogId id = new InflowControlLogId();
|
||||
|
||||
id.setEaibzwkdstcd(bzwkDstcd);
|
||||
id.setMsgdpstyms(msgDpstYMS);
|
||||
id.setEaisvcserno(eAISvcSerno);
|
||||
|
||||
inflowControlLog.setId(id);
|
||||
inflowControlLog.setEaisevrinstncname(eAISevrInstncName);
|
||||
inflowControlLog.setEaisvcname(eAISvcName);
|
||||
inflowControlLog.setAdptrbzwkgroupname(adapterGroupName);
|
||||
inflowControlLog.setThresholdpersecond((int) limitPerSecond);
|
||||
inflowControlLog.setThreshold((int) limit);
|
||||
inflowControlLog.setThresholdtimeunit(timeUnit);
|
||||
|
||||
inflowControlLogLogger.save(inflowControlLog);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.message.EAIMessage;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.message.service.InterfaceMapper;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
import io.github.bucket4j.Bandwidth;
|
||||
import io.github.bucket4j.Bucket4j;
|
||||
import io.github.bucket4j.local.LocalBucketBuilder;
|
||||
|
||||
@Component
|
||||
public class InflowControlManager implements Lifecycle, Bucket {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
public static final String QUOTA_TIMEUNIT_SECOND = "SEC";
|
||||
public static final String QUOTA_TIMEUNIT_MINUTE = "MIN";
|
||||
public static final String QUOTA_TIMEUNIT_HOUR = "HOU";
|
||||
public static final String QUOTA_TIMEUNIT_DAY = "DAY";
|
||||
public static final String QUOTA_TIMEUNIT_MONTH = "MON";
|
||||
|
||||
private Map<String, CustomBucket> adapterBucketList = new HashMap<>();
|
||||
private Map<String, CustomBucket> interfaceBucketList = new HashMap<>();
|
||||
private boolean started;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
@Autowired
|
||||
private InflowControlDAO inflowControlDAO;
|
||||
|
||||
public static synchronized InflowControlManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(InflowControlManager.class);
|
||||
}
|
||||
|
||||
public static synchronized Bucket getBucket() {
|
||||
return ApplicationContextProvider.getContext().getBean(InflowControlManager.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 유량제어 대상인 거래인지 체크한다.(사이트에 맞게 구성)
|
||||
*
|
||||
* @param eaiServerManager
|
||||
* @param eaiMessage
|
||||
* @return
|
||||
*/
|
||||
public static Boolean isTargetOfInflowControl(EAIServerManager eaiServerManager, EAIMessage eaiMessage) {
|
||||
InterfaceMapper mapper = eaiMessage.getMapper();
|
||||
String inExDiv = MessageUtil.getInExDivision(mapper.getInExDivision(eaiMessage.getStandardMessage()),
|
||||
eaiMessage.getInternalExternalDvcd()); // 1|2
|
||||
String returnType = mapper.getSendRecvDivision(eaiMessage.getStandardMessage()); // S|R
|
||||
|
||||
if (STDMessageKeys.DIRECTION_IN.equals(inExDiv) && STDMessageKeys.SEND_RECV_CD_SEND.equals(returnType)) {
|
||||
return Boolean.valueOf(true);
|
||||
}
|
||||
|
||||
return Boolean.valueOf(false);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICMM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICMM202"));
|
||||
}
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
initAdapter();
|
||||
initInterface();
|
||||
}
|
||||
|
||||
private void initAdapter() throws Exception {
|
||||
adapterBucketList = new HashMap<>();
|
||||
List<InflowTargetVO> inflowAdapterVoList = inflowControlDAO.getInflowAdapterList();
|
||||
|
||||
for (InflowTargetVO inflowVo : inflowAdapterVoList) {
|
||||
if (InflowControlManager.isInflowTarget(inflowVo)) {
|
||||
CustomBucket bucket = makeBucketUsingInflowVO(inflowVo);
|
||||
if (bucket != null) {
|
||||
adapterBucketList.put(inflowVo.getName(), bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initInterface() throws Exception {
|
||||
interfaceBucketList = new HashMap<>();
|
||||
List<InflowTargetVO> inflowInterfaceVoList = inflowControlDAO.getInflowInterfaceList();
|
||||
|
||||
for (InflowTargetVO inflowVo : inflowInterfaceVoList) {
|
||||
if (InflowControlManager.isInflowTarget(inflowVo)) {
|
||||
CustomBucket bucket = makeBucketUsingInflowVO(inflowVo);
|
||||
if (bucket != null) {
|
||||
interfaceBucketList.put(inflowVo.getName(), bucket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reloadAdapter() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload all Started ...");
|
||||
}
|
||||
initAdapter();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reloadInterface() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload all Started ...");
|
||||
}
|
||||
initInterface();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reloadAdapter(String adapter) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload Started ...");
|
||||
}
|
||||
Map<String, InflowTargetVO> map = inflowControlDAO.getInflowTargetByAdater(adapter);
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = "";
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
|
||||
InflowTargetVO inflowTarget = map.get(key);
|
||||
if (InflowControlManager.isInflowTarget(inflowTarget)) {
|
||||
CustomBucket bucket = makeBucketUsingInflowVO(inflowTarget);
|
||||
if (bucket != null) {
|
||||
adapterBucketList.put(inflowTarget.getName(), bucket);
|
||||
} else {
|
||||
adapterBucketList.remove(inflowTarget.getName());
|
||||
}
|
||||
} else {
|
||||
adapterBucketList.remove(inflowTarget.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reloadInterface(String inter) throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload Started ...");
|
||||
}
|
||||
Map<String, InflowTargetVO> map = inflowControlDAO.getInflowTargetByInterface(inter);
|
||||
if (map != null) {
|
||||
Iterator<String> it = map.keySet().iterator();
|
||||
String key = "";
|
||||
while (it.hasNext()) {
|
||||
key = it.next();
|
||||
|
||||
InflowTargetVO inflowTarget = map.get(key);
|
||||
if (InflowControlManager.isInflowTarget(inflowTarget)) {
|
||||
CustomBucket bucket = makeBucketUsingInflowVO(inflowTarget);
|
||||
if (bucket != null) {
|
||||
interfaceBucketList.put(inflowTarget.getName(), bucket);
|
||||
} else {
|
||||
interfaceBucketList.remove(inflowTarget.getName());
|
||||
}
|
||||
} else {
|
||||
interfaceBucketList.remove(inflowTarget.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("InflowControlManager] reload finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
// Validate and update our current component state
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICMM203");
|
||||
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
adapterBucketList.clear();
|
||||
interfaceBucketList.clear();
|
||||
|
||||
started = false;
|
||||
// Notify our interested LifecycleListeners
|
||||
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 String[] getAdapterAllKeys() {
|
||||
Iterator<String> it = this.adapterBucketList.keySet().iterator();
|
||||
String[] svcCd = new String[this.adapterBucketList.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
svcCd[i] = it.next();
|
||||
}
|
||||
Arrays.sort(svcCd);
|
||||
return svcCd;
|
||||
}
|
||||
|
||||
public String[] getInterfaceAllKeys() {
|
||||
Iterator<String> it = this.interfaceBucketList.keySet().iterator();
|
||||
String[] svcCd = new String[this.interfaceBucketList.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
svcCd[i] = it.next();
|
||||
}
|
||||
Arrays.sort(svcCd);
|
||||
return svcCd;
|
||||
}
|
||||
|
||||
public void removeAdapter(String adapter) {
|
||||
adapterBucketList.remove(adapter);
|
||||
}
|
||||
|
||||
public void removeInterface(String inter) {
|
||||
interfaceBucketList.remove(inter);
|
||||
}
|
||||
|
||||
private CustomBucket makeBucketUsingInflowVO(InflowTargetVO inflowTarget) {
|
||||
if (InflowControlManager.isInflowTarget(inflowTarget)) {
|
||||
LocalBucketBuilder builder = Bucket4j.builder();
|
||||
if (inflowTarget.getThresholdPerSecond() > 0) {
|
||||
builder.addLimit(Bandwidth.simple(inflowTarget.getThresholdPerSecond(), Duration.ofSeconds(1)));
|
||||
}
|
||||
|
||||
if (inflowTarget.getThreshold() > 0 && StringUtils.isNotBlank(inflowTarget.getThresholdTimeUnit())) {
|
||||
builder.addLimit(Bandwidth.simple(inflowTarget.getThreshold(),
|
||||
InflowControlManager.getPeriod(inflowTarget.getThresholdTimeUnit())));
|
||||
}
|
||||
|
||||
return new CustomBucket(builder.build(), inflowTarget);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdapterPass(String adapter) {
|
||||
CustomBucket b = adapterBucketList.get(adapter);
|
||||
|
||||
if (b == null)
|
||||
return true;
|
||||
|
||||
return b.getLocalBucket().tryConsume(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterfacePass(String inter) {
|
||||
CustomBucket b = interfaceBucketList.get(inter);
|
||||
|
||||
if (b == null)
|
||||
return true;
|
||||
|
||||
return b.getLocalBucket().tryConsume(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InflowTargetVO getAdapterInflowThreashold(String adapter) {
|
||||
CustomBucket b = adapterBucketList.get(adapter);
|
||||
if (b == null)
|
||||
return null;
|
||||
return b.getInflowTargetVo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InflowTargetVO getInterfaceInflowThreashold(String inter) {
|
||||
CustomBucket b = interfaceBucketList.get(inter);
|
||||
if (b == null)
|
||||
return null;
|
||||
return b.getInflowTargetVo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InflowTargetVO getInflowThreashold(String inter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public InflowTargetVO getAdapterInflow(String adapter) {
|
||||
return getAdapterInflowThreashold(adapter);
|
||||
}
|
||||
|
||||
public InflowTargetVO getInterfaceInflow(String inter) {
|
||||
return getInterfaceInflowThreashold(inter);
|
||||
}
|
||||
|
||||
public static boolean isInflowTarget(InflowTargetVO inflowTarget) {
|
||||
if (inflowTarget == null || !inflowTarget.isActivate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return inflowTarget.getThresholdPerSecond() > 0 || (inflowTarget.getThreshold() > 0 && StringUtils
|
||||
.equalsAnyIgnoreCase(inflowTarget.getThresholdTimeUnit(), QUOTA_TIMEUNIT_DAY, QUOTA_TIMEUNIT_SECOND,
|
||||
QUOTA_TIMEUNIT_MINUTE, QUOTA_TIMEUNIT_HOUR, QUOTA_TIMEUNIT_DAY, QUOTA_TIMEUNIT_MONTH));
|
||||
|
||||
}
|
||||
|
||||
public static Duration getPeriod(String timeUnit) {
|
||||
if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_SECOND)) {
|
||||
return Duration.ofSeconds(1);
|
||||
} else if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_MINUTE)) {
|
||||
return Duration.ofMinutes(1);
|
||||
} else if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_HOUR)) {
|
||||
return Duration.ofHours(1);
|
||||
} else if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_DAY)) {
|
||||
return Duration.ofDays(1);
|
||||
} else if (StringUtils.equalsIgnoreCase(timeUnit, QUOTA_TIMEUNIT_MONTH)) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
return Duration.ofDays(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
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.util.Logger;
|
||||
|
||||
public class InflowControlUtil {
|
||||
private InflowControlUtil() {
|
||||
}
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static Bucket getBucket() {
|
||||
Properties inFlowProp = PropManager.getInstance().getProperties("INFLOW");
|
||||
String className = inFlowProp.getProperty("inflow.control.bucket.className");
|
||||
if (StringUtils.isBlank(className)
|
||||
|| StringUtils.equals(className, "com.eactive.eai.common.inflow.InflowControlManager")) {
|
||||
return InflowControlManager.getBucket();
|
||||
} else {
|
||||
try {
|
||||
Class clazz = Class.forName(className);
|
||||
Method method = clazz.getMethod("getBucket", (Class<?>[]) null);
|
||||
return (Bucket) method.invoke(null, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
logger.error("Method call error class= {}, method= getBucket", className);
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static boolean isTargetOfInflowControl(EAIServerManager eaiServerManager, EAIMessage eaiMessage) {
|
||||
Properties inFlowProp = PropManager.getInstance().getProperties("INFLOW");
|
||||
String controlInflow = inFlowProp.getProperty("inflow.control.yn", "N");
|
||||
|
||||
if (!"Y".equalsIgnoreCase(controlInflow)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String className = inFlowProp.getProperty("inflow.control.bucket.className");
|
||||
if (StringUtils.isBlank(className)
|
||||
|| StringUtils.equals(className, "com.eactive.eai.common.inflow.InflowControlManager")) {
|
||||
return InflowControlManager.isTargetOfInflowControl(eaiServerManager, eaiMessage).booleanValue();
|
||||
} else {
|
||||
try {
|
||||
Class clazz = Class.forName(className);
|
||||
Method method = clazz.getMethod("isTargetOfInflowControl", EAIServerManager.class, EAIMessage.class);
|
||||
Boolean returnBoolean = (Boolean) method.invoke(null, eaiServerManager, eaiMessage);
|
||||
return returnBoolean.booleanValue();
|
||||
} catch (Exception e) {
|
||||
logger.error("Method call error class= {}, method= isTargetOfInflowControl", className);
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class InflowTargetVO implements Serializable {
|
||||
String name;
|
||||
long thresholdPerSecond;
|
||||
long threshold;
|
||||
String thresholdTimeUnit;
|
||||
boolean activate;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return name.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public boolean isActivate() {
|
||||
return activate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getThreshold() {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
public void setThreshold(long threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public void setActivate(boolean activate) {
|
||||
this.activate = activate;
|
||||
}
|
||||
|
||||
public long getThresholdPerSecond() {
|
||||
return thresholdPerSecond;
|
||||
}
|
||||
|
||||
public void setThresholdPerSecond(long thresholdPerSecond) {
|
||||
this.thresholdPerSecond = thresholdPerSecond;
|
||||
}
|
||||
|
||||
public String getThresholdTimeUnit() {
|
||||
return thresholdTimeUnit;
|
||||
}
|
||||
|
||||
public void setThresholdTimeUnit(String thresholdTimeUnit) {
|
||||
this.thresholdTimeUnit = thresholdTimeUnit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InflowTargetVO [name=" + name + ", thresholdPerSecond=" + thresholdPerSecond + ", threshold="
|
||||
+ threshold + ", thresholdTimeUnit=" + thresholdTimeUnit + ", activate=" + activate + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.eactive.eai.common.jeus;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.QueueSender;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.jms.JmsServiceLocator;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class JeusQueueProducer {
|
||||
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
QueueConnectionFactory qconFactory = null;
|
||||
|
||||
String connectionFactory = null;
|
||||
String destination = null;
|
||||
|
||||
public JeusQueueProducer(String connectionUrl, String queueName) throws Exception {
|
||||
this.connectionFactory = connectionUrl;
|
||||
this.destination = queueName;
|
||||
}
|
||||
|
||||
public void sendMessage(Serializable object, Properties prop) throws Exception {
|
||||
QueueConnection qcon = null;
|
||||
QueueSession qsession = null;
|
||||
Queue queue = null;
|
||||
QueueSender qsender = null;
|
||||
try {
|
||||
JmsServiceLocator locator = JmsServiceLocator.getInstance();
|
||||
|
||||
qconFactory = locator.getQueueConnectionFactory(connectionFactory);
|
||||
qcon = qconFactory.createQueueConnection();
|
||||
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
queue = locator.getQueue(destination);
|
||||
qsender = qsession.createSender(queue);
|
||||
|
||||
ObjectMessage msg = qsession.createObjectMessage();
|
||||
msg.setObject(object);
|
||||
|
||||
// Properties setting setStringProperties();
|
||||
if (prop != null) {
|
||||
Iterator it = prop.keySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
String key = (String) it.next();
|
||||
String value = prop.getProperty(key);
|
||||
msg.setStringProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
qsender.send(msg);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// throw new JMSException("RECEAICUL001");
|
||||
throw new JMSException(ExceptionUtil.getErrorCode(e, "RECEAICUL001"));
|
||||
} finally {
|
||||
try {
|
||||
if (qsender != null)
|
||||
qsender.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if (qsession != null)
|
||||
qsession.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if (qcon != null)
|
||||
qcon.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.eactive.eai.common.jeus;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.ObjectMessage;
|
||||
import javax.jms.Session;
|
||||
import javax.jms.Topic;
|
||||
import javax.jms.TopicConnection;
|
||||
import javax.jms.TopicConnectionFactory;
|
||||
import javax.jms.TopicPublisher;
|
||||
import javax.jms.TopicSession;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.jms.JmsServiceLocator;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
public class JeusTopicProducer {
|
||||
|
||||
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
TopicConnectionFactory topicFactory = null;
|
||||
|
||||
String connectionFactory = null;
|
||||
String destination = null;
|
||||
String correlationID = null;
|
||||
|
||||
public JeusTopicProducer(String connectionUrl, String topicName, String correlationID) throws Exception {
|
||||
this.connectionFactory = connectionUrl;
|
||||
this.destination = topicName;
|
||||
this.correlationID = correlationID;
|
||||
}
|
||||
|
||||
//JMSSender.sendToTopic(eaiMessage, topicConFactory, routeTopicName, null, traceKey, ttl);
|
||||
|
||||
public void sendMessage(Serializable object, Properties prop, long ttl) throws Exception {
|
||||
TopicConnection tcon = null;
|
||||
TopicSession tsession = null;
|
||||
Topic topic = null;
|
||||
TopicPublisher publisher = null;
|
||||
try {
|
||||
if (logger.isDebug()){
|
||||
logger.debug("sendToTopic] connectionFactory = "+connectionFactory);
|
||||
logger.debug("sendToTopic] destination = "+destination);
|
||||
logger.debug("sendToTopic] correlationID =["+correlationID+"]");
|
||||
}
|
||||
JmsServiceLocator locator = JmsServiceLocator.getInstance();
|
||||
topicFactory = locator.getTopicConnectionFactory(connectionFactory);
|
||||
topic = locator.getTopic(destination);
|
||||
|
||||
tcon = topicFactory.createTopicConnection();
|
||||
tsession = tcon.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
||||
publisher = tsession.createPublisher(topic);
|
||||
|
||||
// TTL Setting
|
||||
if(ttl > 0) {
|
||||
publisher.setTimeToLive(ttl);
|
||||
}
|
||||
|
||||
ObjectMessage msg = tsession.createObjectMessage();
|
||||
msg.setObject(object);
|
||||
if (correlationID != null)
|
||||
msg.setJMSCorrelationID(correlationID);
|
||||
|
||||
// Properties setting setStringProperties();
|
||||
if(prop!=null) {
|
||||
Iterator it = prop.keySet().iterator();
|
||||
while(it.hasNext()) {
|
||||
String key = (String)it.next();
|
||||
String value = prop.getProperty(key);
|
||||
msg.setStringProperty(key,value);
|
||||
}
|
||||
}
|
||||
publisher.publish(msg);
|
||||
} catch(Exception e) {
|
||||
throw new JMSException(ExceptionUtil.getErrorCode(e,"RECEAICUL002"));
|
||||
} finally {
|
||||
try {
|
||||
if(publisher!=null) publisher.close();
|
||||
} catch(Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if(tsession!=null) tsession.close();
|
||||
} catch(Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if(tcon!=null) tcon.close();
|
||||
} catch(Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.eactive.eai.common.jms;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.Topic;
|
||||
import javax.jms.TopicConnectionFactory;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.ServiceLocatorException;
|
||||
|
||||
public class JmsServiceLocator {
|
||||
static private Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static JmsServiceLocator instance;
|
||||
private InitialContext initial;
|
||||
private Map cache;
|
||||
|
||||
protected JmsServiceLocator() throws ServiceLocatorException {
|
||||
try {
|
||||
initial = new InitialContext();
|
||||
cache = Collections.synchronizedMap(new HashMap());
|
||||
} catch (NamingException e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL101"));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL102"));
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized JmsServiceLocator getInstance() throws ServiceLocatorException {
|
||||
if (instance == null) {
|
||||
instance = new JmsServiceLocator();
|
||||
return instance;
|
||||
} else {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public QueueConnectionFactory getQueueConnectionFactory(String qConnFactoryName) throws ServiceLocatorException {
|
||||
QueueConnectionFactory factory = null;
|
||||
|
||||
try {
|
||||
if (cache.containsKey(qConnFactoryName)) {
|
||||
factory = (QueueConnectionFactory) cache.get(qConnFactoryName);
|
||||
} else {
|
||||
factory = (QueueConnectionFactory) initial.lookup(qConnFactoryName);
|
||||
cache.put(qConnFactoryName, factory);
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(ne, "RECEAICUL113"));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL114"));
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
public Queue getQueue(String queueName) throws ServiceLocatorException {
|
||||
Queue queue = null;
|
||||
try {
|
||||
if (cache.containsKey(queueName)) {
|
||||
queue = (Queue) cache.get(queueName);
|
||||
} else {
|
||||
queue = (Queue) initial.lookup(queueName);
|
||||
cache.put(queueName, queue);
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(ne, "RECEAICUL115"));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL116"));
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
public TopicConnectionFactory getTopicConnectionFactory(String topicConnFactoryName)
|
||||
throws ServiceLocatorException {
|
||||
TopicConnectionFactory factory = null;
|
||||
|
||||
try {
|
||||
if (cache.containsKey(topicConnFactoryName)) {
|
||||
factory = (TopicConnectionFactory) cache.get(topicConnFactoryName);
|
||||
} else {
|
||||
factory = (TopicConnectionFactory) initial.lookup(topicConnFactoryName);
|
||||
cache.put(topicConnFactoryName, factory);
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(ne, "RECEAICUL117"));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL118"));
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
public Topic getTopic(String topicName) throws ServiceLocatorException {
|
||||
Topic topic = null;
|
||||
try {
|
||||
if (cache.containsKey(topicName)) {
|
||||
topic = (Topic) cache.get(topicName);
|
||||
} else {
|
||||
topic = (Topic) initial.lookup(topicName);
|
||||
cache.put(topicName, topic);
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(ne, "RECEAICUL119"));
|
||||
} catch (Exception e) {
|
||||
throw new ServiceLocatorException(ExceptionUtil.getErrorCode(e, "RECEAICUL120"));
|
||||
}
|
||||
return topic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
|
||||
public class CustomStringBuffer {
|
||||
private StringBuffer sb ;
|
||||
private String DELEMITER ;
|
||||
public CustomStringBuffer() {
|
||||
this.sb = new StringBuffer();
|
||||
this.DELEMITER = "#|@";
|
||||
|
||||
}
|
||||
public CustomStringBuffer(String delemiter) {
|
||||
this.sb = new StringBuffer();
|
||||
this.DELEMITER = delemiter;
|
||||
}
|
||||
public CustomStringBuffer appendAndDelimeter(String data){
|
||||
sb.append(data).append(DELEMITER);
|
||||
return this;
|
||||
}
|
||||
public CustomStringBuffer appendAndDelimeter(int data){
|
||||
sb.append(Integer.toString(data)).append(DELEMITER);
|
||||
return this;
|
||||
}
|
||||
public CustomStringBuffer append(String data){
|
||||
sb.append(data);
|
||||
return this;
|
||||
}
|
||||
public CustomStringBuffer append(int data){
|
||||
sb.append(Integer.toString(data));
|
||||
return this;
|
||||
}
|
||||
public String toString(){
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// public static void main(String[] args){
|
||||
// CustomStringBuffer sb = new CustomStringBuffer();
|
||||
// sb.appendAndDelimeter("ABD").append("KKK");
|
||||
// System.out.println(sb.toString());
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.eactive.eai.adapter.ElinkAdapter;
|
||||
import com.eactive.eai.adapter.ElinkAdapterFactory;
|
||||
import com.eactive.eai.common.dao.DAOFactory;
|
||||
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.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI에서 처리되는 모든 On-Line 거래를 데이터베이스에 로깅하기 위한 운영관리 Logger Sender
|
||||
* 2. 처리 개요 :
|
||||
* - Processor에서 받은 거래로그 정보를 저장
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 3.0.0
|
||||
* @see :
|
||||
* @since :JDK v1.5.0
|
||||
*/
|
||||
public class DBLogTransactionLogger implements TransactionLogger {
|
||||
// 거래 로그 Count
|
||||
private int logCount;
|
||||
|
||||
// 에러 로그 Count
|
||||
private int errCount;
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI 거래 로그 Count를 반환
|
||||
* 2. 처리 개요 :
|
||||
* - EAI 거래 로그 Count를 반환한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return int 거래 로그 Count
|
||||
**/
|
||||
public int logCount() {
|
||||
return logCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI 에러 로그 Count를 반환
|
||||
* 2. 처리 개요 :
|
||||
* - EAI 거래 에러 Count를 반환한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return int 에러 로그 Count
|
||||
**/
|
||||
public int errCount() {
|
||||
return errCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 거래 로그 및 에러 로그 초기화
|
||||
* 2. 처리 개요 :
|
||||
* - 거래 및 에러 로그를 초기화 한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
**/
|
||||
public void resetCount() {
|
||||
logCount = 0;
|
||||
errCount = 0;
|
||||
}
|
||||
|
||||
private byte[] callAdapter(String adapterGroupName, Properties prop, Object message)
|
||||
throws java.lang.Exception {
|
||||
byte[] resBytes;
|
||||
try {
|
||||
|
||||
ElinkAdapterFactory factory = ElinkAdapterFactory.newInstance();
|
||||
ElinkAdapter adapter = null;
|
||||
adapter = factory.getElinkAdapter(com.eactive.eai.adapter.Keys.TYPE_NET2);
|
||||
|
||||
if(prop==null) {
|
||||
prop = new Properties();
|
||||
}
|
||||
if(prop.getProperty("ADAPTER_GROUP_NAME") == null) {
|
||||
prop.setProperty("ADAPTER_GROUP_NAME", adapterGroupName);
|
||||
}
|
||||
resBytes = (byte[])adapter.callService(adapterGroupName, prop, message, prop);
|
||||
} catch(Exception e) {
|
||||
logger.error("callSocketAdapter error", e);
|
||||
//throw new Exception(ExceptionUtil.getErrorCode(e, SOCK_CONTROL_ERROR));
|
||||
throw e;
|
||||
}
|
||||
return resBytes;
|
||||
}
|
||||
|
||||
private byte[] getItsmSMSMesage(EAIMessage eaimessage) {
|
||||
byte[] itsmSMSMessage = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try {
|
||||
// make message from EAIMessage
|
||||
sb.append(eaimessage.getEAISvcCd());
|
||||
itsmSMSMessage = sb.toString().getBytes();
|
||||
}
|
||||
catch(Exception e) {
|
||||
itsmSMSMessage = sb.toString().getBytes();
|
||||
}
|
||||
return itsmSMSMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 로깅 정보를 로그 Queue로 전달
|
||||
* 2. 처리 개요 :
|
||||
* - 로깅 정보를 로그 Queue로 전달
|
||||
* - 실시간 거래 정보 통계를 위해 EAIServiceMonitor로 전달
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message EAIMessage
|
||||
* @param prop logging 관련 Properties
|
||||
* @exception EAILogException
|
||||
**/
|
||||
public void log(EAIMessage message, Properties prop) throws EAILogException {
|
||||
++logCount;
|
||||
int svcLogLvl = message.getSvcLogLvl();
|
||||
String svcTsmtUsgTp = message.getSvcTsmtUsgTp();
|
||||
int logPssSno = message.getLogPssSno();
|
||||
boolean isLogging = false;
|
||||
|
||||
String guidLogPrefix = "DBLogTransactionLogger] GUID["
|
||||
+ message.getMapper().getGuid(message.getStandardMessage())
|
||||
+ "] UUID[" + message.getSvcOgNo() + "] ";
|
||||
|
||||
try {
|
||||
// Direct DB Logging
|
||||
String logType = "DB";
|
||||
String setLogType = PropManager.getInstance().getProperty("LOG_TYPE");
|
||||
if(setLogType != null) {
|
||||
logType = setLogType;
|
||||
}
|
||||
|
||||
if("DB".equals(logType)) {
|
||||
insertLog(message, prop);
|
||||
}
|
||||
else {
|
||||
EAIFileLogger.getInstance().setLog(message, prop);
|
||||
}
|
||||
//---------------------------------------------------->
|
||||
// ITSM ERROR Log 전송
|
||||
// 템플릿만 남겨두고, 나머지는 사이트에 맞게 수정 필요함.
|
||||
//---------------------------------------------------->
|
||||
boolean itsmEnabled = false;
|
||||
if((itsmEnabled) && !MessageUtil.checkRspErrCd(message.getRspErrCd())) {
|
||||
if(logger.isDebug()) {
|
||||
logger.debug(guidLogPrefix + " ITSM Error Message Notify! ");
|
||||
}
|
||||
if(( EAIMessageKeys.SYNC_SVC.equals(svcTsmtUsgTp) && logPssSno == 400 ) ||
|
||||
( EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && (logPssSno == 200 || logPssSno == 400))) {
|
||||
String itsmErrorAdapterName = "";
|
||||
itsmErrorAdapterName = PropManager.getInstance().getProperty("ITSM_CONFIG","ADAPTER_GROUP_NAME_ERROR"); /* Properties 추가 및 어뎁터 등록 */
|
||||
if (logger.isDebug()) {
|
||||
logger.debug(guidLogPrefix + " ITSM ERROR Send Message Adapter Name[" + itsmErrorAdapterName + "]");
|
||||
}
|
||||
|
||||
if(itsmErrorAdapterName != null && itsmErrorAdapterName.length() > 0) {
|
||||
byte[] itsmSMSMessage = getItsmSMSMesage(message); /* ITSM 전송 메시지 포맷 결정 */
|
||||
Properties itsmProp = new Properties();
|
||||
callAdapter(itsmErrorAdapterName, itsmProp, itsmSMSMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
if (logger.isError()) logger.error(guidLogPrefix + " ITSM ERROR Send ERROR " + e.getMessage(),e);
|
||||
errCount++;
|
||||
//throw new EAILogException(ExceptionUtil.getErrorCode(e, "RECEAICLG005"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void insertLog(EAIMessage eaiMessage, Properties prop) throws EAILogException {
|
||||
String guidLogPrefix = "DBLogTransactionLogger] GUID["+ eaiMessage.getMapper().getGuid(eaiMessage.getStandardMessage())
|
||||
+"] UUID["+eaiMessage.getSvcOgNo()+"] ";
|
||||
try {
|
||||
if (EAIDBLogControl.isEnable()){
|
||||
try {
|
||||
EAILogDAO dao = ApplicationContextProvider.getContext().getBean(EAILogDAO.class);
|
||||
dao.addEAISvcLog(eaiMessage, prop);
|
||||
} catch(Exception e) {
|
||||
if (logger.isError()) logger.error(guidLogPrefix +" insertLog DB ERROR. - " + e.getMessage(),e);
|
||||
// DB Connection Error일 경우에만 설정하도록 수정
|
||||
String message = e.getMessage();
|
||||
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
|
||||
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
|
||||
if( "ConnectionError".equals(message) || StringUtils.contains(message, "JDBCConnectionException")
|
||||
|| StringUtils.contains(message, "Unable to acquire JDBC Connection") ) {
|
||||
EAIDBLogControl.setEnable(false);
|
||||
}
|
||||
//file log
|
||||
EAIFileLogger.getInstance().setLog(eaiMessage, prop);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
else{
|
||||
//file log
|
||||
EAIFileLogger.getInstance().setLog(eaiMessage, prop);
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
if (logger.isError()) logger.error(guidLogPrefix + " insertLog ERROR. - " + e.getMessage(), e);
|
||||
throw new EAILogException("insertLog ERROR."+ e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOFactory;
|
||||
import com.eactive.eai.common.logger.async.HttpAdapterExtraLogH2Factory;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
|
||||
/**
|
||||
* 1. 기능 : DB 장애 상태 관리
|
||||
* 2. 처리 개요 :
|
||||
* 3. 주의사항
|
||||
*/
|
||||
public class EAIDBLogControl {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private static boolean isEnable = true;
|
||||
|
||||
private EAIDBLogControl() {
|
||||
|
||||
}
|
||||
|
||||
public static synchronized boolean isEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public static synchronized void setEnable(boolean enable) {
|
||||
if (isEnable == enable) return ;
|
||||
isEnable = enable;
|
||||
if (!enable){
|
||||
//thread 기동
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
while(true) {
|
||||
try {
|
||||
//db check
|
||||
EAILogDAO dao = ApplicationContextProvider.getContext().getBean(EAILogDAO.class);
|
||||
|
||||
boolean result = dao.getCheck();
|
||||
if (result){
|
||||
setEnable(result);
|
||||
// 25.04.29 안해도 정상적으로 Header 정보 저장됨 확인
|
||||
// 있으면 오히려 NoClassDefFoundError Exception 발생
|
||||
// HttpAdapterExtraLogH2Factory.getInstance().closeSessionFactory();
|
||||
break;
|
||||
}
|
||||
} catch(Throwable t) {
|
||||
logger.warn("setEnable", t);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch(InterruptedException e) {
|
||||
logger.warn("sleep", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread t = new Thread(runnable);
|
||||
t.setName("DBChecker-Launcher");
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,900 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.agent.encryption.EncryptionManager;
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
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.MessageType;
|
||||
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.util.DatetimeUtil;
|
||||
import com.eactive.eai.common.util.LogKeys;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.common.util.NullControl;
|
||||
import com.eactive.eai.common.util.StringUtil;
|
||||
import com.eactive.eai.transformer.layout.Item;
|
||||
import com.eactive.eai.transformer.layout.Layout;
|
||||
import com.eactive.eai.transformer.transform.Transform;
|
||||
import com.eactive.eai.transformer.transform.TransformManager;
|
||||
import com.eactive.eai.transformer.util.IConv;
|
||||
import com.eactive.eai.util.HexaConverter;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
/**
|
||||
* 1. 기능 : DAO 객체를 생성하기 위한 Factory 클래스
|
||||
* 2. 처리 개요 : DAO 객체를 생성하는 Factory 메서드를 정의한다.
|
||||
* * -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since :
|
||||
* :
|
||||
*/
|
||||
public class EAIFileLogger
|
||||
{
|
||||
private static EAIFileLogger instance ;
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
static Logger tranLogger = Logger.getLogger(Logger.LOGGER_TRAN);
|
||||
|
||||
private static final String DELIMITER = "#|@";
|
||||
private static final String EOL = "EOL$$;";
|
||||
|
||||
private EAIFileLogger() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI File Logger 객체를 생성 반환하는 메서드
|
||||
* 2. 처리 개요 : EAI File Logger 객체를 생성 반환한다.
|
||||
* -
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return DAOFactory
|
||||
**/
|
||||
public static EAIFileLogger getInstance() {
|
||||
if (instance == null){
|
||||
instance = new EAIFileLogger();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 메시지의 Type이 EBCDIC인지 판단
|
||||
* 2. 처리 개요 :
|
||||
* - 로그시퀀스에 맞는 Adapter의 메시지 type을 비교
|
||||
* - EBC인지 판별
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param srcIfType String
|
||||
* @param tgtIfType String
|
||||
* @param logPssSno int
|
||||
* @param srcAdapterMsgType String
|
||||
* @param tgtAdapterMsgType String
|
||||
* @return boolean
|
||||
**/
|
||||
public boolean isEBC(String srcIfType, String tgtIfType, int logPssSno,
|
||||
String srcAdapterMsgType, String tgtAdapterMsgType) {
|
||||
|
||||
boolean isEBCDIC = false;
|
||||
|
||||
// SS. SA Type
|
||||
if(logPssSno == 100) {
|
||||
if( "EBC".equals(srcAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
else if(logPssSno == 200) {
|
||||
if( "EBC".equals(tgtAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
else if(logPssSno == 300) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if( "EBC".equals(srcAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( "EBC".equals(tgtAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 400
|
||||
else if(logPssSno == 400) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if( "EBC".equals(tgtAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( "EBC".equals(srcAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 900
|
||||
else {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if( "EBC".equals(tgtAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( "EBC".equals(srcAdapterMsgType) ) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isEBCDIC;
|
||||
}
|
||||
|
||||
public boolean isUTF8(String srcIfType, String tgtIfType, int logPssSno,
|
||||
String srcAdapterMsgEncode, String tgtAdapterMsgEncode) {
|
||||
boolean isUTF = false;
|
||||
if (logger.isInfo()) {
|
||||
logger.info(String.format("EAIFileLogger] isUTF8 %s %s %s %s %s", srcIfType, tgtIfType, logPssSno, srcAdapterMsgEncode, tgtAdapterMsgEncode));
|
||||
}
|
||||
|
||||
String adapterMsgEncode = "";
|
||||
// SS. SA Type
|
||||
if(logPssSno == 100) {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
else if(logPssSno == 200) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
}
|
||||
else if(logPssSno == 300) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
else {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
// 400
|
||||
else if(logPssSno == 400) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
}
|
||||
else {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
// 900
|
||||
else {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) &&
|
||||
EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
}
|
||||
else {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
isUTF = StringUtils.equalsIgnoreCase(adapterMsgEncode, "UTF-8");
|
||||
return isUTF;
|
||||
}
|
||||
|
||||
protected String removeXMLHeaderAll(String xmlMsg) {
|
||||
|
||||
if(xmlMsg == null) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
xmlMsg = xmlMsg.trim();
|
||||
}
|
||||
int sPos = xmlMsg.indexOf("<Individual>");
|
||||
int ePos = xmlMsg.indexOf("</Individual>");
|
||||
|
||||
// 중간에 있는 경우 - CDATA 의 내용
|
||||
if(sPos > -1 && ePos > -1) {
|
||||
xmlMsg = xmlMsg.substring(sPos+12, ePos);
|
||||
}
|
||||
return xmlMsg;
|
||||
}
|
||||
|
||||
// private String removeXMLRootItem(String xmlString, String rootItemName) {
|
||||
// String prefix = "<" + rootItemName + ">";
|
||||
// String suffix = "</" + rootItemName + ">";
|
||||
//
|
||||
// int s_idx = xmlString.indexOf(prefix);
|
||||
// int e_idx = xmlString.indexOf(suffix);
|
||||
// if (s_idx == -1 || e_idx == -1) {
|
||||
// return xmlString;
|
||||
// } else {
|
||||
// return xmlString.substring(s_idx + prefix.length(), e_idx);
|
||||
// }
|
||||
// }
|
||||
|
||||
// private String addJsonRootItem(String jsonString, String rootItemName) {
|
||||
// JSONObject value = (JSONObject)JSONValue.parse(jsonString);
|
||||
// JSONObject root = new JSONObject();
|
||||
// root.put(rootItemName, value);
|
||||
// return root.toJSONString();
|
||||
// }
|
||||
|
||||
// private String removeJsonRootItem(String jsonString, String rootItemName) {
|
||||
// JSONObject value = (JSONObject)JSONValue.parse(jsonString);
|
||||
// JSONObject sub = (JSONObject) value.get(rootItemName);
|
||||
// return sub.toJSONString();
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI 서비스 로그 셋팅
|
||||
* 2. 처리 개요 :
|
||||
* - tran.log(EAI서비스로그) 로그값 셋팅
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message EAIMessage
|
||||
* @exception DAOException
|
||||
**/
|
||||
public void setLog(EAIMessage message, Properties prop) throws Exception{
|
||||
|
||||
|
||||
// 업무데이터 size 체크하여 업무데이터1,2에 insert하고
|
||||
// addBwkDataSub(message) 호출 여부 결정
|
||||
|
||||
String apndBwkDataYn = "N"; //추가업무데이터 여부
|
||||
int dayOfWeek = DatetimeUtil.getDayOfWeekNum(message.getMsgRcvTm());
|
||||
|
||||
// 개별메시지
|
||||
// Object bizMsg = message.getBizMsg()[0];
|
||||
// Object bizMsg = message.getExtMsg().getBizData()[0];
|
||||
Object bizMsg = message.getStandardMessage().getBizData();
|
||||
|
||||
ServiceMessage svcMsg = message.getCurrentSvcMsg();
|
||||
String bizMsgStr = "";
|
||||
|
||||
//transformer 적용
|
||||
String svcTsmtUsgTp = message.getSvcTsmtUsgTp(); // 기동 Syunc/Async
|
||||
String psvItfTp = svcMsg.getPsvItfTp(); // 수동 Syunc/Async
|
||||
int logPssSno = message.getLogPssSno();
|
||||
String rspErrCd = message.getRspErrCd();
|
||||
|
||||
// Duplication Error 방지를 위해
|
||||
// 원 로그처리일련번호를 저장 : 2009.07.13
|
||||
int orglogPssSno = logPssSno;
|
||||
|
||||
// int svcLogLvl = message.getSvcLogLvl();
|
||||
boolean loggingBizData = true;
|
||||
// if(svcLogLvl > 3) {
|
||||
// loggingBizData = false;
|
||||
// }
|
||||
|
||||
if (logger.isWarn()) logger.warn("EAIFileLogger] loggingBizData - " + loggingBizData);
|
||||
|
||||
// 복합거래인 경우 2X1,3X1 -> 200, 2X2,3X2 -> 300 처럼 처리한다.
|
||||
if( (logPssSno > 200 && logPssSno < 300)
|
||||
|| (logPssSno > 300 && logPssSno < 400) ) {
|
||||
if( (logPssSno % 2) == 1) {
|
||||
logPssSno = 200;
|
||||
}
|
||||
else {
|
||||
logPssSno = 300;
|
||||
}
|
||||
}
|
||||
|
||||
// 업무테이터 처리
|
||||
// 1. Get Source, Target Adapter Group Name
|
||||
String srcAdapterGroupName = message.getSngSysItfTp();
|
||||
String tgtAdapterGroupName = message.getCurrentSvcMsg().getPsvSysItfTp();
|
||||
|
||||
// 2. Get Source, Target Adapter GroupVO
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO srcAdapterGrpVO = adapterManager.getAdapterGroupVO(srcAdapterGroupName);
|
||||
AdapterGroupVO tgtAdapterGrpVO = adapterManager.getAdapterGroupVO(tgtAdapterGroupName);
|
||||
|
||||
// 3. Get Source, Target Adapter Message Type
|
||||
/*
|
||||
String srcAdapterMsgType = srcAdapterGrpVO.getMessageType();
|
||||
String tgtAdapterMsgType = tgtAdapterGrpVO != null ? tgtAdapterGrpVO.getMessageType() : "N/A";
|
||||
*/
|
||||
String srcAdapterMsgType = null;
|
||||
String tgtAdapterMsgType = null;
|
||||
//String srcAdptrMsgPtrnCd = null;
|
||||
String tgtAdptrMsgPtrnCd = null;
|
||||
|
||||
String srcAdapterMsgEncode = null;
|
||||
String tgtAdapterMsgEncode = null;
|
||||
|
||||
// String s = System.getProperty("os.name");
|
||||
// if (s.indexOf("Window") < 0){
|
||||
|
||||
// srcAdptrMsgPtrnCd = srcAdapterGrpVO.getAdptrMsgPtrnCd();
|
||||
if (srcAdapterGrpVO == null){
|
||||
srcAdapterMsgType = MessageType.ASC;
|
||||
srcAdapterMsgEncode = Charset.defaultCharset().name();
|
||||
if (logger.isWarn()){
|
||||
logger.warn("EAIFileLogger] Source Adapter null. eai service code="+message.getEAISvcCd());
|
||||
}
|
||||
}
|
||||
else {
|
||||
srcAdapterMsgType = srcAdapterGrpVO.getMessageType();
|
||||
srcAdapterMsgEncode = StringUtils.defaultIfBlank(srcAdapterGrpVO.getMessageEncode(), Charset.defaultCharset().name());
|
||||
}
|
||||
if (tgtAdapterGrpVO == null){
|
||||
tgtAdapterMsgType = MessageType.ASC;
|
||||
tgtAdapterMsgEncode = Charset.defaultCharset().name();
|
||||
if (logger.isWarn()){
|
||||
logger.warn("EAIFileLogger] Target Adapter null. eai service code="+message.getEAISvcCd());
|
||||
}
|
||||
}
|
||||
else{
|
||||
tgtAdapterMsgType = tgtAdapterGrpVO.getMessageType();
|
||||
tgtAdptrMsgPtrnCd = tgtAdapterGrpVO.getAdptrMsgPtrnCd();
|
||||
tgtAdapterMsgEncode = StringUtils.defaultIfBlank(tgtAdapterGrpVO.getMessageEncode(), Charset.defaultCharset().name());
|
||||
}
|
||||
// }else{
|
||||
// srcAdapterMsgType = MessageType.ASC;
|
||||
// tgtAdapterMsgType = MessageType.ASC;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
String bwkData = "";
|
||||
String addBwkData = "";
|
||||
String refMsgID = "";
|
||||
|
||||
if(loggingBizData) {
|
||||
//---------------------------------------------------
|
||||
// LogMasking 을 위해 변환이 등록된 경우에만
|
||||
// 변환을 통해 처리하도록 수정 : 20080827 DHLEE
|
||||
//---------------------------------------------------
|
||||
boolean isMasked = false;
|
||||
boolean isMasking = false;
|
||||
|
||||
// 변환이 등록된 경우
|
||||
if ("1".equals(svcMsg.getCnvEn())) {
|
||||
TransformManager manager = TransformManager.getManager();
|
||||
Transform info = null;
|
||||
Layout l = null;
|
||||
|
||||
// AA - 요청변환에서
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)) {
|
||||
info = manager.getTransform(svcMsg.getCnvMsgID()); //요청변환메시지ID명
|
||||
}
|
||||
// AA이 아닌 경우
|
||||
// - 100, 200 요청변환에서
|
||||
// - 300, 400 응답변환에서
|
||||
else {
|
||||
if (logPssSno == 100 || logPssSno == 200) {
|
||||
info = manager.getTransform(svcMsg.getCnvMsgID()); //요청변환메시지ID명
|
||||
} else {
|
||||
if (rspErrCd.equals(EAIMessageKeys.BWK_ERRMSG_CODE)) { //업무에러(RIBEAI999999)
|
||||
info = manager.getTransform(svcMsg.getErrRspCnvMsgID()); //오류응답변환메시지ID명
|
||||
if(info == null) {
|
||||
info = manager.getTransform(svcMsg.getBsRspCnvMsgID()); //기본응답변환메시지ID명
|
||||
}
|
||||
} else if(MessageUtil.checkRspErrCd(rspErrCd)) {
|
||||
info = manager.getTransform(svcMsg.getBsRspCnvMsgID()); //기본응답변환메시지ID명
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 등록된 변환이 있는 경우
|
||||
if (info != null) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Masking Log Message - " + message.getEAISvcCd());
|
||||
|
||||
// 변환은 등록되어 있으나 레이아웃정보가 삭제된 경우
|
||||
// 정삭적인 Case 가 아님.
|
||||
try {
|
||||
if (logPssSno == 100 || logPssSno == 300 || logPssSno == 900)
|
||||
l = info.getSourceLayout(0);
|
||||
else
|
||||
l = info.getTargetLayout();
|
||||
}
|
||||
catch(Exception e) {
|
||||
if (logger.isInfo()) logger.info("getTargetLayout error" + e.getMessage());
|
||||
}
|
||||
|
||||
// Layout 에 Mask 필드가 없는 경우 SKIP 하도록 한다.
|
||||
if(l != null) {
|
||||
try {
|
||||
Item root = l.getRootItem();
|
||||
isMasking = root.existMask();
|
||||
}
|
||||
catch(Exception e) {
|
||||
if (logger.isWarn()) logger.info("EAIFileLogger] Check Masking field Error - " + e.getMessage());
|
||||
isMasking = false;
|
||||
}
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message has Masking field [" + l.getName() + "][ " + isMasking+"]");
|
||||
}
|
||||
|
||||
if(isMasking) {
|
||||
try {
|
||||
bizMsgStr = LogMessageUtil.makeMaskData(message, bizMsg, l, logPssSno,tgtAdptrMsgPtrnCd
|
||||
, svcTsmtUsgTp, psvItfTp );
|
||||
isMasked = true;
|
||||
} catch(Exception e) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] LogMasking Error - " + e.getMessage());
|
||||
isMasked = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("EAIFileLogger] Masking is unnecessary - Skip Masking ");
|
||||
}
|
||||
isMasked = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (logger.isInfo()) {
|
||||
logger.info("EAIFileLogger] Transform Not Found - Masking Unable");
|
||||
}
|
||||
isMasked = false;
|
||||
}
|
||||
// Masking check END
|
||||
}
|
||||
|
||||
// boolean isUtf8 = isUTF8(svcTsmtUsgTp, psvItfTp, logPssSno, srcAdapterMsgType, tgtAdapterMsgType);
|
||||
boolean isUtf8 = isUTF8(svcTsmtUsgTp, psvItfTp, logPssSno, srcAdapterMsgEncode, tgtAdapterMsgEncode);
|
||||
// 요청 변환이 등록되지 않은 경우 또는 Masking 처리를 실패한 경우
|
||||
if(!isMasked) {
|
||||
if (bizMsg == null) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is NULL");
|
||||
bizMsgStr = "";
|
||||
} else if (bizMsg instanceof String) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is String Type");
|
||||
bizMsgStr = (String)bizMsg;
|
||||
} else if (bizMsg instanceof byte[]) {
|
||||
if(isEBC(svcTsmtUsgTp, psvItfTp, logPssSno, srcAdapterMsgType, tgtAdapterMsgType)) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is EBCDIC bytes Type");
|
||||
try {
|
||||
bizMsgStr = IConv.ebcdicToASCIIWithSOSIEX( (byte[])bizMsg );
|
||||
} catch(Exception ex) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] 타입변환오류 - " + ex.getMessage());
|
||||
bizMsgStr = new String((byte[])bizMsg);
|
||||
}
|
||||
}
|
||||
else if(isUtf8) {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is ASCII-UTF8 bytes Type");
|
||||
bizMsgStr = new String((byte[])bizMsg, StandardCharsets.UTF_8);
|
||||
|
||||
}
|
||||
else {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is ASCII bytes Type");
|
||||
bizMsgStr = new String((byte[])bizMsg);
|
||||
// bizMsgStr = new String((byte[])bizMsg,JSONMessage.encode);
|
||||
}
|
||||
} else {
|
||||
if (logger.isInfo()) logger.info("EAIFileLogger] Message is Object or UNKNOWN Type");
|
||||
try {
|
||||
StringBuilder sbuff = new StringBuilder();
|
||||
bizMsgStr = sbuff.append(PropertyUtils.describe(bizMsg)).toString();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarn()) logger.warn("EAIFileLogger] Object Message Parsing Error - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
// EAI 업무 개별부(32,000bytes)
|
||||
/**
|
||||
* 업무데이터에 대한정의
|
||||
* 1. biz 데이터
|
||||
* 2. 표준전문 JSON 데이터
|
||||
* 3. 전장표
|
||||
*/
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String biz ="";
|
||||
// String header = ExtMessageConverter.getSTDLog(message.getExtMsg());
|
||||
String header = message.getStandardMessage().toFixedString(false);
|
||||
//20220405
|
||||
// String header = "";
|
||||
// if (logPssSno ==100 || logPssSno ==300){
|
||||
// header = ExtMessageConverter.getOriginalSTDLog(message.getExtMsg());
|
||||
// }else{
|
||||
// header = ExtMessageConverter.getSettingSTDLog(message.getExtMsg());
|
||||
// }
|
||||
String mdclData ="";
|
||||
if (bizMsgStr == null) {
|
||||
bizMsgStr = "";
|
||||
}
|
||||
|
||||
//전장표 데이터부 JSON Array로 저장
|
||||
//암호화
|
||||
Charset hexaCharset = Charset.forName("euc-kr");
|
||||
if("Y".equalsIgnoreCase(EncryptionManager.getInstance().getEncryptYN()) ){
|
||||
try{
|
||||
biz = HexaConverter.bytesToHexa(bizMsgStr.getBytes(hexaCharset));
|
||||
}catch(Exception e){
|
||||
logger.error("EAIFileLogger] bizMsgStr encryption Error - " + e.getMessage());
|
||||
}
|
||||
try{
|
||||
header = HexaConverter.bytesToHexa(header.getBytes(hexaCharset));
|
||||
}catch(Exception e){
|
||||
logger.error("EAIFileLogger] header encryption Error - " + e.getMessage());
|
||||
}
|
||||
try{
|
||||
mdclData = HexaConverter.bytesToHexa(mdclData.getBytes(hexaCharset));
|
||||
}catch(Exception e){
|
||||
logger.error("EAIFileLogger] mdclData encryption Error - " + e.getMessage());
|
||||
}
|
||||
|
||||
}else {
|
||||
biz = bizMsgStr;
|
||||
}
|
||||
|
||||
//임시코드 시작
|
||||
String logType = PropManager.getInstance().getProperty("BIZ_LOG_TYPE");
|
||||
if (!StringUtils.isBlank(logType)){
|
||||
if ("ALL".equals(logType)){
|
||||
sb.append(header).append("|").append(biz).append("|").append(mdclData);
|
||||
}else if ("HEADER".equals(logType)){
|
||||
sb.append(header).append("|").append("|");
|
||||
}else if ("BODY".equals(logType)){
|
||||
sb.append("|").append(biz).append("|");
|
||||
}else if ("NONE".equals(logType)){
|
||||
sb.append("|").append("|");
|
||||
}
|
||||
}else{
|
||||
sb.append(header).append("|").append(biz).append("|").append(mdclData);
|
||||
}
|
||||
|
||||
//임시코드 종료
|
||||
|
||||
// File은 전체전문을 남기도록 한다.
|
||||
String tmpStr = sb.toString();
|
||||
bwkData = tmpStr.length() > 4000 ? StringUtils.substring(tmpStr, 0, 4000) : tmpStr;
|
||||
addBwkData = tmpStr.length() > 4000 ? StringUtils.substring(tmpStr, 4000) : "";
|
||||
|
||||
// 업무데이터 사이즈가 4000byte 이상이면 추가업무데이터 테이블에 insert
|
||||
if (!"".equals(addBwkData))
|
||||
apndBwkDataYn = "Y";
|
||||
|
||||
String[] refMsgIDs = svcMsg.getRefMsgIDs();
|
||||
|
||||
// 입력메시지IDS 배열은 delimiter로 구분하여 200byte 만 insert
|
||||
StringBuilder sbMsgIds = new StringBuilder();
|
||||
if (refMsgIDs != null && refMsgIDs.length > 0) {
|
||||
for (int i = 0; i < refMsgIDs.length - 1; i++) {
|
||||
sbMsgIds.append(refMsgIDs[i]).append(", ");
|
||||
}
|
||||
sbMsgIds.append(refMsgIDs[refMsgIDs.length - 1]);
|
||||
refMsgID = sbMsgIds.toString();
|
||||
|
||||
if (refMsgID.getBytes().length > 200) {
|
||||
refMsgID = StringUtil.chunkString(refMsgID, 200);
|
||||
}
|
||||
}
|
||||
} // 업무데이터 로깅을 할 경우에만 END loggingBizData
|
||||
|
||||
// ExtMessage extMessage = message.getExtMsg();
|
||||
|
||||
// 메시지수신시각으로 테이블명 설정
|
||||
// int dayOfWeek = DatetimeUtil.getDayOfWeekNum(message.getMsgRcvTm());
|
||||
|
||||
|
||||
try {
|
||||
// 1/1000초로 변경
|
||||
//String msgPssTm = DatetimeUtil.getTimeCenti(message.getMsgPssTm());
|
||||
String msgPssTm = DatetimeUtil.getCurrentTime(message.getMsgPssTm());
|
||||
|
||||
CustomStringBuffer sb = new CustomStringBuffer(DELIMITER);
|
||||
|
||||
String serverName = EAIServerManager.getInstance().getLocalServerName();
|
||||
String serverGroupName = EAIServerManager.getInstance().getServerType();
|
||||
|
||||
// EAI 업무 공통부(100 bytes)
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getBwkCls())); //EAI업무구분코드
|
||||
sb.appendAndDelimeter( DatetimeUtil.getCurrentTime(message.getMsgRcvTm())); //메시지수신시각
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSvcOgNo())); //EAI서비스일련번호
|
||||
|
||||
// 2009.07.13 공동망 통신망관련 수정 - 로그 저장시 원 로그처리일련번호를 저장
|
||||
// sb.appendAndDelimeter(4, String.valueOf(logPssSno)); //로그처리일련번호
|
||||
sb.appendAndDelimeter( String.valueOf(orglogPssSno)); //로그처리일련번호
|
||||
|
||||
// sb.appendAndDelimeter(5, NullControl.addSpace(message.getEAISvrInstNm())); //EAI서버인스탄스명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(serverName)); //EAI서버인스탄스명
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getEAISvcCd())); //EAI서비스명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSvcTmEn())); //서비스시각유무
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSvcTsmtUsgTp())); //서비스동기사용구분코드
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSvcPssTp())); //서비스처리구분명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getFlwCntlRtnNm())); //흐름통제라우팅명
|
||||
//index 10
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getUnifTp())); //통합구분명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSngSvcCls())); //기동서비스구분명
|
||||
sb.appendAndDelimeter( String.valueOf(message.getSvcPssSeq())); //서비스처리번호
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSvcWlColLogYn())); //서비스전컬럼로그여부
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getStdMsgUsgCls())); //표준메시지사용여부
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getSngSysItfTp())); //기동시스템어댑터업무그룹명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getLydMsgID())); //현재메시지ID명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRspErrCd())); //응답에러코드명
|
||||
sb.appendAndDelimeter( msgPssTm); //메시지처리시각
|
||||
sb.appendAndDelimeter( String.valueOf(message.getSvrLogLvl())); //서버로그레벨번호
|
||||
//index 20
|
||||
|
||||
sb.appendAndDelimeter( String.valueOf(message.getSvcLogLvl())); //서비스로그레벨번호
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getErrEAISvcName())); //오류EAI서비스명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getDmndErrChngIDName())); //요청오류변환ID명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getDmndErrFldName())); //요청에러필드명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRspnsErrChngIDName())); //응답오류변환ID명
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRspnsErrFldName())); //응답에러필드명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getPsvItfTp())); //수동인터페이스구분명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getPsvBwkSysNm())); //수동업무시스템명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getPsvSysID())); //수동시스템ID명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getPsvSysSvcCd())); //수동시스템서비스구분명
|
||||
//index 30
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getPsvSysItfTp())); //수동시스템어댑터업무그룹명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getFlOvrCls())); //장애극복여부
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getCnvEn())); //변환여부
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getCnvMsgID())); //변환메시지ID명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(refMsgID)); //입력메시지ID명
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getBsRspMsgCprVl())); //기본응답메시지비교내용
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getBsRspCnvEn())); //기본응답변환여부
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getBsRspCnvMsgID())); //기본응답변환메시지ID명
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getErrRspMsgCprVl())); //오류응답메시지비교내용
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getErrRspCnvEn())); //오류응답변환여부
|
||||
//index 40
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getErrRspCnvMsgID())); //오류응답변환메시지ID명
|
||||
sb.appendAndDelimeter( String.valueOf(svcMsg.getNxtSvcPssSeq())); //다음서비스처리번호
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getOutbRtnNm())); //아웃바운드라우팅명
|
||||
sb.appendAndDelimeter(svcMsg.getTmoVl()); //타임아웃값
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getCpnsSvcPssCd())); //보상서비스처리명
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(apndBwkDataYn)); //추가업무데이터여부
|
||||
sb.appendAndDelimeter( NullControl.addSpace(svcMsg.getKeyMgtMsgVl())); //키관리메시지내용
|
||||
|
||||
|
||||
// SS,SA - Send - 100
|
||||
// AA - Send - 100
|
||||
// AA - Recv - 100, 300
|
||||
// AS - 100
|
||||
// String telgmDmndDstcd = kbheader.getTelgmDmndDstcd();
|
||||
// String telgmDmndDstcd = message.getExtMsg().getSendRecv();
|
||||
String telgmDmndDstcd = message.getMapper().getSendRecvDivision(message.getStandardMessage()); // S|R
|
||||
if (prop != null &&
|
||||
((EAIMessageKeys.SYNC_SVC.equals(svcTsmtUsgTp)
|
||||
&& logPssSno == 100)
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp)
|
||||
&& EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)
|
||||
&& STDMessageKeys.SEND_RECV_CD_RECV.equals(telgmDmndDstcd)
|
||||
&& (logPssSno == 100 || logPssSno == 300))
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp)
|
||||
&& EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)
|
||||
&& STDMessageKeys.SEND_RECV_CD_SEND.equals(telgmDmndDstcd)
|
||||
&& logPssSno == 100)
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp)
|
||||
&& EAIMessageKeys.SYNC_SVC.equals(psvItfTp)
|
||||
&& logPssSno == 100))) {
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(prop.getProperty(Keys.LOG_ALT_KEY1))); //추적보조키1내용
|
||||
sb.appendAndDelimeter( NullControl.addSpace(prop.getProperty(Keys.LOG_ALT_KEY2))); //추적보조키2내용
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(prop.getProperty(Keys.LOG_ALT_KEY3))); //추적보조키3내용
|
||||
sb.appendAndDelimeter( NullControl.addSpace(prop.getProperty(Keys.LOG_ALT_KEY4))); //추적보조키4내용
|
||||
} else {
|
||||
sb.appendAndDelimeter( " "); //추적보조키1내용
|
||||
sb.appendAndDelimeter( " "); //추적보조키2내용
|
||||
sb.appendAndDelimeter( " "); //추적보조키3내용
|
||||
sb.appendAndDelimeter( " "); //추적보조키4내용
|
||||
}
|
||||
//index 51
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getGroupCoCd())); //EAI서비스코드의 그룹회사코드
|
||||
|
||||
// sb.appendAndDelimeter( kbheader.getGuIdNo().substring(0,33)); // PGUID
|
||||
// sb.appendAndDelimeter( extMessage.getGuid()); // PGUID
|
||||
sb.appendAndDelimeter( message.getMapper().getGuid(message.getStandardMessage())); // PGUID
|
||||
|
||||
sb.appendAndDelimeter( message.getTranType()); // 거래처리구분
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRspnsChngMsgType())); // 응답변환유형
|
||||
|
||||
// log level 'E' or 'F'
|
||||
if ("E".equals(message.getRspErrCd().substring(1, 2)) || "F".equals(message.getRspErrCd().substring(1, 2))) {
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRspErrCd())); //EAI에러코드
|
||||
sb.appendAndDelimeter( StringUtil.chunkString(message.getRspErrMsg(),1000)); //EAI에러내용
|
||||
}
|
||||
else {
|
||||
sb.appendAndDelimeter( " "); //EAI에러코드
|
||||
sb.appendAndDelimeter( " "); //EAI에러내용
|
||||
}
|
||||
|
||||
//juns 서버명 변경에 따른 인스턴스 룰 추출변경
|
||||
//ex)EAIDSG_i11 => EAIDS01_i01
|
||||
//sb.appendAndDelimeter( serverName.substring(3, 6)); //서버그룹명
|
||||
sb.appendAndDelimeter( serverGroupName); //서버그룹명
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getCompanyCode()) ); //업체코드, add 20190625
|
||||
sb.appendAndDelimeter( message.getSplizLength()); //전문크기, add 20190625
|
||||
//index 60
|
||||
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getAdptrInstiCode())); // add 20190404 // adapterNickName
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getTxId()));// add 20210331 //TODO 거래ID
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getRefKey()));// add 20210331 //TODO 참조ID
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getExtBizCd()));// add 20210402 //TODO 대외업무구분코드
|
||||
// EAI 업무 개별부(32,000bytes)
|
||||
// 전체업무데이터를 HEXA String 으로 변경해서 저장한다. (newline 등의 문제로)
|
||||
// Read시에는 HexaConverter.hexaToBytes 를 사용
|
||||
// String hexaData = HexaConverter.bytesToHexa(bizMsgStr.getBytes());
|
||||
// sb.appendAndDelimeter(hexaData);
|
||||
// 에러메시지에도 newline이 있을 수 있으므로 다른 방안으로 처리 (2019.06.25)
|
||||
// - EOL 라인을 추가한다.
|
||||
if(bwkData == null || bwkData.equals(""))
|
||||
bwkData = " ";
|
||||
sb.appendAndDelimeter(bwkData);
|
||||
|
||||
String standardLayoutName = System.getProperty("STANDARD_LAYOUT_NAME");
|
||||
sb.appendAndDelimeter( NullControl.addSpace(standardLayoutName));
|
||||
sb.appendAndDelimeter( NullControl.addSpace(message.getClientId()));
|
||||
|
||||
// DATA에 NewLine이 있을 경우가 있으므로
|
||||
// 데이터 라인 마지막에 추가하여 Loading 시에 EOL로 시작하는 라인이 올때까지 읽도록 처리해야 함.
|
||||
// 데이터룰 HEXA로 저장하므로 필요없음
|
||||
sb.append("\n"+EOL);
|
||||
|
||||
// tranLogger.info(sb.toString());
|
||||
// 2025.04.10 tran.log 생성 로그 레벨 변경 info -> error
|
||||
tranLogger.error(sb.toString());
|
||||
|
||||
// String sLogDirectory = PropManager.getInstance().getProperty(LogKeys.LOGGER_INFO, LogKeys.LOG_DIRECOTRY_PREFIX);
|
||||
// String localServer = EAIServerManager.getInstance().getLocalServerName();
|
||||
// String type = "TSEAILG1" + dayOfWeek;
|
||||
// String serialNo = message.getSvcOgNo();
|
||||
// String logSeq = String.valueOf(message.getSvcPssSeq());
|
||||
// String logPath = sLogDirectory + localServer + File.separator + type + File.separator + serialNo+ File.separator;
|
||||
//
|
||||
// FileWrite(logPath, logSeq, sb.toString());
|
||||
|
||||
if ("Y".equals(apndBwkDataYn)) {
|
||||
addBwkDataSub(message, addBwkData, dayOfWeek); // 업무데이터서브
|
||||
}
|
||||
} catch(Exception e) {
|
||||
// logger.error("File Logging[MASTER] Failed - " + message.getEAISvcCd() + "|" + orglogPssSno
|
||||
// + "|" + message.getSvcOgNo() + "|" + kbheader.getGuIdNo());
|
||||
logger.error("File Logging[MASTER] Failed - " + message.getEAISvcCd() + "|" + orglogPssSno
|
||||
+ "|" + message.getSvcOgNo() + "|" + message.getMapper().getGuid(message.getStandardMessage()));
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG001"));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 1. 기능 : 업무데이터 서브 로그 셋팅
|
||||
* 2. 처리 개요 :info[3]
|
||||
* - TSEAILG03(EAI로그업무데이터서브정보) 로그값 셋팅
|
||||
* - 매 4000byte 마다 row 증가
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message EAIMessage
|
||||
* @param subBizMsgStr 추가 업무 데이터
|
||||
* @exception DAOException
|
||||
**/
|
||||
public void addBwkDataSub(EAIMessage message, String subBizMsgStr, int dayOfWeek) {
|
||||
|
||||
try {
|
||||
String sLogDirectory = PropManager.getInstance().getProperty(LogKeys.LOGGER_INFO, LogKeys.LOG_DIRECOTRY_PREFIX);
|
||||
String localServer = EAIServerManager.getInstance().getLocalServerName();
|
||||
String type = "TSEAILG2" + dayOfWeek;
|
||||
String serialNo = message.getSvcOgNo();
|
||||
String logSeq = String.valueOf(message.getLogPssSno());
|
||||
String logPath = sLogDirectory + localServer + File.separator + type + File.separator + serialNo + File.separator;
|
||||
|
||||
FileWrite(logPath, logSeq, subBizMsgStr);
|
||||
}catch(Exception e) {
|
||||
logger.error("Log Sub Data write error.",e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 모니터링을 위한 별도의 에러로그테이블에 에러정보를 저정
|
||||
* 2. 처리 개요 :
|
||||
* - TSEAILG03(EAI로그업무데이터서브정보) 로그값 셋팅
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param message EAIMessage
|
||||
* @exception DAOException
|
||||
**/
|
||||
public void addErrorLog(EAIMessage message, int dayOfWeek) {
|
||||
|
||||
try {
|
||||
CustomStringBuffer sb = new CustomStringBuffer();
|
||||
String serverName = EAIServerManager.getInstance().getLocalServerName();
|
||||
|
||||
sb.appendAndDelimeter(message.getBwkCls()); //EAI업무구분코드
|
||||
sb.appendAndDelimeter(DatetimeUtil.getCurrentTime(message.getMsgRcvTm())); //메시지수신시각
|
||||
sb.appendAndDelimeter(message.getSvcOgNo()); //EAI거래일련번호
|
||||
sb.appendAndDelimeter(String.valueOf(message.getLogPssSno())); //로그처리일련번호
|
||||
|
||||
sb.appendAndDelimeter(message.getEAISvcCd()); //EAI서비스명
|
||||
sb.appendAndDelimeter(message.getRspErrCd()); //응답에러코드명
|
||||
|
||||
sb.appendAndDelimeter(message.getSngSysItfTp()); //기동시스템어댑터업무그룹명
|
||||
sb.appendAndDelimeter(message.getCurrentSvcMsg().getPsvSysItfTp()); //수동시스템어댑터업무그룹명
|
||||
|
||||
if ("E".equals(message.getRspErrCd().substring(1, 2)) || "F".equals(message.getRspErrCd().substring(1, 2))) {
|
||||
sb.appendAndDelimeter(NullControl.addSpace(message.getRspErrCd())); //EAI에러코드
|
||||
sb.appendAndDelimeter(StringUtil.chunkString(message.getRspErrMsg(),500)); //EAI에러내용
|
||||
}
|
||||
else {
|
||||
sb.appendAndDelimeter(" "); //EAI에러코드
|
||||
sb.appendAndDelimeter(" "); //EAI에러내용
|
||||
}
|
||||
|
||||
sb.appendAndDelimeter(NullControl.addSpace(serverName)); //EAI서버인스턴스명
|
||||
sb.appendAndDelimeter(NullControl.addSpace(EAIServerManager.getInstance().getEAIServer(serverName).getHostName())); //로깅시스템ID
|
||||
sb.appendAndDelimeter(DatetimeUtil.getCurrentTime(message.getMsgPssTm())); // 메시지처리일시
|
||||
|
||||
// TODO DB 필드매핑 2010.12.21
|
||||
sb.appendAndDelimeter(message.getGroupCoCd()); // EAI그룹회사코드
|
||||
|
||||
|
||||
String sLogDirectory = PropManager.getInstance().getProperty(LogKeys.LOGGER_INFO, LogKeys.LOG_DIRECOTRY_PREFIX);
|
||||
String localServer = EAIServerManager.getInstance().getLocalServerName();
|
||||
String type = "TSEAILG3" + dayOfWeek;
|
||||
String serialNo = message.getSvcOgNo();
|
||||
String logSeq = String.valueOf(message.getLogPssSno());
|
||||
String logPath = sLogDirectory + localServer + File.separator + type + File.separator + serialNo + File.separator;
|
||||
|
||||
FileWrite(logPath, logSeq, sb.toString());
|
||||
} catch(Exception e) {
|
||||
logger.error("Error Log Data write error.",e);
|
||||
}
|
||||
}
|
||||
|
||||
public void FileWrite(String path, String fileName, String data)throws Exception{
|
||||
File directory = new File(path);
|
||||
directory.setWritable(true,false);
|
||||
directory.setReadable(true,false);
|
||||
directory.setExecutable(true,true);
|
||||
if (!directory.exists()){
|
||||
if (!directory.mkdirs()){
|
||||
throw new Exception("디렉토리 생성 오류입니다."+path);
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(path+fileName);
|
||||
FileOutputStream os = null;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
os = new FileOutputStream(file);
|
||||
bos = new BufferedOutputStream(os);
|
||||
bos.write(data.getBytes());
|
||||
bos.flush();
|
||||
file.setWritable(true,false);
|
||||
file.setReadable(true,false);
|
||||
file.setExecutable(true,true);
|
||||
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug(data);
|
||||
}
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.error("file error", ex);
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
try { if(bos != null) bos.close(); } catch(Exception e) {}
|
||||
try { if(os != null) os.close(); } catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,843 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.eactive.eai.authserver.service.OAuth2Manager;
|
||||
import com.eactive.eai.authserver.vo.ClientVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
import com.eactive.eai.adapter.AdapterManager;
|
||||
import com.eactive.eai.agent.encryption.EncryptionManager;
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.logger.EAILogLogger;
|
||||
import com.eactive.eai.common.logger.StatAdapterLogLogger;
|
||||
import com.eactive.eai.common.logger.StatLogLogger;
|
||||
import com.eactive.eai.common.logger.StatTranLogLogger;
|
||||
import com.eactive.eai.common.logger.SubMessageLogLogger;
|
||||
import com.eactive.eai.common.logger.mapper.StatAdapterLogMapper;
|
||||
import com.eactive.eai.common.logger.mapper.StatLogMapper;
|
||||
import com.eactive.eai.common.logger.mapper.StatTranLogMapper;
|
||||
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.message.ServiceMessage;
|
||||
import com.eactive.eai.common.monitor.StatMonitorLogVO;
|
||||
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.loader.EAIServerLoader;
|
||||
import com.eactive.eai.common.util.DatetimeUtil;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.common.util.StringUtil;
|
||||
import com.eactive.eai.data.RollingTable;
|
||||
import com.eactive.eai.data.entity.onl.logger.EAIErrorLog;
|
||||
import com.eactive.eai.data.entity.onl.logger.EAIErrorLogId;
|
||||
import com.eactive.eai.data.entity.onl.logger.EAILog;
|
||||
import com.eactive.eai.data.entity.onl.logger.EAILogId;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatAdapterLog;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatLog;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatTranLog;
|
||||
import com.eactive.eai.data.entity.onl.logger.SubMessageLog;
|
||||
import com.eactive.eai.data.entity.onl.logger.SubMessageLogId;
|
||||
import com.eactive.eai.message.EncodingVar;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.transformer.layout.Item;
|
||||
import com.eactive.eai.transformer.layout.Layout;
|
||||
import com.eactive.eai.transformer.transform.Transform;
|
||||
import com.eactive.eai.transformer.transform.TransformManager;
|
||||
import com.eactive.eai.util.HexaConverter;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class EAILogDAO {
|
||||
//extends BaseDAO {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private EAILogLogger eaiLogEntityService;
|
||||
|
||||
@Autowired
|
||||
private SubMessageLogLogger subMessageLogLogger;
|
||||
|
||||
@Autowired
|
||||
private StatLogLogger statLogLogger;
|
||||
|
||||
@Autowired
|
||||
private StatTranLogLogger statTranLogLogger;
|
||||
|
||||
@Autowired
|
||||
private StatAdapterLogLogger statAdapterLogLogger;
|
||||
|
||||
@Autowired
|
||||
private StatLogMapper statLogMapper;
|
||||
|
||||
@Autowired
|
||||
private StatTranLogMapper statTranLogMapper;
|
||||
|
||||
@Autowired
|
||||
private StatAdapterLogMapper statAdapterLogMapper;
|
||||
|
||||
@Autowired
|
||||
private EAIServerLoader eaiServerEntityService;
|
||||
|
||||
public EAILogDAO() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 메시지의 Type이 EBCDIC인지 판단 2. 처리 개요 : - 로그시퀀스에 맞는 Adapter의 메시지 type을 비교 -
|
||||
* EBC인지 판별 3. 주의사항
|
||||
*
|
||||
* @param srcIfType String
|
||||
* @param tgtIfType String
|
||||
* @param logPssSno int
|
||||
* @param srcAdapterMsgType String
|
||||
* @param tgtAdapterMsgType String
|
||||
* @return boolean
|
||||
**/
|
||||
public boolean isEBC(String srcIfType, String tgtIfType, int logPssSno, String srcAdapterMsgType,
|
||||
String tgtAdapterMsgType) {
|
||||
|
||||
boolean isEBCDIC = false;
|
||||
|
||||
// SS. SA Type
|
||||
if (logPssSno == 100) {
|
||||
if (MessageType.EBC.equals(srcAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
} else if (logPssSno == 200) {
|
||||
if (MessageType.EBC.equals(tgtAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
} else if (logPssSno == 300) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if (MessageType.EBC.equals(srcAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
} else {
|
||||
if (MessageType.EBC.equals(tgtAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 400
|
||||
else if (logPssSno == 400) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if (MessageType.EBC.equals(tgtAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
} else {
|
||||
if (MessageType.EBC.equals(srcAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 900
|
||||
else {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
if (MessageType.EBC.equals(tgtAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
} else {
|
||||
if (MessageType.EBC.equals(srcAdapterMsgType)) {
|
||||
isEBCDIC = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isEBCDIC;
|
||||
}
|
||||
|
||||
public boolean isUTF8(String srcIfType, String tgtIfType, int logPssSno, String srcAdapterMsgEncode,
|
||||
String tgtAdapterMsgEncode) {
|
||||
boolean isUTF = false;
|
||||
if (logger.isInfo()) {
|
||||
logger.info(String.format("EAILogDAO] isUTF8 %s %s %s %s %s", srcIfType, tgtIfType, logPssSno,
|
||||
srcAdapterMsgEncode, tgtAdapterMsgEncode));
|
||||
}
|
||||
|
||||
String adapterMsgEncode = "";
|
||||
// SS. SA Type
|
||||
if (logPssSno == 100) {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
} else if (logPssSno == 200) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
} else if (logPssSno == 300) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
} else {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
// 400
|
||||
else if (logPssSno == 400) {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
} else {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
// 900
|
||||
else {
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(srcIfType) && EAIMessageKeys.ASYNC_SVC.equals(tgtIfType)) {
|
||||
adapterMsgEncode = tgtAdapterMsgEncode;
|
||||
} else {
|
||||
adapterMsgEncode = srcAdapterMsgEncode;
|
||||
}
|
||||
}
|
||||
isUTF = StringUtils.equalsIgnoreCase(adapterMsgEncode, "UTF-8");
|
||||
return isUTF;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI 서비스 로그 셋팅 2. 처리 개요 : - TSEAILG01(EAI서비스로그) 로그값 셋팅 -
|
||||
* TSEAILG03(EAI로그업무데이터서브정보) insert 여부 결정 3. 주의사항
|
||||
*
|
||||
* @param message EAIMessage
|
||||
* @exception DAOException
|
||||
**/
|
||||
public void addEAISvcLog(EAIMessage message, Properties prop) throws Exception {
|
||||
String apndBwkDataYn = "N"; // 추가업무데이터 여부
|
||||
|
||||
// 개별메시지
|
||||
String bizMsg = message.getStandardMessage().getBizData();
|
||||
|
||||
ServiceMessage svcMsg = message.getCurrentSvcMsg();
|
||||
String bizMsgStr = "";
|
||||
|
||||
// transformer 적용
|
||||
String svcTsmtUsgTp = message.getSvcTsmtUsgTp(); // 기동 Syunc/Async
|
||||
String psvItfTp = svcMsg.getPsvItfTp(); // 수동 Syunc/Async
|
||||
int logPssSno = message.getLogPssSno();
|
||||
String rspErrCd = message.getRspErrCd();
|
||||
|
||||
// Duplication Error 방지를 위해
|
||||
// 원 로그처리일련번호를 저장 : 2009.07.13
|
||||
int orglogPssSno = logPssSno;
|
||||
|
||||
int svcLogLvl = message.getSvcLogLvl();
|
||||
boolean loggingBizData = true;
|
||||
|
||||
// 특정거래에 대해 업무데이터를 저외함.
|
||||
if (svcLogLvl > 3) {
|
||||
loggingBizData = false;
|
||||
}
|
||||
if (logger.isWarn())
|
||||
logger.warn("EAILogDAO] loggingBizData - " + loggingBizData);
|
||||
|
||||
// 복합거래인 경우 2X1,3X1 -> 200, 2X2,3X2 -> 300 처럼 처리한다.
|
||||
if ((logPssSno > 200 && logPssSno < 300) || (logPssSno > 300 && logPssSno < 400)) {
|
||||
if ((logPssSno % 2) == 1) {
|
||||
logPssSno = 200;
|
||||
} else {
|
||||
logPssSno = 300;
|
||||
}
|
||||
}
|
||||
|
||||
// 업무테이터 처리
|
||||
// 1. Get Source, Target Adapter Group Name
|
||||
String srcAdapterGroupName = message.getSngSysItfTp();
|
||||
String tgtAdapterGroupName = message.getCurrentSvcMsg().getPsvSysItfTp();
|
||||
|
||||
// 2. Get Source, Target Adapter GroupVO
|
||||
AdapterManager adapterManager = AdapterManager.getInstance();
|
||||
AdapterGroupVO srcAdapterGrpVO = adapterManager.getAdapterGroupVO(srcAdapterGroupName);
|
||||
AdapterGroupVO tgtAdapterGrpVO = adapterManager.getAdapterGroupVO(tgtAdapterGroupName);
|
||||
|
||||
// 3. Get Source, Target Adapter Message Type
|
||||
String srcAdapterMsgType = null;
|
||||
String srcAdptrMsgPtrnCd = null;
|
||||
String tgtAdapterMsgType = null;
|
||||
String tgtAdptrMsgPtrnCd = null;
|
||||
|
||||
String srcAdapterMsgEncode = null;
|
||||
String tgtAdapterMsgEncode = null;
|
||||
|
||||
if (srcAdapterGrpVO == null) {
|
||||
srcAdapterMsgType = MessageType.ASC;
|
||||
srcAdapterMsgEncode = Charset.defaultCharset().name();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("EAILogDAO] Source Adapter null. eai service code=" + message.getEAISvcCd());
|
||||
}
|
||||
} else {
|
||||
srcAdapterMsgType = srcAdapterGrpVO.getMessageType();
|
||||
srcAdptrMsgPtrnCd = srcAdapterGrpVO.getAdptrMsgPtrnCd();
|
||||
srcAdapterMsgEncode = StringUtils.defaultIfBlank(srcAdapterGrpVO.getMessageEncode(),
|
||||
Charset.defaultCharset().name());
|
||||
}
|
||||
|
||||
if (tgtAdapterGrpVO == null) {
|
||||
tgtAdapterMsgType = MessageType.ASC;
|
||||
tgtAdapterMsgEncode = Charset.defaultCharset().name();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("EAILogDAO] Target Adapter null. eai service code=" + message.getEAISvcCd());
|
||||
}
|
||||
} else {
|
||||
tgtAdapterMsgType = tgtAdapterGrpVO.getMessageType();
|
||||
tgtAdptrMsgPtrnCd = tgtAdapterGrpVO.getAdptrMsgPtrnCd();
|
||||
tgtAdapterMsgEncode = StringUtils.defaultIfBlank(tgtAdapterGrpVO.getMessageEncode(),
|
||||
Charset.defaultCharset().name());
|
||||
}
|
||||
|
||||
// SUBSTANDARD Logging
|
||||
StandardMessage subMessage = message.getSubMessage();
|
||||
boolean isSubLogging = false;
|
||||
if(subMessage != null) {
|
||||
isSubLogging = checkSubLogging(svcTsmtUsgTp, psvItfTp, srcAdptrMsgPtrnCd, tgtAdptrMsgPtrnCd, logPssSno);
|
||||
if (logger.isDebug()) {
|
||||
logger.debug( String.format("EAILogDAO] SUBSTANDARD-LOGGING checkSubLogging %s-%s %s-%s %d => %s",
|
||||
svcTsmtUsgTp, psvItfTp, srcAdptrMsgPtrnCd, tgtAdptrMsgPtrnCd, logPssSno, isSubLogging) );
|
||||
}
|
||||
}
|
||||
if(isSubLogging) {
|
||||
String headerData = subMessage.toFixedString(false, EncodingVar.flatEncoding);
|
||||
if (logger.isDebug()) {
|
||||
logger.debug( String.format("EAILogDAO] SUBSTANDARD-LOGGING UUID: %s, LOGSEQ: %s, HEADER: %s",
|
||||
message.getSvcOgNo(), logPssSno, headerData) );
|
||||
}
|
||||
try {
|
||||
String layoutName = StandardMessageManager.getInstance().getVersionLayoutName();
|
||||
|
||||
SubMessageLog subMessageLog = (SubMessageLog) applicationContext.getBean(RollingTable.class, SubMessageLog.class,
|
||||
message.getMsgRcvTm());
|
||||
SubMessageLogId subLogId = new SubMessageLogId();
|
||||
subMessageLog.setId(subLogId);
|
||||
subLogId.setEaisvcserno(message.getSvcOgNo());
|
||||
subLogId.setLogprcssserno(String.valueOf(orglogPssSno));
|
||||
subMessageLog.setLayoutname(layoutName);
|
||||
subMessageLog.setHeaderdata(headerData);
|
||||
subMessageLogLogger.save(subMessageLog);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.error( String.format("EAILogDAO] SUBSTANDARD-LOGGING ERROR UUID: %s, LOGSEQ: %s, HEADER: %s",
|
||||
message.getSvcOgNo(), logPssSno, headerData), ex);
|
||||
}
|
||||
}
|
||||
|
||||
String bwkData = "";
|
||||
String addBwkData = "";
|
||||
String refMsgID = "";
|
||||
|
||||
if (loggingBizData) {
|
||||
// ---------------------------------------------------
|
||||
// LogMasking 을 위해 변환이 등록된 경우에만
|
||||
// 변환을 통해 처리하도록 수정
|
||||
// ---------------------------------------------------
|
||||
boolean isMasked = false;
|
||||
boolean isMasking = false;
|
||||
|
||||
// 변환이 등록된 경우
|
||||
if ("1".equals(svcMsg.getCnvEn())) {
|
||||
TransformManager manager = TransformManager.getManager();
|
||||
Transform info = null;
|
||||
Layout l = null;
|
||||
|
||||
// AA - 요청변환에서
|
||||
if (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)) {
|
||||
info = manager.getTransform(svcMsg.getCnvMsgID()); // 요청변환메시지ID명
|
||||
}
|
||||
// AA이 아닌 경우
|
||||
// - 100, 200 요청변환에서
|
||||
// - 300, 400 응답변환에서
|
||||
else {
|
||||
if (logPssSno == 100 || logPssSno == 200) {
|
||||
info = manager.getTransform(svcMsg.getCnvMsgID()); // 요청변환메시지ID명
|
||||
} else {
|
||||
if (rspErrCd.equals(EAIMessageKeys.BWK_ERRMSG_CODE)) { // 업무에러(RIBEAI999999)
|
||||
info = manager.getTransform(svcMsg.getErrRspCnvMsgID()); // 오류응답변환메시지ID명
|
||||
if (info == null) {
|
||||
info = manager.getTransform(svcMsg.getBsRspCnvMsgID()); // 기본응답변환메시지ID명
|
||||
}
|
||||
} else if (MessageUtil.checkRspErrCd(rspErrCd)) {
|
||||
info = manager.getTransform(svcMsg.getBsRspCnvMsgID()); // 기본응답변환메시지ID명
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 등록된 변환이 있는 경우
|
||||
if (info != null) {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Masking Log Message - " + message.getEAISvcCd());
|
||||
|
||||
// 변환은 등록되어 있으나 레이아웃정보가 삭제된 경우
|
||||
// 정삭적인 Case 가 아님.
|
||||
try {
|
||||
if (logPssSno == 100 || logPssSno == 300 || logPssSno == 900)
|
||||
l = info.getSourceLayout(0);
|
||||
else
|
||||
l = info.getTargetLayout();
|
||||
} catch (Exception e) {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Layout not set");
|
||||
}
|
||||
|
||||
// Layout 에 Mask 필드가 없는 경우 SKIP 하도록 한다.
|
||||
if (l != null) {
|
||||
try {
|
||||
Item root = l.getRootItem();
|
||||
isMasking = root.existMask();
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarn())
|
||||
logger.info("EAILogDAO] Check Masking field Error - " + e.getMessage());
|
||||
isMasking = false;
|
||||
}
|
||||
if (logger.isInfo())
|
||||
logger.info(
|
||||
"EAILogDAO] Message has Masking field [" + l.getName() + "][ " + isMasking + "]");
|
||||
}
|
||||
|
||||
if (isMasking) {
|
||||
try {
|
||||
bizMsgStr = LogMessageUtil.makeMaskData(message, bizMsg, l, logPssSno, tgtAdptrMsgPtrnCd,
|
||||
svcTsmtUsgTp, psvItfTp);
|
||||
isMasked = true;
|
||||
} catch (Exception e) {
|
||||
if (logger.isWarn())
|
||||
logger.warn("EAILogDAO] LogMasking Error - " + e.getMessage(), e);
|
||||
isMasked = false;
|
||||
}
|
||||
} else {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Masking is unnecessary - Skip Masking ");
|
||||
|
||||
isMasked = false;
|
||||
}
|
||||
} else {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Transform Not Found - Masking Unable");
|
||||
isMasked = false;
|
||||
}
|
||||
// Masking check END
|
||||
}
|
||||
|
||||
// boolean isUtf8 = isUTF8(svcTsmtUsgTp, psvItfTp, logPssSno, srcAdapterMsgEncode, tgtAdapterMsgEncode);
|
||||
// 요청 변환이 등록되지 않은 경우 또는 Masking 처리를 실패한 경우
|
||||
if (!isMasked) {
|
||||
if (bizMsg == null) {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Message is NULL");
|
||||
bizMsgStr = "";
|
||||
} else {
|
||||
if (logger.isInfo())
|
||||
logger.info("EAILogDAO] Message is String Type");
|
||||
bizMsgStr = bizMsg;
|
||||
}
|
||||
}
|
||||
|
||||
// EAI 업무 개별부(32,000bytes)
|
||||
/**
|
||||
* 업무데이터에 대한정의 1. biz 데이터 2. 표준전문 JSON 데이터 3. 전장표
|
||||
*/
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String biz = "";
|
||||
String header = message.getStandardMessage().toFixedString(false, EncodingVar.flatEncoding);
|
||||
|
||||
String mdclData = "";
|
||||
if (bizMsgStr == null) {
|
||||
bizMsgStr = "";
|
||||
}
|
||||
|
||||
// 암호화
|
||||
Charset hexaCharset = Charset.forName("euc-kr");
|
||||
if ("Y".equalsIgnoreCase(EncryptionManager.getInstance().getEncryptYN())) {
|
||||
try {
|
||||
biz = HexaConverter.bytesToHexa(bizMsgStr.getBytes(hexaCharset));
|
||||
} catch (Exception e) {
|
||||
logger.error("EAIFileLogger] bizMsgStr encryption Error - " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
header = HexaConverter.bytesToHexa(header.getBytes(hexaCharset));
|
||||
} catch (Exception e) {
|
||||
logger.error("EAIFileLogger] header encryption Error - " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
mdclData = HexaConverter.bytesToHexa(mdclData.getBytes(hexaCharset));
|
||||
} catch (Exception e) {
|
||||
logger.error("EAIFileLogger] mdclData encryption Error - " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
biz = bizMsgStr;
|
||||
}
|
||||
|
||||
// 임시코드 시작
|
||||
String logType = PropManager.getInstance().getProperty("BIZ_LOG_TYPE");
|
||||
if (!StringUtils.isBlank(logType)) {
|
||||
if ("ALL".equals(logType)) {
|
||||
sb.append(header).append("|").append(biz).append("|").append(mdclData);
|
||||
} else if ("HEADER".equals(logType)) {
|
||||
sb.append(header).append("|").append("|");
|
||||
} else if ("BODY".equals(logType)) {
|
||||
sb.append("|").append(biz).append("|");
|
||||
} else if ("NONE".equals(logType)) {
|
||||
sb.append("|").append("|");
|
||||
}
|
||||
} else {
|
||||
sb.append(header).append("|").append(biz).append("|").append(mdclData);
|
||||
}
|
||||
// 임시코드 종료
|
||||
|
||||
bwkData = sb.toString();
|
||||
|
||||
String[] refMsgIDs = svcMsg.getRefMsgIDs();
|
||||
|
||||
// 입력메시지IDS 배열은 delimiter로 구분하여 200byte 만 insert
|
||||
StringBuilder sbMsgIds = new StringBuilder();
|
||||
if (refMsgIDs != null && refMsgIDs.length > 0) {
|
||||
for (int i = 0; i < refMsgIDs.length - 1; i++) {
|
||||
sbMsgIds.append(refMsgIDs[i]).append(", ");
|
||||
}
|
||||
sbMsgIds.append(refMsgIDs[refMsgIDs.length - 1]);
|
||||
refMsgID = sbMsgIds.toString();
|
||||
|
||||
if (refMsgID.getBytes().length > 200) {
|
||||
refMsgID = StringUtil.chunkString(refMsgID, 200);
|
||||
}
|
||||
}
|
||||
} // 업무데이터 로깅을 할 경우에만 END loggingBizData
|
||||
|
||||
EAILog eaiLog = (EAILog) applicationContext.getBean(RollingTable.class, EAILog.class, message.getMsgRcvTm());
|
||||
|
||||
try {
|
||||
// 1/1000초로 변경
|
||||
String msgPssTm = DatetimeUtil.getCurrentTime(message.getMsgPssTm());
|
||||
|
||||
String serverName = EAIServerManager.getInstance().getLocalServerName();
|
||||
String serverGroupName = EAIServerManager.getInstance().getServerType();
|
||||
|
||||
// EAI 업무 공통부(100 bytes)
|
||||
EAILogId eaiLogId = new EAILogId();
|
||||
eaiLog.setId(eaiLogId);
|
||||
|
||||
// EAI업무구분코드
|
||||
eaiLogId.setEaibzwkdstcd(message.getBwkCls());
|
||||
// 메시지수신시각
|
||||
eaiLogId.setMsgdpstyms(DatetimeUtil.getCurrentTime(message.getMsgRcvTm()));
|
||||
// EAI서비스일련번호
|
||||
eaiLogId.setEaisvcserno(message.getSvcOgNo());
|
||||
// 로그처리일련번호
|
||||
eaiLogId.setLogprcssserno(String.valueOf(orglogPssSno));
|
||||
// EAI서버인스탄스명
|
||||
eaiLog.setEaisevrinstncname(serverName);
|
||||
|
||||
// EAI서비스명
|
||||
eaiLog.setEaisvcname(message.getEAISvcCd());
|
||||
// 서비스시각유무
|
||||
eaiLog.setSvchmseonot(message.getSvcTmEn());
|
||||
// 서비스동기사용구분코드
|
||||
eaiLog.setSvcmotivusedstcd(message.getSvcTsmtUsgTp());
|
||||
// 서비스처리구분명
|
||||
eaiLog.setSvcprcssdsticname(message.getSvcPssTp());
|
||||
// 흐름통제라우팅명
|
||||
eaiLog.setFlowctrlroutname(message.getFlwCntlRtnNm());
|
||||
|
||||
// 통합구분명
|
||||
eaiLog.setIntgradsticname(message.getUnifTp());
|
||||
// 기동서비스구분명
|
||||
eaiLog.setGstatsvcdsticname(message.getSngSvcCls());
|
||||
// 서비스처리번호
|
||||
eaiLog.setSvcprcssno(String.valueOf(message.getSvcPssSeq()));
|
||||
// 서비스전컬럼로그여부
|
||||
eaiLog.setSvcbfclmnlogyn(message.getSvcWlColLogYn());
|
||||
// 표준메시지사용여부
|
||||
eaiLog.setStndmsguseyn(message.getStdMsgUsgCls());
|
||||
|
||||
// 기동시스템어댑터업무그룹명
|
||||
eaiLog.setGstatsysadptrbzwkgroupname(message.getSngSysItfTp());
|
||||
// 현재메시지ID명
|
||||
eaiLog.setPrsntmsgidname(message.getLydMsgID());
|
||||
// 응답에러코드명
|
||||
eaiLog.setRspnserrcdname(message.getRspErrCd());
|
||||
// 메시지처리시각
|
||||
eaiLog.setMsgprcssyms(msgPssTm);
|
||||
// 서버로그레벨번호
|
||||
eaiLog.setSevrloglvelno(String.valueOf(message.getSvrLogLvl()));
|
||||
|
||||
// 서비스로그레벨번호
|
||||
eaiLog.setSvcloglvelno(String.valueOf(message.getSvcLogLvl()));
|
||||
// 오류EAI서비스명
|
||||
eaiLog.setErreaisvcname(message.getErrEAISvcName());
|
||||
// 요청오류변환ID명
|
||||
eaiLog.setDmnderrchngidname(message.getDmndErrChngIDName());
|
||||
// 요청에러필드명
|
||||
eaiLog.setDmnderrfldname(message.getDmndErrFldName());
|
||||
// 응답오류변환ID명
|
||||
eaiLog.setRspnserrchngidname(message.getRspnsErrChngIDName());
|
||||
|
||||
// 응답에러필드명
|
||||
eaiLog.setRspnserrfldname(message.getRspnsErrFldName());
|
||||
// 수동인터페이스구분명
|
||||
eaiLog.setPsvintfacdsticname(svcMsg.getPsvItfTp());
|
||||
// 수동업무시스템명
|
||||
eaiLog.setPsvbzwksysname(svcMsg.getPsvBwkSysNm());
|
||||
// 수동시스템ID명
|
||||
eaiLog.setPsvsysidname(svcMsg.getPsvSysID());
|
||||
// 수동시스템서비스구분명
|
||||
eaiLog.setPsvsyssvcdsticname(svcMsg.getPsvSysSvcCd());
|
||||
|
||||
// 수동시스템어댑터업무그룹명
|
||||
eaiLog.setPsvsysadptrbzwkgroupname(svcMsg.getPsvSysItfTp());
|
||||
// 장애극복여부
|
||||
eaiLog.setFlovryn(svcMsg.getFlOvrCls());
|
||||
// 변환여부
|
||||
eaiLog.setChngyn(svcMsg.getCnvEn());
|
||||
// 변환메시지ID명
|
||||
eaiLog.setChngmsgidname(svcMsg.getCnvMsgID());
|
||||
// 입력메시지ID명
|
||||
eaiLog.setInptmsgidname(refMsgID);
|
||||
|
||||
// 기본응답메시지비교내용
|
||||
eaiLog.setBascrspnsmsgcmprctnt(svcMsg.getBsRspMsgCprVl());
|
||||
// 기본응답변환여부
|
||||
eaiLog.setBascrspnschngyn(svcMsg.getBsRspCnvEn());
|
||||
// 기본응답변환메시지ID명
|
||||
eaiLog.setBascrspnschngmsgidname(svcMsg.getBsRspCnvMsgID());
|
||||
// 오류응답메시지비교내용
|
||||
eaiLog.setErrrspnsmsgcmprctnt(svcMsg.getErrRspMsgCprVl());
|
||||
// 오류응답변환여부
|
||||
eaiLog.setErrrspnschngyn(svcMsg.getErrRspCnvEn());
|
||||
|
||||
// 오류응답변환메시지ID명
|
||||
eaiLog.setErrrspnschngmsgidname(svcMsg.getErrRspCnvMsgID());
|
||||
// 다음서비스처리번호
|
||||
eaiLog.setNextsvcprcssno(String.valueOf(svcMsg.getNxtSvcPssSeq()));
|
||||
// 아웃바운드라우팅명
|
||||
eaiLog.setOutbndroutname(svcMsg.getOutbRtnNm());
|
||||
// 타임아웃값
|
||||
eaiLog.setToutval(svcMsg.getTmoVl());
|
||||
// 보상서비스처리명
|
||||
eaiLog.setCmpensvcprcssname(svcMsg.getCpnsSvcPssCd());
|
||||
// 추가업무데이터여부
|
||||
eaiLog.setSupplbzwkdatayn(apndBwkDataYn);
|
||||
// 키관리메시지내용
|
||||
eaiLog.setKeymgtmsgctnt(svcMsg.getKeyMgtMsgVl());
|
||||
|
||||
// SS,SA - Send - 100
|
||||
// AA - Send - 100
|
||||
// AA - Recv - 100, 300
|
||||
// AS - 100
|
||||
String telgmDmndDstcd = message.getMapper().getSendRecvDivision(message.getStandardMessage());
|
||||
if (prop != null && ((EAIMessageKeys.SYNC_SVC.equals(svcTsmtUsgTp) && logPssSno == 100)
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)
|
||||
&& STDMessageKeys.SEND_RECV_CD_RECV.equals(telgmDmndDstcd)
|
||||
&& (logPssSno == 100 || logPssSno == 300))
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp)
|
||||
&& STDMessageKeys.SEND_RECV_CD_SEND.equals(telgmDmndDstcd) && logPssSno == 100)
|
||||
|| (EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.SYNC_SVC.equals(psvItfTp)
|
||||
&& logPssSno == 100))) {
|
||||
eaiLog.setTrackasiskey1ctnt(prop.getProperty(com.eactive.eai.common.logger.Keys.LOG_ALT_KEY1)); // 추적보조키1내용
|
||||
eaiLog.setTrackasiskey2ctnt(prop.getProperty(com.eactive.eai.common.logger.Keys.LOG_ALT_KEY2)); // 추적보조키2내용
|
||||
eaiLog.setTrackasiskey3ctnt(prop.getProperty(com.eactive.eai.common.logger.Keys.LOG_ALT_KEY3)); // 추적보조키3내용
|
||||
eaiLog.setTrackasiskey4ctnt(prop.getProperty(com.eactive.eai.common.logger.Keys.LOG_ALT_KEY4)); // 추적보조키4내용
|
||||
}
|
||||
|
||||
// EAI서비스코드의 그룹회사코드
|
||||
eaiLog.setEaigroupcodstcd(message.getGroupCoCd());
|
||||
// PGUID
|
||||
eaiLog.setPguid(message.getMapper().getOrgGuid(message.getStandardMessage()));
|
||||
// 송수신구분
|
||||
eaiLog.setTrantype(message.getTranType());
|
||||
//
|
||||
eaiLog.setRspnschngmsgtype(message.getRspnsChngMsgType());
|
||||
|
||||
// log level 'E' or 'F'
|
||||
if ("E".equals(message.getRspErrCd().substring(1, 2))
|
||||
|| "F".equals(message.getRspErrCd().substring(1, 2))) {
|
||||
// EAI에러코드
|
||||
eaiLog.setEaierrcd(message.getRspErrCd());
|
||||
// EAI에러내용
|
||||
eaiLog.setEaierrctnt(StringUtil.chunkString(message.getRspErrMsg(), 1000));
|
||||
}
|
||||
|
||||
// 서버그룹명
|
||||
eaiLog.setSevrgroupname(serverGroupName);
|
||||
// 업체코드
|
||||
eaiLog.setCompanycode(message.getCompanyCode());
|
||||
// 전문크기, add 20190404
|
||||
eaiLog.setSplizlength(message.getSplizLength());
|
||||
// index 60
|
||||
// add 20190404 // adapterNickName
|
||||
eaiLog.setAdptrinsticode(message.getAdptrInstiCode());
|
||||
|
||||
// 거래ID
|
||||
eaiLog.setTxid(message.getTxId());
|
||||
// 참조ID
|
||||
eaiLog.setRefkey(message.getRefKey());
|
||||
// 대외업무구분코드
|
||||
eaiLog.setExtbizcd(message.getExtBizCd());
|
||||
// EAI 업무 개별부(32,000bytes)
|
||||
if (bwkData == null || bwkData.equals(""))
|
||||
bwkData = " ";
|
||||
eaiLog.setBzwkdatactnt(bwkData);
|
||||
String standardLayoutName = System.getProperty("STANDARD_LAYOUT_NAME");
|
||||
// 표준전문레이아웃 명
|
||||
eaiLog.setStdlayoutname(standardLayoutName);
|
||||
|
||||
// clientId 로그에 추가
|
||||
String clientId = message.getClientId();
|
||||
eaiLog.setClientid(clientId);
|
||||
|
||||
// client IP 로그에 추가
|
||||
String clientIp = message.getClientIp();
|
||||
eaiLog.setClientip(clientIp);
|
||||
|
||||
/**
|
||||
* CLIENT ID 있을 경우 APP, 기관정보 로그에 추가
|
||||
* TODO: ClientVO의 경우 spring security oauth의 ClientDetails를 상속받고 있어 OAUTH가 아닌 인증의 경우에 대한 처리 추가 필요
|
||||
*/
|
||||
if(StringUtils.isNotBlank(clientId)) {
|
||||
ClientVO clientVO = OAuth2Manager.getInstance().getClientVO(clientId);
|
||||
if (clientVO != null) {
|
||||
eaiLog.setClientname(clientVO.getClientName());
|
||||
eaiLog.setOrgid(clientVO.getOrgId());
|
||||
eaiLog.setOrgname(clientVO.getOrgName());
|
||||
}
|
||||
}
|
||||
|
||||
eaiLogEntityService.save(eaiLog);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
"DB Logging[MASTER] Failed - " + message.getEAISvcCd() + "|" + orglogPssSno + "|"
|
||||
+ message.getSvcOgNo() + "|" + message.getMapper().getGuid(message.getStandardMessage()),
|
||||
e);
|
||||
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG001"));
|
||||
}
|
||||
|
||||
// 에러로그를 별도의 테이블에 저장하도록 한다.
|
||||
if (!MessageUtil.checkRspErrCd(message.getRspErrCd())) {
|
||||
try {
|
||||
// 거래통제, 유량제어에 의한 에러는 저장하지 않도록 한다.
|
||||
if (!(EAIMessageKeys.EAI_BLOCKED_CODE.equals(message.getRspErrCd())
|
||||
|| EAIMessageKeys.EAI_INFLOW_BLOCKED_CODE.equals(message.getRspErrCd()))) {
|
||||
addErrorLog(message); // 에러로그
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.warn("에러로그테이블 저장 SKIP 에러발생 - " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void addErrorLog(EAIMessage message) throws DAOException {
|
||||
try {
|
||||
String serverName = EAIServerManager.getInstance().getLocalServerName();
|
||||
|
||||
EAIErrorLog eaiErrorLog = (EAIErrorLog) applicationContext.getBean(RollingTable.class, EAIErrorLog.class,
|
||||
message.getMsgRcvTm());
|
||||
|
||||
// EAI업무구분코드
|
||||
EAIErrorLogId eaiErrorLogId = new EAIErrorLogId();
|
||||
eaiErrorLog.setId(eaiErrorLogId);
|
||||
|
||||
eaiErrorLogId.setEaibzwkdstcd(message.getBwkCls());
|
||||
// 메시지수신시각
|
||||
eaiErrorLogId.setMsgdpstyms(DatetimeUtil.getCurrentTime(message.getMsgRcvTm()));
|
||||
// EAI거래일련번호
|
||||
eaiErrorLogId.setEaisvcserno(message.getSvcOgNo());
|
||||
// 로그처리일련번호
|
||||
eaiErrorLogId.setLogprcssserno(String.valueOf(message.getLogPssSno()));
|
||||
|
||||
// EAI서비스명
|
||||
eaiErrorLog.setEaisvcname(message.getEAISvcCd());
|
||||
// 응답에러코드명
|
||||
eaiErrorLog.setRspnserrcdname(message.getRspErrCd());
|
||||
// 기동시스템어댑터업무그룹명
|
||||
eaiErrorLog.setGstatsysadptrbzwkgroupname(message.getSngSysItfTp());
|
||||
// 수동시스템어댑터업무그룹명
|
||||
eaiErrorLog.setPsvsysadptrbzwkgroupname(message.getCurrentSvcMsg().getPsvSysItfTp());
|
||||
|
||||
if ("E".equals(message.getRspErrCd().substring(1, 2))
|
||||
|| "F".equals(message.getRspErrCd().substring(1, 2))) {
|
||||
// EAI에러코드
|
||||
eaiErrorLog.setEaierrcd(message.getRspErrCd());
|
||||
// EAI에러내용
|
||||
eaiErrorLog.setEaierrctnt(StringUtil.chunkString(message.getRspErrMsg(), 500));
|
||||
}
|
||||
|
||||
// EAI서버인스턴스명
|
||||
eaiErrorLog.setEaisevrinstncname(serverName);
|
||||
// 로깅시스템ID
|
||||
EAIServerVO eaiServerVO = EAIServerManager.getInstance().getEAIServer(serverName);
|
||||
if(eaiServerVO != null) {
|
||||
eaiErrorLog.setLgingsysid(eaiServerVO.getHostName());
|
||||
}
|
||||
// 메시지처리일시
|
||||
eaiErrorLog.setMsgprcssyms(DatetimeUtil.getCurrentTime(message.getMsgPssTm()));
|
||||
// EAI그룹회사코드
|
||||
eaiErrorLog.setEaigroupcodstcd(message.getGroupCoCd());
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("DB Logging[ERROR_LOG] Failed - " + message.getEAISvcCd() + "|" + message.getLogPssSno() + "|"
|
||||
+ message.getSvcOgNo(), e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG003"));
|
||||
}
|
||||
}
|
||||
|
||||
public void addStaticLog(StatMonitorLogVO vo) throws DAOException {
|
||||
try {
|
||||
StatLog statLog = statLogMapper.toEntity(vo);
|
||||
statLogLogger.save(statLog);
|
||||
} catch (Exception e) {
|
||||
logger.error("DB Logging[STATIC_LOG] Failed - " + vo.toString(), e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG003"));
|
||||
}
|
||||
}
|
||||
|
||||
public void addStaticTranCdLog(StatMonitorLogVO vo) throws DAOException {
|
||||
try {
|
||||
StatTranLog statTranLog = statTranLogMapper.toEntity(vo);
|
||||
statTranLogLogger.save(statTranLog);
|
||||
} catch (Exception e) {
|
||||
logger.error("DB Logging[STATIC_TRANCD_LOG] Failed - " + vo.toString(), e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG003"));
|
||||
}
|
||||
}
|
||||
|
||||
public void addStaticAdapterLog(StatMonitorLogVO vo) throws DAOException {
|
||||
try {
|
||||
StatAdapterLog statAdapterLog = statAdapterLogMapper.toEntity(vo);
|
||||
statAdapterLogLogger.save(statAdapterLog);
|
||||
} catch (Exception e) {
|
||||
logger.error("DB Logging[STATIC_ADAPTER_LOG] Failed - " + vo.toString(), e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICLG003"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getCheck() throws DAOException {
|
||||
return eaiServerEntityService.checkConnection();
|
||||
}
|
||||
|
||||
private boolean checkSubLogging(String svcTsmtUsgTp, String psvItfTp, String srcAdptrMsgPtrnCd, String tgtAdptrMsgPtrnCd, int logPssSno) {
|
||||
boolean isAsyncSvc = EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) && EAIMessageKeys.ASYNC_SVC.equals(psvItfTp);
|
||||
boolean isSrcStandard = com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(srcAdptrMsgPtrnCd);
|
||||
|
||||
// // SOURCE : AA : 100, 300, ELSE: 100, 400
|
||||
if(isSrcStandard && ( (isAsyncSvc && (logPssSno == 100 || logPssSno == 300)) ||
|
||||
(!isAsyncSvc && (logPssSno == 100 || logPssSno == 400)) ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isTgtStandard = com.eactive.eai.adapter.Keys.IF_SUBSTANDARD.equals(tgtAdptrMsgPtrnCd);
|
||||
// // TARGET : AA : 200, 400, ELSE : 200, 300
|
||||
if (isTgtStandard && ( (isAsyncSvc && (logPssSno == 200 || logPssSno == 400)) ||
|
||||
(!isAsyncSvc && (logPssSno == 200 || logPssSno == 300)) ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI 로그 처리 시 예외처리를 위한 Exception
|
||||
* 2. 처리 개요 :
|
||||
* - EAILogger 예외처리
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author : 전영석( amjang@evalleyvs.com)
|
||||
* @version : v 1.0.0
|
||||
* @see : TestCall
|
||||
* @since :JDK v1.4.2
|
||||
*/
|
||||
public class EAILogException extends Exception
|
||||
{
|
||||
/**
|
||||
* 1. 기능 : Default 생성자 함수
|
||||
* 2. 처리 개요 :
|
||||
* - Default 생성자 함수
|
||||
* 3. 주의사항
|
||||
*
|
||||
**/
|
||||
public EAILogException() {
|
||||
super("EAILogException is occured.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Exception 발생 원인을 저장하는 생성자 함수
|
||||
* 2. 처리 개요 :
|
||||
* - Exception 발생 원인을 저장하는 생성자 함수
|
||||
* 3. 주의사항
|
||||
*
|
||||
*@param msg Exception 발생 원인
|
||||
**/
|
||||
public EAILogException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.dao.Keys;
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI에서 처리되는 모든 On-Line 거래를 데이터베이스에 로깅하기 위한 운영관리 Logger Query Object
|
||||
* 2. 처리 개요 :
|
||||
* - TSEAILG01(EAI서비스로그), TSEAILG02(로그ALTKEY정보), TSEAILG03(EAI로그업무데이터서브정보), TSEAILG04(EAI서비스오류정보) insert Query
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author : 전영석(amjang@evalleyvs.com)
|
||||
* @version : v 1.0.0
|
||||
* @see : IMSAdapterListener, IMSRecord
|
||||
* @since :JDK v1.4.2
|
||||
*/
|
||||
public interface EAILogQuery
|
||||
{
|
||||
/**
|
||||
* 1. 기능 : EAI 서비스 로그 셋팅
|
||||
* 2. 처리 개요 :
|
||||
* - TSEAILG01(EAI서비스로그) 로그값 셋팅
|
||||
* 3. 주의사항
|
||||
**/
|
||||
public static final String ADD_EAI_SVC_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "#{LOG_MASTER_TABLE} ( \n"
|
||||
//EAI업무공통부
|
||||
+ " EAIBZWKDSTCD, MSGDPSTYMS, EAISVCSERNO, LOGPRCSSSERNO, EAISEVRINSTNCNAME, \n"
|
||||
+ " EAISVCNAME, SVCHMSEONOT, SVCMOTIVUSEDSTCD, SVCPRCSSDSTICNAME, FLOWCTRLROUTNAME, \n"
|
||||
+ " INTGRADSTICNAME, GSTATSVCDSTICNAME, SVCPRCSSNO, SVCBFCLMNLOGYN, STNDMSGUSEYN, \n"
|
||||
+ " GSTATSYSADPTRBZWKGROUPNAME, PRSNTMSGIDNAME, RSPNSERRCDNAME, MSGPRCSSYMS, SEVRLOGLVELNO, \n"
|
||||
+ " SVCLOGLVELNO, ERREAISVCNAME, DMNDERRCHNGIDNAME, DMNDERRFLDNAME, RSPNSERRCHNGIDNAME, \n"
|
||||
+ " RSPNSERRFLDNAME, PSVINTFACDSTICNAME, PSVBZWKSYSNAME, PSVSYSIDNAME, PSVSYSSVCDSTICNAME, \n"
|
||||
+ " PSVSYSADPTRBZWKGROUPNAME, FLOVRYN, CHNGYN, CHNGMSGIDNAME, INPTMSGIDNAME, \n"
|
||||
+ " BASCRSPNSMSGCMPRCTNT, BASCRSPNSCHNGYN, BASCRSPNSCHNGMSGIDNAME, ERRRSPNSMSGCMPRCTNT, ERRRSPNSCHNGYN, \n"
|
||||
+ " ERRRSPNSCHNGMSGIDNAME, NEXTSVCPRCSSNO, OUTBNDROUTNAME, TOUTVAL, CMPENSVCPRCSSNAME, \n"
|
||||
+ " SUPPLBZWKDATAYN, KEYMGTMSGCTNT, TRACKASISKEY1CTNT, TRACKASISKEY2CTNT, TRACKASISKEY3CTNT, \n"
|
||||
+ " TRACKASISKEY4CTNT, EAIGROUPCODSTCD, PGUID, TRANTYPE, RSPNSCHNGMSGTYPE, \n"
|
||||
+ " EAIERRCD, EAIERRCTNT, SEVRGROUPNAME, COMPANYCODE, SPLIZLENGTH, ADPTRINSTICODE, \n"
|
||||
+ " TXID, REFKEY, EXTBIZCD, \n"
|
||||
+ " BZWKDATACTNT, STDLAYOUTNAME, CLIENTID \n"
|
||||
+ " ) VALUES ( \n"
|
||||
//EAI업무공통부
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 5
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 10
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 15
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 20
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 25
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 30
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 35
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 40
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 45
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 50
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 55
|
||||
+ " ?, ?, ?, ?, ?, \n" //index to 60
|
||||
+ " ?, ?, ?, ?,\n" //index to 61
|
||||
+ " ?, ?, ? \n" // 62~66
|
||||
+ ") ";
|
||||
|
||||
/**
|
||||
* 1. 기능 : 업무데이터 서브 로그 셋팅
|
||||
* 2. 처리 개요 :
|
||||
* - TSEAILG03(EAI로그업무데이터서브정보) 로그값 셋팅
|
||||
* 3. 주의사항
|
||||
**/
|
||||
public static final String ADD_BWK_DATA_SUB
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "#{LOG_SLAVE_TABLE} ( \n"
|
||||
+ " EAIBZWKDSTCD, MSGDPSTYMS, EAISVCSERNO, BZWKDATASERNO, LOGPRCSSSERNO \n"
|
||||
+ " , BZWKDATACTNT \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ? \n"
|
||||
+ " ) ";
|
||||
|
||||
public static final String ERROR_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "#{LOG_SLAVE_TABLE} ( \n"
|
||||
+ " EAIBZWKDSTCD, MSGDPSTYMS, EAISVCSERNO, LOGPRCSSSERNO, EAISVCNAME \n"
|
||||
+ " , RSPNSERRCDNAME, GSTATSYSADPTRBZWKGROUPNAME, PSVSYSADPTRBZWKGROUPNAME, EAIERRCD, EAIERRCTNT \n"
|
||||
+ " , EAISEVRINSTNCNAME, LGINGSYSID, MSGPRCSSYMS, EAIGROUPCODSTCD \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ? \n"
|
||||
+ " ) ";
|
||||
|
||||
|
||||
public static final String STATIC_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "TSEAISR01 ( \n"
|
||||
+ " BASEYMD, BASEHH, BASEHHMM, EAIBZWKDSTCD, EAISVCNAME \n"
|
||||
+ " , EAISEVRINSTNCNAME, EAIPRCSSTTMVAL, EAIPSVPRCSSTTMVAL, EAITOTALPRCSSTTMVAL, WHOLPRCSSNOITM \n"
|
||||
+ " , ERRZNOITM, TOUTNOITM, NOMALNOITM \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ? \n"
|
||||
+ " ) ";
|
||||
|
||||
|
||||
public static final String STATIC_TRANCD_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "TSEAISR02 ( \n"
|
||||
+ " BASEYMD, BASEHH, BASEHHMM, EAIBZWKDSTCD, EAISVCNAME \n"
|
||||
+ " , INTFACSENDTRANCD, EAISEVRINSTNCNAME ,EAIPRCSSTTMVAL, EAIPSVPRCSSTTMVAL, EAITOTALPRCSSTTMVAL \n"
|
||||
+ " , WHOLPRCSSNOITM, ERRZNOITM, TOUTNOITM, NOMALNOITM \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ? \n"
|
||||
+ " ) ";
|
||||
|
||||
public static final String STATIC_SCREEN_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "TSEAISR03 ( \n"
|
||||
+ " BASEYMD, BASEHH, BASEHHMM, EAIBZWKDSTCD, EAISVCNAME \n"
|
||||
+ " , SCRENNO, EAISEVRINSTNCNAME, EAIPRCSSTTMVAL, EAIPSVPRCSSTTMVAL, EAITOTALPRCSSTTMVAL \n"
|
||||
+ " , WHOLPRCSSNOITM, ERRZNOITM, TOUTNOITM, NOMALNOITM \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ? \n"
|
||||
+ " ) ";
|
||||
|
||||
public static final String STATIC_ADAPTER_LOG
|
||||
= " INSERT INTO " + Keys.TABLE_OWNER + "TSEAISR04 ( \n"
|
||||
+ " BASEYMD, BASEHH, BASEHHMM, EAIBZWKDSTCD, EAISVCNAME \n"
|
||||
+ " , ADPTRBZWKGROUPNAME, EAISEVRINSTNCNAME, EAIPRCSSTTMVAL, EAIPSVPRCSSTTMVAL, EAITOTALPRCSSTTMVAL \n"
|
||||
+ " , WHOLPRCSSNOITM, ERRZNOITM, TOUTNOITM, NOMALNOITM \n"
|
||||
+ " ) VALUES ( \n"
|
||||
+ " ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ?, ? \n"
|
||||
+ " , ?, ?, ?, ? \n"
|
||||
+ " ) ";
|
||||
|
||||
public static final String CHECK_DB = "select 1";
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
|
||||
import com.eactive.eai.common.logger.async.AsyncLoggingPoolManager;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.message.EAIMessageKeys;
|
||||
import com.eactive.eai.common.monitor.EAIServiceMonitor;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.env.ElinkConfig;
|
||||
|
||||
/**
|
||||
* 1. 기능 : EAI에서 처리되는 모든 On-Line 거래를 데이터베이스에 로깅하기 위한 운영관리 Logger Sender
|
||||
* 2. 처리 개요 : - RequestProcessor에서 받은 로깅 정보를 로그 Queue로 전달
|
||||
* 3. 주의사항
|
||||
*/
|
||||
public class EAILogSender {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
static TransactionLogger txLogger;
|
||||
static {
|
||||
try {
|
||||
txLogger = (TransactionLogger) Class.forName("com.eactive.eai.common.logger.DBLogTransactionLogger").newInstance();
|
||||
} catch(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private EAILogSender() {
|
||||
|
||||
}
|
||||
public static int logCount() {
|
||||
return txLogger.logCount();
|
||||
}
|
||||
|
||||
public static int errCount() {
|
||||
return txLogger.errCount();
|
||||
}
|
||||
|
||||
public static void resetCount() {
|
||||
txLogger.resetCount();
|
||||
}
|
||||
|
||||
public static void send(EAIMessage message, Properties prop) throws Exception {
|
||||
if(message == null) {
|
||||
if(logger.isWarn()) {
|
||||
logger.warn("EAIMessage is null, skip async logging.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
String guidLogPrefix = "EAILogSender] GUID[" + message.getMapper().getGuid(message.getStandardMessage())
|
||||
+ "] UUID[" + message.getSvcOgNo() + "] ";
|
||||
|
||||
boolean isLogging = false;
|
||||
int svcLogLvl = message.getSvcLogLvl();
|
||||
int logPssSno = message.getLogPssSno();
|
||||
String svcTsmtUsgTp = message.getSvcTsmtUsgTp();
|
||||
if(svcLogLvl >= 3) {
|
||||
isLogging = true;
|
||||
}
|
||||
else if(svcLogLvl == 2) {
|
||||
if( EAIMessageKeys.SYNC_SVC.equals(svcTsmtUsgTp) &&
|
||||
(logPssSno == 100 || logPssSno == 400) ) {
|
||||
isLogging = true;
|
||||
}
|
||||
if( EAIMessageKeys.ASYNC_SVC.equals(svcTsmtUsgTp) &&
|
||||
(logPssSno == 200 || logPssSno == 400) ) {
|
||||
isLogging = true;
|
||||
}
|
||||
}
|
||||
else if(svcLogLvl == 1) {
|
||||
isLogging = ! MessageUtil.checkRspErrCd(message.getRspErrCd());
|
||||
}
|
||||
else {
|
||||
isLogging = false;
|
||||
}
|
||||
if(logger.isDebug()) {
|
||||
logger.debug(guidLogPrefix + " svcLogLvl="+ svcLogLvl + ",isLogging="+ isLogging+ ", logPssSno="+ logPssSno);
|
||||
}
|
||||
long logTime = System.currentTimeMillis();
|
||||
message.setMsgPssTm(logTime);
|
||||
if(isLogging) {
|
||||
if(ElinkConfig.isUseAsyncLogging()) {
|
||||
try {
|
||||
EAIMessage cloned = null;
|
||||
// cloned = (EAIMessage) ObjectUtil.deepCopy(message);
|
||||
// cloned = (EAIMessage) SerializationUtils.clone(message);
|
||||
// performance issue, use clone -> shallow copy bug -> fix
|
||||
cloned = (EAIMessage) message.clone();
|
||||
Properties clonedProp = null;
|
||||
if(prop != null) clonedProp = (Properties) prop.clone();
|
||||
AsyncLoggingPoolManager.getInstance().publish(cloned, clonedProp);
|
||||
} catch (Exception e) {
|
||||
logger.warn("AsyncLogging error", e);
|
||||
logDirect(message, prop);
|
||||
// throw e;
|
||||
}
|
||||
}
|
||||
else {
|
||||
logDirect(message, prop);
|
||||
}
|
||||
}
|
||||
|
||||
// 실시간 모니터링 로그
|
||||
EAIServiceMonitor servicemonitor = EAIServiceMonitor.getInstance();
|
||||
if(EAIMessageKeys.EAI_BLOCKED_CODE.equals(message.getRspErrCd())) {
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(guidLogPrefix + " 거래통제 실시간 모니터링 SKIP - " + message.getEAISvcCd()
|
||||
+ ", "+message.getMapper().getGuid(message.getStandardMessage()) );
|
||||
}
|
||||
}else if (EAIMessageKeys.EAI_INFLOW_BLOCKED_CODE.equals(message.getRspErrCd())) {
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(guidLogPrefix + " 유량제어 실시간 모니터링 SKIP - " + message.getEAISvcCd()
|
||||
+ ", "+ message.getMapper().getGuid(message.getStandardMessage()) );
|
||||
}
|
||||
}else {
|
||||
servicemonitor.receiveLogMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void logDirect(EAIMessage message, Properties prop) throws EAILogException {
|
||||
txLogger.log(message, prop);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class HttpAdapterExtraHeaderVo {
|
||||
private String name;
|
||||
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.logger.async.HttpAdapterExtraLogH2Factory;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class HttpAdapterExtraLogFileLogger {
|
||||
|
||||
public void writeFileLog(HttpAdapterExtraLog httpAdapterExtraLog){
|
||||
try (Session session = HttpAdapterExtraLogH2Factory.getInstance().openSession()) {
|
||||
Transaction transaction = null;
|
||||
|
||||
try {
|
||||
// 트랜잭션 시작
|
||||
transaction = session.beginTransaction();
|
||||
|
||||
session.persist(httpAdapterExtraLog);
|
||||
|
||||
// 트랜잭션 커밋
|
||||
transaction.commit();
|
||||
} catch (Exception e) {
|
||||
if (transaction != null) {
|
||||
transaction.rollback();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HttpAdapterExtraLogVo {
|
||||
private String guid;
|
||||
private int serviceProcessNumber;
|
||||
private String adapterGroupName;
|
||||
private String adapterName;
|
||||
private String url;
|
||||
private String httpMethod;
|
||||
private int httpStatus;
|
||||
List<HttpAdapterExtraHeaderVo> headerList;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.logger.mapper.HttpAdapterExtraLogMapper;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class HttpLoggingService {
|
||||
|
||||
@Autowired
|
||||
private HttpAdapterExtraLogMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private HttpAdapterExtraLogLogger dbLogger;
|
||||
|
||||
@Autowired
|
||||
private HttpAdapterExtraLogFileLogger fileLogger;
|
||||
|
||||
public void insertHttpAdapterExtraLog(HttpAdapterExtraLogVo httpAdapterExtraLogVo) throws Throwable{
|
||||
HttpAdapterExtraLog httpAdapterExtraLog = mapper.toEntity(httpAdapterExtraLogVo);
|
||||
if (EAIDBLogControl.isEnable()) {
|
||||
try {
|
||||
dbLogger.save(httpAdapterExtraLog);
|
||||
} catch(Exception e){
|
||||
String message = e.getMessage();
|
||||
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
|
||||
// 오류 메시지 추가 - Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
|
||||
if( "ConnectionError".equals(message) || StringUtils.contains(message, "JDBCConnectionException")
|
||||
|| StringUtils.contains(message, "Unable to acquire JDBC Connection") ) {
|
||||
EAIDBLogControl.setEnable(false);
|
||||
}
|
||||
fileLogger.writeFileLog(httpAdapterExtraLog);
|
||||
}
|
||||
} else {
|
||||
fileLogger.writeFileLog(httpAdapterExtraLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageListener;
|
||||
import javax.jms.Queue;
|
||||
import javax.jms.QueueConnection;
|
||||
import javax.jms.QueueConnectionFactory;
|
||||
import javax.jms.QueueReceiver;
|
||||
import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import com.eactive.eai.common.exception.ExceptionUtil;
|
||||
import com.eactive.eai.common.jms.JmsServiceLocator;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 1. 기능 : LogListener를 관리하는 Manager 클래스
|
||||
* 2. 처리 개요 : ServiceLocator로부터 queue를 get하여 Receiver를 생성 관리한한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since : :
|
||||
*/
|
||||
public class LogListener implements MessageListener, Lifecycle {
|
||||
private String name;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
private boolean started;
|
||||
|
||||
private QueueConnection qcon;
|
||||
private QueueSession qsession;
|
||||
private QueueReceiver qreceiver;
|
||||
private Queue queue;
|
||||
|
||||
public LogListener(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void onMessage(Message msg) {
|
||||
// write code here!
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICLG101");
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, null);
|
||||
|
||||
try {
|
||||
JmsServiceLocator locator = JmsServiceLocator.getInstance();
|
||||
QueueConnectionFactory qconFactory = locator.getQueueConnectionFactory(Keys.LOG_CONNECTION_FACTORY);
|
||||
if (qconFactory == null) {
|
||||
throw new Exception("QueueConnectionFactory not found - " + Keys.LOG_CONNECTION_FACTORY);
|
||||
}
|
||||
qcon = qconFactory.createQueueConnection();
|
||||
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
queue = locator.getQueue(Keys.LOG_QUEUE);
|
||||
qreceiver = qsession.createReceiver(queue);
|
||||
qreceiver.setMessageListener(this);
|
||||
qcon.start();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICLG102"));
|
||||
}
|
||||
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, null);
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICLG103");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, null);
|
||||
|
||||
try {
|
||||
if (qreceiver != null)
|
||||
qreceiver.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if (qreceiver != null)
|
||||
qsession.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
try {
|
||||
if (qreceiver != null)
|
||||
qcon.close();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
started = false;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, null);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 1. 기능 : LogListener를 생성 관리하는 Manager 클래스
|
||||
* 2. 처리 개요 : LogListener를 생성 관리한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @author :
|
||||
* @version : v 1.0.0
|
||||
* @see : 관련 기능을 참조
|
||||
* @since :
|
||||
* :
|
||||
*/
|
||||
public class LogListenerManager implements Lifecycle
|
||||
{
|
||||
|
||||
/**
|
||||
* Default Logger
|
||||
*/
|
||||
// private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
/**
|
||||
* LogListener생성 count. LogListener생성시 증가시킴
|
||||
*/
|
||||
private int count;
|
||||
|
||||
|
||||
// private ArrayList listeners;
|
||||
|
||||
/**
|
||||
* LifeccyleSupport object
|
||||
*/
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
/**
|
||||
* 기동 여부
|
||||
*/
|
||||
private boolean started;
|
||||
|
||||
/**
|
||||
* LogListener생성시 동기화를 위한 lock
|
||||
*/
|
||||
private Object lock = new Object();
|
||||
|
||||
/**
|
||||
* 1. 기능 : Lifecycle의 start 메서드로 LogListenerManager를 초기화하는 메서드
|
||||
* 2. 처리 개요 : Lifecycle의 start
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @exception LifecycleException 이미 시작되었을 경우 발생(RECEAICLG111)
|
||||
*
|
||||
**/
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICLG111");
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, null);
|
||||
|
||||
// this.listeners = new ArrayList();
|
||||
this.count = 0;
|
||||
|
||||
started = true;
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : Lifecycle의 stop 메서드로 LogListenerManager를 종료하는 메서드
|
||||
* 2. 처리 개요 : Lifecycle의 stop 메서드로 LogListenerManager를 종료
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @exception LifecycleException 이미 종료된 경우 발생(RECEAICLG112)
|
||||
**/
|
||||
public void stop() throws LifecycleException {
|
||||
// Validate and update our current component state
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICLG112");
|
||||
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, null);
|
||||
|
||||
|
||||
|
||||
started = false;
|
||||
// Notify our interested LifecycleListeners
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : LifecycleListener를 등록하는 메서드
|
||||
* 2. 처리 개요 : LifecycleListener를 등록한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param listener LifecycleEvent를 수신한 LifecycleListener
|
||||
**/
|
||||
public void addLifecycleListener(LifecycleListener listener)
|
||||
{
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 등록된 LifecycleListener 리스트를 반환하는 메서드
|
||||
* 2. 처리 개요 : 등록된 LifecycleListener 리스트를 반환하다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return 등록된 LifecycleListener 리스트
|
||||
**/
|
||||
public LifecycleListener[] findLifecycleListeners()
|
||||
{
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : 등록된 LifecycleListener를 삭제하는 메서드
|
||||
* 2. 처리 개요 : 파라미터의 LifecycleListener를 삭제한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @param listener 삭제할 LifecycleListener
|
||||
**/
|
||||
public void removeLifecycleListener(LifecycleListener listener)
|
||||
{
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : LogListenerManager의 초기화 여부를 반환하는 getter 메서드
|
||||
* 2. 처리 개요 : LogListenerManager의 초기화 여부를 반환한다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
* @return 초기화 여부
|
||||
**/
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 1. 기능 : LogListener를 생성하고 초기화하는 메서드
|
||||
* 2. 처리 개요 : LogListener를 생성하고 생성한 LogListener를 start하여 초기화 시킨다.
|
||||
* 3. 주의사항
|
||||
*
|
||||
**/
|
||||
public void addLogListener() {
|
||||
LogListener listener = createLogListener();
|
||||
if(listener instanceof Lifecycle) {
|
||||
try {
|
||||
listener.start();
|
||||
} catch(Exception e) {
|
||||
String code = "RECEAICLG113";
|
||||
//if (logger.isError()) logger.error(ExceptionUtil.make(code, CodeMessageHandler.getMessage(code)));
|
||||
throw new RuntimeException(ExceptionUtil.getErrorCode(e, code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. 기능 : LogListener를 생성하는 메서드
|
||||
* 2. 처리 개요 : LogListener를 생성시 생성 카운트를 증가시킨다
|
||||
* -
|
||||
* 3. 주의사항
|
||||
* @return LogListener 생성된 LogListener
|
||||
**/
|
||||
private LogListener createLogListener() {
|
||||
String name = null;
|
||||
synchronized(lock) {
|
||||
name = "LogListener["+(++count)+"]";
|
||||
}
|
||||
LogListener listener = new LogListener(name);
|
||||
|
||||
return listener;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.MessageUtil;
|
||||
import com.eactive.eai.transformer.layout.Layout;
|
||||
import com.eactive.eai.transformer.message.BytesMessage;
|
||||
import com.eactive.eai.transformer.message.JSONMessage;
|
||||
import com.eactive.eai.transformer.message.Message;
|
||||
import com.eactive.eai.transformer.message.MessageFactory;
|
||||
import com.eactive.eai.transformer.message.XMLMessage;
|
||||
|
||||
public class LogMessageUtil {
|
||||
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
public static String makeMaskData(EAIMessage message, Object bizMsg, Layout l, int logPssSno, String tgtAdptrMsgPtrnCd
|
||||
, String svcTsmtUsgTp, String psvItfTp) throws Exception {
|
||||
String bizMsgStr="";
|
||||
Message msg = MessageFactory.getFactory().getMessage(l.getName());
|
||||
if("XML".equals(l.getLayoutType().getName())) {
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] XML Message Masking - "+ message.getEAISvcCd()+" - "+ logPssSno);
|
||||
|
||||
String xmlString = "";
|
||||
if(bizMsg instanceof byte[]) {
|
||||
xmlString = new String((byte[])bizMsg);
|
||||
} else {
|
||||
xmlString = (String)bizMsg;
|
||||
}
|
||||
|
||||
String rootItemName = ((XMLMessage)msg).getLayout().getRootItem().getName();
|
||||
xmlString = MessageUtil.removeXMLHeader(xmlString);
|
||||
xmlString = "<"+rootItemName+">"+xmlString+"</"+rootItemName+">";
|
||||
msg.setData(xmlString);
|
||||
bizMsgStr = MessageUtil.removeXMLRootItem(msg.toLogString(), rootItemName);
|
||||
}
|
||||
else if("JSON".equals(l.getLayoutType().getName())) {
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] JSON Message Masking - "+ message.getEAISvcCd()+" - "+ logPssSno);
|
||||
String jsonString = "";
|
||||
|
||||
jsonString = (String)bizMsg;
|
||||
|
||||
// String rootItemName = ((JSONMessage)msg).getLayout().getRootItem().getName();
|
||||
// jsonString = MessageUtil.addJsonRootItem(jsonString, rootItemName);
|
||||
// msg.setData(jsonString);
|
||||
// bizMsgStr = MessageUtil.removeJsonRootItem(msg.toLogString(), rootItemName);;
|
||||
|
||||
// JSON Tuning
|
||||
msg.setData(jsonString);
|
||||
bizMsgStr = msg.toLogString();
|
||||
}
|
||||
// else if("UJSON".equals(l.getLayoutType().getName())) {
|
||||
// if (logger.isInfo()) logger.info("EAILogDAO] UJSON Message Masking - "+ message.getEAISvcCd()+" - "+ logPssSno);
|
||||
//
|
||||
// String jsonString = "";
|
||||
//
|
||||
// if(bizMsg instanceof byte[]) {
|
||||
// jsonString = new String((byte[])bizMsg, UJSONMessage.encode);
|
||||
// } else {
|
||||
// jsonString = (String)bizMsg;
|
||||
// }
|
||||
//
|
||||
// String rootItemName = ((UJSONMessage)msg).getLayout().getRootItem().getName();
|
||||
// jsonString = MessageUtil.addJsonRootItem(jsonString, rootItemName);
|
||||
// msg.setData(jsonString);
|
||||
// bizMsgStr = MessageUtil.removeJsonRootItem(msg.toLogString(), rootItemName);;
|
||||
// }
|
||||
else if("EBCDIC".equals(l.getLayoutType().getName())) {
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] EBCDIC Message Masking - "+ message.getEAISvcCd()+" - "+ logPssSno);
|
||||
|
||||
byte[] orgBytes = (byte[])bizMsg;
|
||||
byte[] msgBytes = null;
|
||||
byte[] header = null;
|
||||
|
||||
msg.setData(bizMsg);
|
||||
bizMsgStr = ((BytesMessage)msg).toLogString(true);
|
||||
}
|
||||
else if( "BYTES".equals(l.getLayoutType().getName()) ) {
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] BYTES Message Masking - "+ logPssSno);
|
||||
byte[] orgBytes = (byte[])bizMsg;
|
||||
byte[] msgBytes = null;
|
||||
byte[] header = null;
|
||||
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] BYTES Standard Header Type = " + tgtAdptrMsgPtrnCd);
|
||||
|
||||
if (logger.isInfo()) logger.info("EAILogDAO] "+l.getLayoutType().getName()+" Message Masking - "+ message.getEAISvcCd()+" - "+ logPssSno);
|
||||
msg.setData(bizMsg);
|
||||
bizMsgStr = msg.toLogString();
|
||||
}
|
||||
else {
|
||||
msg.setData(bizMsg);
|
||||
bizMsgStr = msg.toLogString();
|
||||
}
|
||||
return bizMsgStr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.eactive.eai.common.logger;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
public interface TransactionLogger {
|
||||
public void log(EAIMessage message,Properties prop) throws EAILogException;
|
||||
public int logCount();
|
||||
public int errCount();
|
||||
public void resetCount();
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
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.logger.HttpAdapterExtraLogVo;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ElinkConfig;
|
||||
import org.apache.commons.pool2.ObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* HTTP 로그도 ASYNC 모드를 대응하기 위해 추가
|
||||
* 추후 고도화 필요
|
||||
*/
|
||||
public class AsyncHttpLoggingPoolManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static AsyncHttpLoggingPoolManager instance;
|
||||
|
||||
private static boolean stopped = true;
|
||||
|
||||
private int maxPoolSize = 10;
|
||||
private int initPoolSize = 8;
|
||||
|
||||
private boolean initOnStartup = true;
|
||||
|
||||
private ObjectPool<HttpLoggingPoolObject> pool = null;
|
||||
|
||||
/**
|
||||
* 기동 여부
|
||||
*/
|
||||
private boolean started;
|
||||
|
||||
/**
|
||||
* LifeccyleSupport object
|
||||
*/
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
public static synchronized AsyncHttpLoggingPoolManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new AsyncHttpLoggingPoolManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
}
|
||||
|
||||
public int getInitPoolSize() {
|
||||
return initPoolSize;
|
||||
}
|
||||
|
||||
public void setInitPoolSize(int initPoolSize) {
|
||||
this.initPoolSize = initPoolSize;
|
||||
}
|
||||
|
||||
public boolean isInitOnStartup() {
|
||||
return initOnStartup;
|
||||
}
|
||||
|
||||
public void setInitOnStartup(boolean initOnStartup) {
|
||||
this.initOnStartup = initOnStartup;
|
||||
}
|
||||
|
||||
public void publish(HttpAdapterExtraLogVo httpAdapterExtraLogVo) throws Exception {
|
||||
HttpLoggingPoolObject queue = null;
|
||||
try {
|
||||
queue = borrowObject();
|
||||
queue.putMessage(httpAdapterExtraLogVo);
|
||||
} catch (Exception ex) {
|
||||
logger.error("publish failed.", ex);
|
||||
throw ex;
|
||||
} finally {
|
||||
if (queue != null) returnObject(queue);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (pool != null) shutdown();
|
||||
maxPoolSize = ElinkConfig.getAsyncPoolMaxSize();
|
||||
initPoolSize = ElinkConfig.getAsyncPoolInitSize();
|
||||
initOnStartup = ElinkConfig.isAsyncInitOnstartup();
|
||||
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("<< init start - maxPoolSize = {}, initPoolSize = {}, initOnStartup = {}", maxPoolSize, initPoolSize, initOnStartup);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
|
||||
HttpLoggingPoolObjectFactory factory = new HttpLoggingPoolObjectFactory();
|
||||
|
||||
config.setMaxTotal(maxPoolSize);
|
||||
//config.setMinIdle(maxPoolSize); // default: 0
|
||||
//config.setMaxIdle(maxPoolSize); // default: 8
|
||||
config.setMaxWait(Duration.ofSeconds(5));
|
||||
// add proper config options
|
||||
// config.setLifo(true);
|
||||
pool = new GenericObjectPool<HttpLoggingPoolObject>(factory, config);
|
||||
|
||||
if (initOnStartup) {
|
||||
HttpLoggingPoolObject[] pools = new HttpLoggingPoolObject[initPoolSize];
|
||||
for (int i = 0; i < initPoolSize; i++) {
|
||||
try {
|
||||
logger.warn(">> borrowObject LoggingPoolObject-" + i);
|
||||
pools[i] = pool.borrowObject();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < initPoolSize; i++) {
|
||||
try {
|
||||
logger.warn("<< returnObject LoggingPoolObject-" + i);
|
||||
pool.returnObject(pools[i]);
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
stopped = false;
|
||||
logger.warn("<< init end");
|
||||
}
|
||||
|
||||
public HttpLoggingPoolObject borrowObject() throws Exception {
|
||||
if (stopped) throw new PoolShutdownException();
|
||||
return pool.borrowObject();
|
||||
}
|
||||
|
||||
public void returnObject(HttpLoggingPoolObject object) throws Exception {
|
||||
if (stopped) throw new PoolShutdownException();
|
||||
pool.returnObject(object);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("<< shutdown start");
|
||||
}
|
||||
int retry = 0;
|
||||
|
||||
try {
|
||||
if (pool != null) {
|
||||
while (true) {
|
||||
pool.close();
|
||||
logger.warn("close pool.getNumActive() = " + pool.getNumActive());
|
||||
if (pool.getNumActive() == 0 || retry > 10) break;
|
||||
logger.warn("close - sleep 100ms");
|
||||
Thread.sleep(100);
|
||||
retry++;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("shutdown failed.", e);
|
||||
} finally {
|
||||
stopped = true;
|
||||
pool = null;
|
||||
}
|
||||
logger.warn(">> shutdown end");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LifecycleListener[] findLifecycleListeners() {
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICRT201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
// init pool & disruptor component
|
||||
init();
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICRT203");
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
shutdown();
|
||||
started = false;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.pool2.ObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
|
||||
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.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ElinkConfig;
|
||||
|
||||
public class AsyncLoggingPoolManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static AsyncLoggingPoolManager instance;
|
||||
|
||||
private static boolean stopped = true;
|
||||
|
||||
private int maxPoolSize = 10;
|
||||
private int initPoolSize = 8;
|
||||
|
||||
private boolean initOnStartup = true;
|
||||
|
||||
private ObjectPool<LoggingPoolObject> pool = null;
|
||||
|
||||
/**
|
||||
* 기동 여부
|
||||
*/
|
||||
private boolean started;
|
||||
|
||||
/**
|
||||
* LifeccyleSupport object
|
||||
*/
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
public static synchronized AsyncLoggingPoolManager getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new AsyncLoggingPoolManager();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return maxPoolSize;
|
||||
}
|
||||
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
}
|
||||
|
||||
public int getInitPoolSize() {
|
||||
return initPoolSize;
|
||||
}
|
||||
|
||||
public void setInitPoolSize(int initPoolSize) {
|
||||
this.initPoolSize = initPoolSize;
|
||||
}
|
||||
|
||||
public boolean isInitOnStartup() {
|
||||
return initOnStartup;
|
||||
}
|
||||
|
||||
public void setInitOnStartup(boolean initOnStartup) {
|
||||
this.initOnStartup = initOnStartup;
|
||||
}
|
||||
|
||||
public void publish(EAIMessage message, Properties prop) throws Exception {
|
||||
LoggingPoolObject queue = null;
|
||||
try {
|
||||
queue = borrowObject();
|
||||
queue.putMessage(message, prop);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.error("publish failed.", ex);
|
||||
throw ex;
|
||||
}
|
||||
finally {
|
||||
if(queue != null) returnObject(queue);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if(pool != null) shutdown();
|
||||
maxPoolSize = ElinkConfig.getAsyncPoolMaxSize();
|
||||
initPoolSize = ElinkConfig.getAsyncPoolInitSize();
|
||||
initOnStartup = ElinkConfig.isAsyncInitOnstartup();
|
||||
|
||||
if(logger.isWarn()) {
|
||||
logger.warn("<< init start - maxPoolSize = {}, initPoolSize = {}, initOnStartup = {}", maxPoolSize, initPoolSize, initOnStartup);
|
||||
}
|
||||
@SuppressWarnings("rawtypes")
|
||||
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
|
||||
LoggingPoolObjectFactory factory = new LoggingPoolObjectFactory();
|
||||
|
||||
config.setMaxTotal(maxPoolSize);
|
||||
//config.setMinIdle(maxPoolSize); // default: 0
|
||||
//config.setMaxIdle(maxPoolSize); // default: 8
|
||||
config.setMaxWait(Duration.ofSeconds(5));
|
||||
// add proper config options
|
||||
// config.setLifo(true);
|
||||
pool = new GenericObjectPool<LoggingPoolObject>(factory, config);
|
||||
|
||||
if(initOnStartup) {
|
||||
LoggingPoolObject[] pools = new LoggingPoolObject[initPoolSize];
|
||||
for(int i=0; i<initPoolSize; i++) {
|
||||
try {
|
||||
logger.warn(">> borrowObject LoggingPoolObject-"+ i);
|
||||
pools[i] = pool.borrowObject();
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
for(int i=0; i<initPoolSize; i++) {
|
||||
try {
|
||||
logger.warn("<< returnObject LoggingPoolObject-"+ i);
|
||||
pool.returnObject(pools[i]);
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
stopped = false;
|
||||
logger.warn("<< init end");
|
||||
}
|
||||
|
||||
public LoggingPoolObject borrowObject() throws Exception {
|
||||
if(stopped) throw new PoolShutdownException();
|
||||
return pool.borrowObject();
|
||||
}
|
||||
|
||||
public void returnObject(LoggingPoolObject object) throws Exception {
|
||||
if(stopped) throw new PoolShutdownException();
|
||||
pool.returnObject(object);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if(logger.isWarn()) {
|
||||
logger.warn("<< shutdown start");
|
||||
}
|
||||
int retry = 0;
|
||||
|
||||
try {
|
||||
if(pool != null) {
|
||||
while(true) {
|
||||
pool.close();
|
||||
logger.warn("close pool.getNumActive() = "+pool.getNumActive());
|
||||
if(pool.getNumActive() == 0 || retry > 10) break;
|
||||
logger.warn("close - sleep 100ms");
|
||||
Thread.sleep(100);
|
||||
retry++;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("shutdown failed.", e);
|
||||
}
|
||||
finally {
|
||||
stopped = true;
|
||||
pool = null;
|
||||
}
|
||||
logger.warn(">> shutdown end");
|
||||
}
|
||||
@Override
|
||||
public void addLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.addLifecycleListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LifecycleListener[] findLifecycleListeners() {
|
||||
return lifecycle.findLifecycleListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLifecycleListener(LifecycleListener listener) {
|
||||
lifecycle.removeLifecycleListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICRT201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
// init pool & disruptor component
|
||||
init();
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICRT203");
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
shutdown();
|
||||
started = false;
|
||||
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
return this.started;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.eactive.eai.common.logger.EAILogException;
|
||||
import com.eactive.eai.common.logger.EAILogSender;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.lmax.disruptor.EventHandler;
|
||||
|
||||
public class CustomEventHandler implements EventHandler<LoggingEvent> {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
String name;
|
||||
int sleepMs;
|
||||
private int batchSize = 1;
|
||||
|
||||
private int count = 0;
|
||||
private final List<LoggingEvent> eventList = new ArrayList<>();
|
||||
|
||||
public CustomEventHandler() {
|
||||
}
|
||||
|
||||
public CustomEventHandler(String name, int sleepMs, int batchSize) {
|
||||
this.name = name;
|
||||
this.sleepMs = sleepMs;
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(LoggingEvent event, long sequence, boolean endOfBatch) throws Exception {
|
||||
if(sleepMs > 0) Thread.sleep(sleepMs);
|
||||
if(batchSize > 1) {
|
||||
eventList.add(event);
|
||||
if (++count >= batchSize) {
|
||||
processBatch();
|
||||
eventList.clear();
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
EAIMessage message = event.getMessage();
|
||||
if(logger.isInfo()) {
|
||||
logger.info(String.format("CustomWorkHandler: %s LoggingEvent: %s %s\n"
|
||||
,name, message.getSvcOgNo() ,message.getLogPssSno())
|
||||
);
|
||||
}
|
||||
EAILogSender.logDirect(event.getMessage(), event.getProperty());
|
||||
if(event != null) {
|
||||
event.clear();
|
||||
event = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processBatch() throws EAILogException {
|
||||
for(LoggingEvent event:eventList) {
|
||||
EAILogSender.logDirect(event.getMessage(), event.getProperty());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
public class CustomThreadFactory implements ThreadFactory {
|
||||
// stores the thread count
|
||||
private int count = 0;
|
||||
|
||||
// returns the thread count
|
||||
public int getCount() { return count; }
|
||||
|
||||
// Factory method
|
||||
@Override
|
||||
public Thread newThread(Runnable command) {
|
||||
count++;
|
||||
// System.out.println( String.format(">> newThread-%d created", count) );
|
||||
return new Thread(command);
|
||||
}
|
||||
|
||||
public CustomThreadFactory() {
|
||||
// empty
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.eactive.eai.common.logger.EAILogException;
|
||||
import com.eactive.eai.common.logger.EAILogSender;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.lmax.disruptor.WorkHandler;
|
||||
|
||||
public class CustomWorkHandler implements WorkHandler<LoggingEvent> {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
String name;
|
||||
int sleepMs;
|
||||
private int batchSize = 1;
|
||||
|
||||
private int count = 0;
|
||||
private final List<LoggingEvent> eventList = new ArrayList<>();
|
||||
|
||||
public CustomWorkHandler() {
|
||||
}
|
||||
|
||||
public CustomWorkHandler(String name, int sleepMs, int batchSize) {
|
||||
this.name = name;
|
||||
this.sleepMs = sleepMs;
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(LoggingEvent event) throws Exception {
|
||||
if(sleepMs > 0) Thread.sleep(sleepMs);
|
||||
if(batchSize > 1) {
|
||||
eventList.add(event);
|
||||
if (++count >= batchSize) {
|
||||
processBatch();
|
||||
eventList.clear();
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
EAIMessage message = event.getMessage();
|
||||
if(logger.isInfo()) {
|
||||
logger.info(String.format("CustomWorkHandler: %s LoggingEvent: %s %s\n"
|
||||
,name, message.getSvcOgNo() ,message.getLogPssSno())
|
||||
);
|
||||
}
|
||||
EAILogSender.logDirect(event.getMessage(), event.getProperty());
|
||||
if(event != null) {
|
||||
event.clear();
|
||||
event = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void processBatch() throws EAILogException {
|
||||
for(LoggingEvent event:eventList) {
|
||||
EAILogSender.logDirect(event.getMessage(), event.getProperty());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import com.eactive.eai.common.property.PropManager;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.common.util.LogKeys;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraHeader;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
public class HttpAdapterExtraLogH2Factory {
|
||||
private SessionFactory sessionFactory ;
|
||||
private HikariDataSource dataSource;
|
||||
|
||||
private static HttpAdapterExtraLogH2Factory httpAdapterExtraLogH2Factory = new HttpAdapterExtraLogH2Factory();
|
||||
|
||||
private HttpAdapterExtraLogH2Factory(){
|
||||
sessionFactory = buildSessionFactory();
|
||||
}
|
||||
|
||||
public static HttpAdapterExtraLogH2Factory getInstance(){
|
||||
return httpAdapterExtraLogH2Factory;
|
||||
}
|
||||
|
||||
private SessionFactory buildSessionFactory() {
|
||||
try {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
|
||||
configuration.setProperty("hibernate.hbm2ddl.auto", "update");
|
||||
configuration.setProperty("hibernate.show_sql", "true");
|
||||
configuration.setProperty("hibernate.format_sql", "true");
|
||||
configuration.setProperty("hibernate.use_sql_comments", "true");
|
||||
configuration.setProperty("hibernate.auto_quote_keyword", "true");
|
||||
configuration.setProperty("hibernate.globally_quoted_identifiers", "true");
|
||||
|
||||
String logBaseDirectory = PropManager.getInstance().getProperty(LogKeys.LOGGER_INFO, LogKeys.LOG_DIRECOTRY_PREFIX);
|
||||
String localServer = EAIServerManager.getInstance().getLocalServerName();
|
||||
String serverLogPath = FilenameUtils.concat(logBaseDirectory, localServer);
|
||||
makeDirs(serverLogPath);
|
||||
String httpLogDbFilePath = FilenameUtils.concat(serverLogPath, "http_log");
|
||||
httpLogDbFilePath = httpLogDbFilePath.replace("\\", "/");
|
||||
// HikariCP 설정
|
||||
HikariConfig hikariConfig = new HikariConfig();
|
||||
hikariConfig.setDriverClassName("org.h2.Driver");
|
||||
hikariConfig.setJdbcUrl("jdbc:h2:file:"+httpLogDbFilePath);
|
||||
hikariConfig.setUsername("sa");
|
||||
hikariConfig.setPassword("");
|
||||
hikariConfig.setMaximumPoolSize(20);
|
||||
hikariConfig.setMinimumIdle(5);
|
||||
hikariConfig.setIdleTimeout(300000);
|
||||
hikariConfig.setMaxLifetime(600000);
|
||||
|
||||
dataSource = new HikariDataSource(hikariConfig);
|
||||
configuration.getProperties().put("hibernate.connection.datasource", dataSource);
|
||||
|
||||
// 엔티티 클래스 추가
|
||||
configuration.addAnnotatedClass(HttpAdapterExtraLog.class);
|
||||
configuration.addAnnotatedClass(HttpAdapterExtraHeader.class);
|
||||
|
||||
return configuration.buildSessionFactory();
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
throw new ExceptionInInitializerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Session openSession(){
|
||||
if(sessionFactory == null || sessionFactory.isClosed()){
|
||||
sessionFactory = buildSessionFactory();
|
||||
}
|
||||
return sessionFactory.openSession();
|
||||
}
|
||||
|
||||
public void closeSessionFactory() {
|
||||
if (sessionFactory != null && !sessionFactory.isClosed()) {
|
||||
sessionFactory.close();
|
||||
sessionFactory = null;
|
||||
}
|
||||
if (dataSource != null && dataSource instanceof HikariDataSource) {
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static void makeDirs(String path) throws Exception{
|
||||
File directory = new File(path);
|
||||
|
||||
if (directory.exists()){
|
||||
return;
|
||||
}
|
||||
|
||||
Stack<File> stack = new Stack<File>();
|
||||
//check
|
||||
File p = directory;
|
||||
stack.push(p);
|
||||
while (true){
|
||||
p = p.getParentFile();
|
||||
if (p.exists()){
|
||||
break;
|
||||
}else{
|
||||
stack.push(p);
|
||||
}
|
||||
}
|
||||
while(!stack.empty()){
|
||||
File s = stack.pop();
|
||||
s.mkdir();
|
||||
//그룹까지 rwx로 권한이 필요한 경우가 많음 필요 시 수정 할 것
|
||||
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxr-x");
|
||||
Files.setPosixFilePermissions(s.toPath(), perms);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
|
||||
import com.lmax.disruptor.EventFactory;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HttpLoggingEvent {
|
||||
private HttpAdapterExtraLogVo httpAdapterExtraLogVo;
|
||||
|
||||
public final static EventFactory<HttpLoggingEvent> EVENT_FACTORY = new EventFactory<HttpLoggingEvent>() {
|
||||
public HttpLoggingEvent newInstance() {
|
||||
return new HttpLoggingEvent();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ConfigKeys;
|
||||
import com.lmax.disruptor.*;
|
||||
import com.lmax.disruptor.dsl.Disruptor;
|
||||
import com.lmax.disruptor.dsl.ProducerType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class HttpLoggingPoolObject {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
Disruptor<HttpLoggingEvent> disruptor = null;
|
||||
RingBuffer<HttpLoggingEvent> ringBuffer = null;
|
||||
int id = 0;
|
||||
int queueMax = (int)Math.pow(2, 10);
|
||||
int workerSize = 0;
|
||||
|
||||
public HttpLoggingPoolObject() {
|
||||
|
||||
}
|
||||
|
||||
private WaitStrategy getWaitStrategy(String waitStrategy) {
|
||||
WaitStrategy ws = null;
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_BLOCK.equals(waitStrategy)) {
|
||||
// throughput and low-latency are not as important as CPU resource
|
||||
return new BlockingWaitStrategy();
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_SLEEP.equals(waitStrategy)) {
|
||||
// default : 200, 100ns
|
||||
// return new SleepingWaitStrategy();
|
||||
// default : 200, 10 ms
|
||||
return new SleepingWaitStrategy(200, 10 * 1000000);
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_TIME.equals(waitStrategy)) {
|
||||
// 100ms
|
||||
return new TimeoutBlockingWaitStrategy(100 * 1000, TimeUnit.MICROSECONDS);
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_BUSYSPIN.equals(waitStrategy)) {
|
||||
// when threads can be bound to specific CPU cores.
|
||||
return new BusySpinWaitStrategy();
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_YIELD.equals(waitStrategy)) {
|
||||
return new YieldingWaitStrategy();
|
||||
}
|
||||
return ws;
|
||||
}
|
||||
|
||||
public HttpLoggingPoolObject(int id, int queueSize, int workerSize, String waitStrategy) {
|
||||
this.id = id;
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(String.format(">> Disruptor-%d queueSize = %d", id, queueSize));
|
||||
logger.warn(String.format(">> Disruptor-%d workerSize = %d", id, workerSize));
|
||||
logger.warn(String.format(">> Disruptor-%d waitStrategy = %s", id, waitStrategy));
|
||||
}
|
||||
CustomThreadFactory tFactory = new CustomThreadFactory();
|
||||
|
||||
disruptor = new Disruptor<HttpLoggingEvent>(HttpLoggingEvent.EVENT_FACTORY, queueSize, tFactory,
|
||||
ProducerType.SINGLE,
|
||||
getWaitStrategy(waitStrategy));
|
||||
// BlockingWaitStrategy | SleepingWaitStrategy | YieldingWaitStrategy | BusySpinWaitStrategy
|
||||
WorkHandler<HttpLoggingEvent>[] handlers = new WorkHandler[workerSize];
|
||||
for(int i=0; i< handlers.length; i++) {
|
||||
WorkHandler handler = new HttpLoggingWorkHandler();
|
||||
handlers[i] = handler;
|
||||
}
|
||||
disruptor.handleEventsWithWorkerPool(handlers);
|
||||
|
||||
try {
|
||||
|
||||
logger.warn(String.format(">> disruptor-%d.start",id));
|
||||
disruptor.start();
|
||||
ringBuffer = disruptor.getRingBuffer();
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public void putMessage(HttpAdapterExtraLogVo httpAdapterExtraLogVo) {
|
||||
long seq = ringBuffer.next();
|
||||
try {
|
||||
if(logger.isDebug()) {
|
||||
logger.debug( String.format("disruptor-%d publish : ringBuffer seq = %d uuid=%s",id, seq, httpAdapterExtraLogVo.getGuid()) );
|
||||
}
|
||||
HttpLoggingEvent httpLoggingEvent = ringBuffer.get(seq);
|
||||
httpLoggingEvent.setHttpAdapterExtraLogVo(httpAdapterExtraLogVo);
|
||||
}
|
||||
finally {
|
||||
ringBuffer.publish(seq);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if(disruptor == null) return;
|
||||
while(true) {
|
||||
if(queueMax == disruptor.getRingBuffer().remainingCapacity()) break;
|
||||
try {
|
||||
logger.warn(String.format("disruptor-%d Sleep 100 ms.", id));
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(String.format("<< disruptor-%d shutdown remainingCapacity : %d",id, disruptor.getRingBuffer().remainingCapacity()) );
|
||||
}
|
||||
if(disruptor !=null) disruptor.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ElinkConfig;
|
||||
import org.apache.commons.pool2.BasePooledObjectFactory;
|
||||
import org.apache.commons.pool2.PooledObject;
|
||||
import org.apache.commons.pool2.impl.DefaultPooledObject;
|
||||
|
||||
public class HttpLoggingPoolObjectFactory extends BasePooledObjectFactory<HttpLoggingPoolObject> {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static int i = 0;
|
||||
public HttpLoggingPoolObjectFactory() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpLoggingPoolObject create() throws Exception {
|
||||
int queueSize = ElinkConfig.getAsyncQueueSize();
|
||||
int workers = ElinkConfig.getAsyncWorkers();
|
||||
String waitStrategy = ElinkConfig.getWaitStrategy();
|
||||
return new HttpLoggingPoolObject(i++, queueSize, workers, waitStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PooledObject<HttpLoggingPoolObject> wrap(HttpLoggingPoolObject object) {
|
||||
return new DefaultPooledObject<>(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passivateObject(PooledObject<HttpLoggingPoolObject> pooledObject) {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyObject(PooledObject<HttpLoggingPoolObject> pooledObject) {
|
||||
HttpLoggingPoolObject loggingPoolObject = pooledObject.getObject();
|
||||
if(logger.isWarn()) {
|
||||
logger.warn("destroyObject - {}", loggingPoolObject.toString());
|
||||
}
|
||||
loggingPoolObject.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import com.eactive.eai.common.logger.HttpLoggingService;
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.lmax.disruptor.WorkHandler;
|
||||
|
||||
public class HttpLoggingWorkHandler implements WorkHandler<HttpLoggingEvent> {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
@Override
|
||||
public void onEvent(HttpLoggingEvent httpLoggingEvent) throws Exception {
|
||||
HttpLoggingService service = ApplicationContextProvider.getContext().getBean(HttpLoggingService.class);
|
||||
try {
|
||||
service.insertHttpAdapterExtraLog( httpLoggingEvent.getHttpAdapterExtraLogVo());
|
||||
} catch (Throwable th) {
|
||||
logger.error("failed to insert async http log ", th);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.lmax.disruptor.EventFactory;
|
||||
|
||||
public class LoggingEvent {
|
||||
EAIMessage message;
|
||||
Properties prop;
|
||||
|
||||
public EAIMessage getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(EAIMessage message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Properties getProperty() {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public void setProperty(Properties prop) {
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if(this.message != null) {
|
||||
this.message.clear();
|
||||
}
|
||||
this.message = null;
|
||||
this.prop = null;
|
||||
}
|
||||
|
||||
public final static EventFactory<LoggingEvent> EVENT_FACTORY = new EventFactory<LoggingEvent>() {
|
||||
public LoggingEvent newInstance() {
|
||||
return new LoggingEvent();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.eactive.eai.common.message.EAIMessage;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ConfigKeys;
|
||||
import com.lmax.disruptor.BlockingWaitStrategy;
|
||||
import com.lmax.disruptor.BusySpinWaitStrategy;
|
||||
import com.lmax.disruptor.RingBuffer;
|
||||
import com.lmax.disruptor.SleepingWaitStrategy;
|
||||
import com.lmax.disruptor.TimeoutBlockingWaitStrategy;
|
||||
import com.lmax.disruptor.WaitStrategy;
|
||||
import com.lmax.disruptor.WorkHandler;
|
||||
import com.lmax.disruptor.YieldingWaitStrategy;
|
||||
import com.lmax.disruptor.dsl.Disruptor;
|
||||
import com.lmax.disruptor.dsl.ProducerType;
|
||||
|
||||
public class LoggingPoolObject {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
Disruptor<LoggingEvent> disruptor = null;
|
||||
RingBuffer<LoggingEvent> ringBuffer = null;
|
||||
int id = 0;
|
||||
int queueMax = (int)Math.pow(2, 10);
|
||||
int workerSize = 0;
|
||||
|
||||
public LoggingPoolObject() {
|
||||
|
||||
}
|
||||
|
||||
private WaitStrategy getWaitStrategy(String waitStrategy) {
|
||||
WaitStrategy ws = null;
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_BLOCK.equals(waitStrategy)) {
|
||||
// throughput and low-latency are not as important as CPU resource
|
||||
return new BlockingWaitStrategy();
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_SLEEP.equals(waitStrategy)) {
|
||||
// default : 200, 100ns
|
||||
// return new SleepingWaitStrategy();
|
||||
// default : 200, 10 ms
|
||||
return new SleepingWaitStrategy(200, 10 * 1000000);
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_TIME.equals(waitStrategy)) {
|
||||
// 100ms
|
||||
return new TimeoutBlockingWaitStrategy(100 * 1000, TimeUnit.MICROSECONDS);
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_BUSYSPIN.equals(waitStrategy)) {
|
||||
// when threads can be bound to specific CPU cores.
|
||||
return new BusySpinWaitStrategy();
|
||||
}
|
||||
if(ConfigKeys.LOGGER_ASYNC_WAITSTRATEGY_YIELD.equals(waitStrategy)) {
|
||||
return new YieldingWaitStrategy();
|
||||
}
|
||||
return ws;
|
||||
}
|
||||
|
||||
public LoggingPoolObject(int id, int queueSize, int workerSize, String waitStrategy) {
|
||||
this.id = id;
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(String.format(">> Disruptor-%d queueSize = %d", id, queueSize));
|
||||
logger.warn(String.format(">> Disruptor-%d workerSize = %d", id, workerSize));
|
||||
logger.warn(String.format(">> Disruptor-%d waitStrategy = %s", id, waitStrategy));
|
||||
}
|
||||
CustomThreadFactory tFactory = new CustomThreadFactory();
|
||||
|
||||
disruptor = new Disruptor<LoggingEvent>(LoggingEvent.EVENT_FACTORY, queueSize, tFactory,
|
||||
ProducerType.SINGLE,
|
||||
getWaitStrategy(waitStrategy));
|
||||
// BlockingWaitStrategy | SleepingWaitStrategy | YieldingWaitStrategy | BusySpinWaitStrategy
|
||||
if(workerSize > 1) {
|
||||
WorkHandler<LoggingEvent>[] handlers = new WorkHandler[workerSize];
|
||||
for(int i=0; i< handlers.length; i++) {
|
||||
// TODO : 현재는 delay 없이 처리하도록 하고, 추후 DB부하를 줄이려면 sleep을 정의.
|
||||
CustomWorkHandler handler = new CustomWorkHandler(String.format("CustomWorkHandler%d-%d",id, i), 0, 1);
|
||||
handlers[i] = handler;
|
||||
}
|
||||
disruptor.handleEventsWithWorkerPool(handlers);
|
||||
}
|
||||
else {
|
||||
CustomEventHandler handler = new CustomEventHandler(String.format("CustomEventHandler%d-%d",id, 0), 0, 1);
|
||||
disruptor.handleEventsWith(handler);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
logger.warn(String.format(">> disruptor-%d.start",id));
|
||||
disruptor.start();
|
||||
ringBuffer = disruptor.getRingBuffer();
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public void putMessage(EAIMessage message, Properties prop) {
|
||||
long seq = ringBuffer.next();
|
||||
try {
|
||||
if(logger.isDebug()) {
|
||||
logger.debug( String.format("disruptor-%d publish : ringBuffer seq = %d uuid=%s logSeq=%s",id, seq, message.getSvcOgNo() ,message.getLogPssSno()) );
|
||||
}
|
||||
LoggingEvent loggingEvent = ringBuffer.get(seq);
|
||||
loggingEvent.setMessage(message);
|
||||
loggingEvent.setProperty(prop);
|
||||
}
|
||||
finally {
|
||||
ringBuffer.publish(seq);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
if(disruptor == null) return;
|
||||
while(true) {
|
||||
if(queueMax == disruptor.getRingBuffer().remainingCapacity()) break;
|
||||
try {
|
||||
logger.warn(String.format("disruptor-%d Sleep 100 ms.", id));
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
if(logger.isWarn()) {
|
||||
logger.warn(String.format("<< disruptor-%d shutdown remainingCapacity : %d",id, disruptor.getRingBuffer().remainingCapacity()) );
|
||||
}
|
||||
if(disruptor !=null) disruptor.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
import org.apache.commons.pool2.BasePooledObjectFactory;
|
||||
import org.apache.commons.pool2.PooledObject;
|
||||
import org.apache.commons.pool2.impl.DefaultPooledObject;
|
||||
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.env.ElinkConfig;
|
||||
|
||||
public class LoggingPoolObjectFactory extends BasePooledObjectFactory<LoggingPoolObject> {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
private static int i = 0;
|
||||
public LoggingPoolObjectFactory() {
|
||||
// empty
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoggingPoolObject create() throws Exception {
|
||||
int queueSize = ElinkConfig.getAsyncQueueSize();
|
||||
int workers = ElinkConfig.getAsyncWorkers();
|
||||
String waitStrategy = ElinkConfig.getWaitStrategy();
|
||||
return new LoggingPoolObject(i++, queueSize, workers, waitStrategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PooledObject<LoggingPoolObject> wrap(LoggingPoolObject object) {
|
||||
return new DefaultPooledObject<>(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passivateObject(PooledObject<LoggingPoolObject> pooledObject) {
|
||||
// empty
|
||||
}
|
||||
@Override
|
||||
public void destroyObject(PooledObject<LoggingPoolObject> pooledObject) {
|
||||
LoggingPoolObject loggingPoolObject = pooledObject.getObject();
|
||||
if(logger.isWarn()) {
|
||||
logger.warn("destroyObject - {}", loggingPoolObject.toString());
|
||||
}
|
||||
loggingPoolObject.shutdown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.eactive.eai.common.logger.async;
|
||||
|
||||
public class PoolShutdownException extends Exception {
|
||||
|
||||
public PoolShutdownException() {
|
||||
super("pool is shutdown already.");
|
||||
}
|
||||
|
||||
public PoolShutdownException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PoolShutdownException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public PoolShutdownException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public PoolShutdownException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.eactive.eai.common.logger.mapper;
|
||||
|
||||
import com.eactive.eai.common.logger.HttpAdapterExtraHeaderVo;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraHeader;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface HttpAdapterExtraHeaderMapper extends GenericMapper<HttpAdapterExtraHeaderVo, HttpAdapterExtraHeader> {
|
||||
|
||||
@Override
|
||||
@Mapping(source = "id.name", target = "name")
|
||||
HttpAdapterExtraHeaderVo toVo(HttpAdapterExtraHeader entity);
|
||||
|
||||
@Override
|
||||
@InheritInverseConfiguration
|
||||
HttpAdapterExtraHeader toEntity(HttpAdapterExtraHeaderVo vo);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger.mapper;
|
||||
|
||||
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraHeaderId;
|
||||
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
import org.mapstruct.*;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class, uses = HttpAdapterExtraHeaderMapper.class)
|
||||
public interface HttpAdapterExtraLogMapper extends GenericMapper<HttpAdapterExtraLogVo, HttpAdapterExtraLog> {
|
||||
|
||||
@Override
|
||||
@Mapping(source = "id.guid", target = "guid")
|
||||
@Mapping(source = "id.serviceProcessNumber", target = "serviceProcessNumber")
|
||||
HttpAdapterExtraLogVo toVo(HttpAdapterExtraLog entity);
|
||||
|
||||
@Override
|
||||
@InheritInverseConfiguration
|
||||
HttpAdapterExtraLog toEntity(HttpAdapterExtraLogVo vo);
|
||||
|
||||
@AfterMapping
|
||||
default void setHeaderIdAndWeekday(@MappingTarget HttpAdapterExtraLog entity, HttpAdapterExtraLogVo vo) {
|
||||
DayOfWeek dayOfWeek = LocalDate.now().getDayOfWeek(); // 현재 요일
|
||||
int dayOfWeekNumber = dayOfWeek.getValue() % 7 + 1; // 1 (일요일)부터 7 (토요일)까지
|
||||
entity.getId().setWeekday(dayOfWeekNumber);
|
||||
Optional.ofNullable(entity.getHeaderList())
|
||||
.ifPresent(headers -> headers.forEach(header -> {
|
||||
if (header.getId() == null) {
|
||||
header.setId(new HttpAdapterExtraHeaderId());
|
||||
}
|
||||
header.getId().setWeekday(dayOfWeekNumber);
|
||||
header.getId().setGuid(vo.getGuid());
|
||||
header.getId().setServiceProcessNumber(vo.getServiceProcessNumber());
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import com.eactive.eai.common.monitor.StatMonitorLogVO;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatAdapterLog;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface StatAdapterLogMapper extends GenericMapper<StatMonitorLogVO, StatAdapterLog> {
|
||||
|
||||
@Mapping(source = "id.baseymd", target = "ymd")
|
||||
@Mapping(source = "id.basehh", target = "hour")
|
||||
@Mapping(source = "id.basehhmm", target = "min")
|
||||
@Mapping(source = "id.eaibzwkdstcd", target = "bzwkDstcd")
|
||||
@Mapping(source = "id.eaisvcname", target = "svcName")
|
||||
@Mapping(source = "id.adptrbzwkgroupname", target = "key")
|
||||
@Mapping(source = "id.eaisevrinstncname", target = "sevrInstncName")
|
||||
@Mapping(source = "eaiprcssttmval", target = "prcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaipsvprcssttmval", target = "psvPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaitotalprcssttmval", target = "totalPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "wholprcssnoitm", target = "wholPrcssNoitm")
|
||||
@Mapping(source = "errznoitm", target = "errzNoitm")
|
||||
@Mapping(source = "toutnoitm", target = "toutNoitm")
|
||||
@Mapping(source = "nomalnoitm", target = "nomalNoitm")
|
||||
@Override
|
||||
StatMonitorLogVO toVo(StatAdapterLog entity);
|
||||
|
||||
@Named("devide")
|
||||
default Double devide(Double org) {
|
||||
return org / 1000;
|
||||
}
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
StatAdapterLog toEntity(StatMonitorLogVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.logger.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import com.eactive.eai.common.monitor.StatMonitorLogVO;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatLog;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface StatLogMapper extends GenericMapper<StatMonitorLogVO, StatLog> {
|
||||
|
||||
@Mapping(source = "id.baseymd", target = "ymd")
|
||||
@Mapping(source = "id.basehh", target = "hour")
|
||||
@Mapping(source = "id.basehhmm", target = "min")
|
||||
@Mapping(source = "id.eaibzwkdstcd", target = "bzwkDstcd")
|
||||
@Mapping(source = "id.eaisvcname", target = "svcName")
|
||||
@Mapping(source = "id.eaisevrinstncname", target = "sevrInstncName")
|
||||
@Mapping(source = "eaiprcssttmval", target = "prcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaipsvprcssttmval", target = "psvPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaitotalprcssttmval", target = "totalPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "wholprcssnoitm", target = "wholPrcssNoitm")
|
||||
@Mapping(source = "errznoitm", target = "errzNoitm")
|
||||
@Mapping(source = "toutnoitm", target = "toutNoitm")
|
||||
@Mapping(source = "nomalnoitm", target = "nomalNoitm")
|
||||
@Override
|
||||
StatMonitorLogVO toVo(StatLog entity);
|
||||
|
||||
@Named("devide")
|
||||
default Double devide(Double org) {
|
||||
return org / 1000;
|
||||
}
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
StatLog toEntity(StatMonitorLogVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.common.logger.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
|
||||
import com.eactive.eai.common.monitor.StatMonitorLogVO;
|
||||
import com.eactive.eai.data.entity.onl.logger.StatTranLog;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface StatTranLogMapper extends GenericMapper<StatMonitorLogVO, StatTranLog> {
|
||||
|
||||
@Mapping(source = "id.baseymd", target = "ymd")
|
||||
@Mapping(source = "id.basehh", target = "hour")
|
||||
@Mapping(source = "id.basehhmm", target = "min")
|
||||
@Mapping(source = "id.eaibzwkdstcd", target = "bzwkDstcd")
|
||||
@Mapping(source = "id.eaisvcname", target = "svcName")
|
||||
@Mapping(source = "id.intfacsendtrancd", target = "key")
|
||||
@Mapping(source = "id.eaisevrinstncname", target = "sevrInstncName")
|
||||
@Mapping(source = "eaiprcssttmval", target = "prcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaipsvprcssttmval", target = "psvPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "eaitotalprcssttmval", target = "totalPrcssTtmVal", qualifiedByName = "devide")
|
||||
@Mapping(source = "wholprcssnoitm", target = "wholPrcssNoitm")
|
||||
@Mapping(source = "errznoitm", target = "errzNoitm")
|
||||
@Mapping(source = "toutnoitm", target = "toutNoitm")
|
||||
@Mapping(source = "nomalnoitm", target = "nomalNoitm")
|
||||
@Override
|
||||
StatMonitorLogVO toVo(StatTranLog entity);
|
||||
|
||||
@Named("devide")
|
||||
default Double devide(Double org) {
|
||||
return org / 1000;
|
||||
}
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Override
|
||||
StatTranLog toEntity(StatMonitorLogVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
public interface AdapterType {
|
||||
// SNA Response
|
||||
public static final String SNAR = "SNAR";
|
||||
|
||||
// SNA No Response
|
||||
public static final String SNAN = "SNAN";
|
||||
|
||||
// SNA Unsolicited
|
||||
public static final String SNAU = "SNAU";
|
||||
|
||||
// IMS
|
||||
public static final String IMSR = "IMSR";
|
||||
|
||||
// Socket Sync
|
||||
public static final String SCKR = "SCKR";
|
||||
|
||||
// Socket Async
|
||||
public static final String SCKN = "SCKN";
|
||||
|
||||
// MQ
|
||||
public static final String MQIN = "MQIN";
|
||||
|
||||
// TUXEDO
|
||||
public static final String TUXR = "TUXR";
|
||||
|
||||
// EJB
|
||||
public static final String EJBR = "EJBR";
|
||||
|
||||
// HTTP
|
||||
public static final String HTTP = "HTTP";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CondPerRtgInfo implements Serializable {
|
||||
|
||||
private String ruleGrpNm; // 규칙필드그룹명[TSEAIFR01.RuleFldGroupName] - RuleGroupName
|
||||
private String ruleColNm; // 규칙필드명[TSEAIFR01.RuleFldName] - RuleColumnName
|
||||
private String ruleCprTxt; // 비교내용[TSEAIFR01.CmprCtnt] - ServiceTimeExistenceOrNot - [Y|N]
|
||||
|
||||
private String rsultPrcssNo; // 결과처리번호[TSEAIFR01.RsultPrcssNo] - ResultProcessNumber
|
||||
|
||||
public CondPerRtgInfo() {
|
||||
}
|
||||
|
||||
public CondPerRtgInfo(String rsultPrcssNo, String ruleGrpNm, String ruleColNm, String ruleCprTxt) {
|
||||
this.rsultPrcssNo = rsultPrcssNo;
|
||||
this.ruleGrpNm = ruleGrpNm;
|
||||
this.ruleColNm = ruleColNm;
|
||||
this.ruleCprTxt = ruleCprTxt;
|
||||
}
|
||||
|
||||
public void setRuleGrpNm(String ruleGrpNm) {
|
||||
this.ruleGrpNm = ruleGrpNm;
|
||||
}
|
||||
|
||||
public String getRuleGrpNm() {
|
||||
return this.ruleGrpNm;
|
||||
}
|
||||
|
||||
public void setRuleColNm(String ruleColNm) {
|
||||
this.ruleColNm = ruleColNm;
|
||||
}
|
||||
|
||||
public String getRuleColNm() {
|
||||
return this.ruleColNm;
|
||||
}
|
||||
|
||||
public void setRuleCprTxt(String ruleCprTxt) {
|
||||
this.ruleCprTxt = ruleCprTxt;
|
||||
}
|
||||
|
||||
public String getRuleCprTxt() {
|
||||
return this.ruleCprTxt;
|
||||
}
|
||||
|
||||
public String getRsultPrcssNo() {
|
||||
return this.rsultPrcssNo;
|
||||
}
|
||||
|
||||
public void setRsultPrcssNo(String rsultPrcssNo) {
|
||||
this.rsultPrcssNo = rsultPrcssNo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,662 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.message.service.InterfaceMapper;
|
||||
import com.ext.eai.common.stdmessage.STDMessageKeys;
|
||||
|
||||
public class EAIMessage implements EAIMessageKeys, Serializable, Comparable<EAIMessage>, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String eaiSvrInstNm; // EAI서버인스턴스명[Runtime 정보] - EAIServerInstanceName
|
||||
private String eaiSvcCd; // EAI서비스명[TSEAIHE01.EAISvcName] - EAIServiceCode
|
||||
private String svcTmEn; // 서비스시각유무[TSEAIHE01.SvcHMSEonot] - ServiceTimeExistenceOrNot - [Y|N]
|
||||
private String svcOgNo; // 서비스고유번호 - ServiceOriginNumber - [UUID]
|
||||
private String svcTsmtUsgTp; // 서비스동기사용구분코드[TSEAIHE01.SvcMotivUseDstcd] - ServiceTheSameTimeUsgaeType - [SYNC|ASYN|AKON]
|
||||
private String svcPssTp; // 서비스프로세스구분명[TSEAIHE01.SvcPrcesDsticName] - ServiceProcessType - [SINGLE|COMPLEX|PCOMPLEX]
|
||||
private String flwCntlRtnNm; // 흐름통제라우팅명[TSEAIHE01.FlowCtrlRoutName] - FlowControlRoutingName
|
||||
private String unifTp; // 통합구분명[TSEAIHE01.IntgraDsticName] - UnificationType - [ONLINE|BATCH|FTP]
|
||||
private String sngSvcCls; // 기동서비스구분 - StartingServiceClassification - [TIMER|EXCEPTION]
|
||||
private int svcPssSeq = 1; // 서비스처리순서 - ServiceProcessSequence - [1,2,3, etc]
|
||||
private int logPssSno; // 로그처리일련번호 - LogProcessSequenceNUmber - [100,200,300,400 | 100,211,212,221,222,...,400]
|
||||
private String svcWlColLogYn; // 서비스전컬럼로그여부[TSEAIHE01.SvcBfClmnLogYn] - ServiceWholeColumnLogYesOrNo - [Y|N]
|
||||
private String internalExternalDvcd; // 서비스전컬럼로그여부[TSEAIHE01.internalExternalDvcd] - [1|2]
|
||||
private String bwkCls; // EAI업무구분코드[TSEAIHE01.EAIBzwkDstcd] - BusinessWorkClassification - 3|4자리 KB표준업무구분코드 사용
|
||||
private String stdMsgUsgCls; // 표준메시지사용구분[Runtime 정보] - StandardMessageUsageClassification - [Y|N]
|
||||
private String sngSysItfTp; // 기동시스템어댑터업무그룹명[TSEAIHE01.GstatSysAdptrBzwkGroupName] - StartingSystemInterfaceType - [Adapter_업무명_IN]
|
||||
private String lydMsgID; // 레이어메시지ID - vlf
|
||||
private String rspErrCd; // 응답에러코드 - ResponseErrorCode - [12 BYTE EAI에러코드]
|
||||
private String rspErrMsg; // 응답에러메시지 - ResponseErrorMessage - [ 200 BYTE ]
|
||||
private long msgRcvTm; // 메시지수신시각 - MessageReceiveTime - RequestProcessor에서 설정한다.
|
||||
private long msgPssTm; // 메시지처리시각 - MessageProcessTime - LOGGER에서 로깅전 설정한다. Queue로 Push하기전에...
|
||||
private int svrLogLvl; // 서버로그레벨번호[TSEAIHE01.SevrLogLvelNo] - ServerLogLevel - DEFAULT(WARNING, ERROR, FATAL)-0, INFO-1, DEBUG-2
|
||||
private int svcLogLvl; // 서비스로그레벨번호[TSEAIHE01.SvcLogLvelNo] - ServiceLogLevel - [0|1|2|3]
|
||||
private List<ServiceMessage> svcMsgs; // 서비스처리정보리스트-ArrayList
|
||||
|
||||
private InterfaceMapper mapper;
|
||||
private StandardMessage standardMessage;
|
||||
private StandardMessage subMessage;
|
||||
|
||||
private String errEAISvcName; //오류EAI서비스명[TSEAIHE01.ErrEAISvcName] -ErrorEAIServiceName
|
||||
private String dmndErrChngIDName; //요청오류변환ID명[TSEAIHE01.DmndErrChngIDName] -RequestErrorConversionID
|
||||
private String dmndErrFldName; //요청에러필드명[TSEAIHE01.DmndErrFldName] -RequestErrorColumnName
|
||||
private String rspnsErrChngIDName; //응답오류변환ID명[TSEAIHE01.RspnsErrChngIDName] -ResponseErrorConversionID
|
||||
private String rspnsErrFldName; //응답에러필드명[TSEAIHE01.RspnsErrFldName] -ResponseErrorColumnName
|
||||
|
||||
private String eaiSvcDesc; //EAI서비스 설명 [ TSEAIHE01.EAISvcDesc]
|
||||
private String extBizCd; //대외업무구분코드[ TSEAIHE01.ExtBizCd] //경우에따라서는 다른컬럼이 아니라 인터페이스 앞3자리일수 있음 //TODO ※JBBEXT※ 인터페이스앞3자리
|
||||
|
||||
private String clientIp; // 요청 시스템 IP 주소
|
||||
|
||||
/**
|
||||
* EAI서버구분코드 (내부-1/대외-2/공동망-3/DMZ-4/OPEN-5)
|
||||
*/
|
||||
private String sevrDstcd;
|
||||
|
||||
/**
|
||||
* 그룹회사코드 (KB0/KC0)
|
||||
*/
|
||||
private String groupCoCd;
|
||||
|
||||
/**
|
||||
* 거래처리구분 (R 실제거래/T TAS/S EAI중단거래/F TAS 기동거래/D 더미단말거래 라우팅됨)
|
||||
*/
|
||||
private String tranType;
|
||||
|
||||
/**
|
||||
* 응답변환유형(0 기본응답변환, 1 에러응답변환)
|
||||
*/
|
||||
private String rspnsChngMsgType;
|
||||
|
||||
/**
|
||||
* 거래로그때문에 추가됨 로그용 휘발성 데이터 companyCode : 업체코드 splizLength : 전문길이 adptrInstiCode
|
||||
* : 어댑터기관코드명
|
||||
*
|
||||
*/
|
||||
private String companyCode;
|
||||
private int splizLength;
|
||||
private String adptrInstiCode;
|
||||
private String useYn;
|
||||
/**
|
||||
* NexCore 용 으로 인터페이스 조회시 참조 txid : 계정계 거래코드 refKey : 대외
|
||||
* 거래코드(대외업무구분코드+전문종별+거래구분코드+기타)
|
||||
*/
|
||||
private String txId; // 거래ID[ TSEAIHE01.TxId]
|
||||
private String refKey;// 참조KEY[ TSEAIHE01.RefKey]
|
||||
|
||||
/**
|
||||
* Open API 서비스시 client 별 통계용 추가
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
private String authType;
|
||||
|
||||
private String apiEnabledYn;
|
||||
|
||||
private String apiCacheYn;
|
||||
|
||||
private String apiCacheType;
|
||||
|
||||
private String authkeyfieldname;
|
||||
|
||||
private String authCheckdYn;
|
||||
|
||||
public EAIMessage() {
|
||||
this.svcMsgs = new ArrayList<>();
|
||||
this.svcPssSeq = 1;
|
||||
}
|
||||
|
||||
public String getBwkCls() {
|
||||
return bwkCls;
|
||||
}
|
||||
|
||||
public void setBwkCls(String bwkCls) {
|
||||
this.bwkCls = bwkCls;
|
||||
}
|
||||
|
||||
public String getEAISvcCd() {
|
||||
return eaiSvcCd;
|
||||
}
|
||||
|
||||
public void setEAISvcCd(String svcCd) {
|
||||
eaiSvcCd = svcCd;
|
||||
}
|
||||
|
||||
public String getEAISvrInstNm() {
|
||||
return eaiSvrInstNm;
|
||||
}
|
||||
|
||||
public void setEAISvrInstNm(String svrInstNm) {
|
||||
eaiSvrInstNm = svrInstNm;
|
||||
}
|
||||
|
||||
public String getFlwCntlRtnNm() {
|
||||
return flwCntlRtnNm;
|
||||
}
|
||||
|
||||
public void setFlwCntlRtnNm(String flwCntlRtnNm) {
|
||||
this.flwCntlRtnNm = flwCntlRtnNm;
|
||||
}
|
||||
|
||||
public int getLogPssSno() {
|
||||
return logPssSno;
|
||||
}
|
||||
|
||||
public void setLogPssSno(int logPssSno) {
|
||||
this.logPssSno = logPssSno;
|
||||
}
|
||||
|
||||
public String getLydMsgID() {
|
||||
return lydMsgID;
|
||||
}
|
||||
|
||||
public void setLydMsgID(String lydMsgID) {
|
||||
this.lydMsgID = lydMsgID;
|
||||
}
|
||||
|
||||
public long getMsgPssTm() {
|
||||
return msgPssTm;
|
||||
}
|
||||
|
||||
public void setMsgPssTm(long msgPssTm) {
|
||||
this.msgPssTm = msgPssTm;
|
||||
}
|
||||
|
||||
public long getMsgRcvTm() {
|
||||
return msgRcvTm;
|
||||
}
|
||||
|
||||
public void setMsgRcvTm(long msgRcvTm) {
|
||||
this.msgRcvTm = msgRcvTm;
|
||||
}
|
||||
|
||||
public String getRspErrCd() {
|
||||
return rspErrCd;
|
||||
}
|
||||
|
||||
public void setRspErrCd(String rspErrCd) {
|
||||
this.rspErrCd = rspErrCd;
|
||||
// --------------------------------------------
|
||||
// 에러메시지는 뒤의 9자리를 짤라서 설정한다.
|
||||
// 에러코드가 아닌경우에는 설정하지 않는다 (RE ,RF )
|
||||
// 2008.04.29
|
||||
// 2008.07.10 : 8자리로 수정
|
||||
// 'S9' + 뒤에 6자리
|
||||
// 20080919 - 업무에러일 경우에도 메시지에 설정하도록 수정
|
||||
// --------------------------------------------
|
||||
|
||||
if (this.mapper != null && this.standardMessage != null && rspErrCd != null && rspErrCd.length() == 12) {
|
||||
if (rspErrCd.startsWith("RE") || rspErrCd.startsWith("RF") || rspErrCd.equals(BWK_FAILMSG_CODE)) {
|
||||
|
||||
// migration ExtMessage to StandardMessage
|
||||
//getMapper().setErrorCode(standardMessage, rspErrCd);
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
standardManager.getMessageCoordinator().coordinateSetStandardMessageError(standardMessage, getMapper(), rspErrCd, null);
|
||||
getMapper().setResponseType(standardMessage, STDMessageKeys.RESPONSE_TYPE_CODE_E);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getRspErrMsg() {
|
||||
return rspErrMsg;
|
||||
}
|
||||
|
||||
public void setRspErrMsg(String rspErrMsg) {
|
||||
this.rspErrMsg = rspErrMsg;
|
||||
|
||||
if (this.mapper != null && this.standardMessage != null && rspErrMsg != null) {
|
||||
//getMapper().setErrorMsg(standardMessage, rspErrMsg);
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
standardManager.getMessageCoordinator().coordinateSetStandardMessageError(standardMessage, getMapper(), null, rspErrMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRspErr(String rspErrCd, String rspErrMsg) {
|
||||
this.rspErrCd = rspErrCd;
|
||||
this.rspErrMsg = rspErrMsg;
|
||||
if (this.mapper != null && this.standardMessage != null) {// 표준전문셋팅
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
String stdErrCd = null;
|
||||
String stdErrMsg = null;
|
||||
if (rspErrCd != null && rspErrCd.length() == 12 && (rspErrCd.startsWith("RE") || rspErrCd.startsWith("RF") || rspErrCd.equals(BWK_FAILMSG_CODE))) {
|
||||
stdErrCd = rspErrCd;
|
||||
}
|
||||
if (rspErrMsg != null) {
|
||||
stdErrMsg = rspErrMsg;
|
||||
}
|
||||
standardManager.getMessageCoordinator().coordinateSetStandardMessageError(standardMessage, getMapper(), stdErrCd, stdErrMsg);
|
||||
}
|
||||
}
|
||||
public String getSngSvcCls() {
|
||||
return sngSvcCls;
|
||||
}
|
||||
|
||||
public void setSngSvcCls(String sngSvcCls) {
|
||||
this.sngSvcCls = sngSvcCls;
|
||||
}
|
||||
|
||||
public String getSngSysItfTp() {
|
||||
return sngSysItfTp;
|
||||
}
|
||||
|
||||
public void setSngSysItfTp(String sngSysItfTp) {
|
||||
this.sngSysItfTp = sngSysItfTp;
|
||||
}
|
||||
|
||||
public String getStdMsgUsgCls() {
|
||||
return stdMsgUsgCls;
|
||||
}
|
||||
|
||||
public void setStdMsgUsgCls(String stdMsgUsgCls) {
|
||||
this.stdMsgUsgCls = stdMsgUsgCls;
|
||||
}
|
||||
|
||||
public int getSvcLogLvl() {
|
||||
return svcLogLvl;
|
||||
}
|
||||
|
||||
public void setSvcLogLvl(int svcLogLvl) {
|
||||
this.svcLogLvl = svcLogLvl;
|
||||
}
|
||||
|
||||
public List<ServiceMessage> getSvcMsgs() {
|
||||
return svcMsgs;
|
||||
}
|
||||
|
||||
public void setSvcMsgs(List<ServiceMessage> svcMsgs) {
|
||||
this.svcMsgs = svcMsgs;
|
||||
}
|
||||
|
||||
public void setSvcMsgs(int pos, ServiceMessage svcMsgs) {
|
||||
this.svcMsgs.set(pos, svcMsgs);
|
||||
}
|
||||
|
||||
public void addSvcMsg(ServiceMessage svcMsg) {
|
||||
this.svcMsgs.add(svcMsg);
|
||||
}
|
||||
|
||||
public void removeSvcMsgs() {
|
||||
// 제거 후 추가시 에러 방지 - 2008.06.03
|
||||
this.svcMsgs.clear();
|
||||
}
|
||||
|
||||
public void removeSvcMsg(int pos) {
|
||||
this.svcMsgs.remove(pos);
|
||||
}
|
||||
|
||||
public ServiceMessage getCurrentSvcMsg() {
|
||||
if (getSvcPssSeq() > 0) {
|
||||
return this.svcMsgs.get(getSvcPssSeq() - 1);
|
||||
} else {
|
||||
throw new RuntimeException("EAIMessage] Invalid SvcPssSeq. - " + this.svcPssSeq);
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceMessage getNextSvcMsg() {
|
||||
if (getSvcPssSeq() >= this.svcMsgs.size())
|
||||
return null;
|
||||
return this.svcMsgs.get(getSvcPssSeq());
|
||||
}
|
||||
|
||||
public ServiceMessage getSvcMsg(int i) {
|
||||
if (i >= this.svcMsgs.size())
|
||||
return null;
|
||||
return this.svcMsgs.get(i);
|
||||
}
|
||||
|
||||
public String getSvcOgNo() {
|
||||
return svcOgNo;
|
||||
}
|
||||
|
||||
public void setSvcOgNo(String svcOgNo) {
|
||||
this.svcOgNo = svcOgNo;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq() {
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int svcPssSeq) {
|
||||
this.svcPssSeq = svcPssSeq;
|
||||
}
|
||||
|
||||
public String getSvcPssTp() {
|
||||
return svcPssTp;
|
||||
}
|
||||
|
||||
public void setSvcPssTp(String svcPssTp) {
|
||||
this.svcPssTp = svcPssTp;
|
||||
}
|
||||
|
||||
public String getSvcTmEn() {
|
||||
return svcTmEn;
|
||||
}
|
||||
|
||||
public void setSvcTmEn(String svcTmEn) {
|
||||
this.svcTmEn = svcTmEn;
|
||||
}
|
||||
|
||||
public String getSvcTsmtUsgTp() {
|
||||
return svcTsmtUsgTp;
|
||||
}
|
||||
|
||||
public void setSvcTsmtUsgTp(String svcTsmtUsgTp) {
|
||||
this.svcTsmtUsgTp = svcTsmtUsgTp;
|
||||
}
|
||||
|
||||
public String getSvcWlColLogYn() {
|
||||
return svcWlColLogYn;
|
||||
}
|
||||
|
||||
public void setSvcWlColLogYn(String svcWlColLogYn) {
|
||||
this.svcWlColLogYn = svcWlColLogYn;
|
||||
}
|
||||
|
||||
public int getSvrLogLvl() {
|
||||
return svrLogLvl;
|
||||
}
|
||||
|
||||
public void setSvrLogLvl(int svrLogLvl) {
|
||||
this.svrLogLvl = svrLogLvl;
|
||||
}
|
||||
|
||||
public String getUnifTp() {
|
||||
return unifTp;
|
||||
}
|
||||
|
||||
public void setUnifTp(String unifTp) {
|
||||
this.unifTp = unifTp;
|
||||
}
|
||||
|
||||
public String getErrEAISvcName() {
|
||||
return errEAISvcName;
|
||||
}
|
||||
|
||||
public String getDmndErrChngIDName() {
|
||||
return dmndErrChngIDName;
|
||||
}
|
||||
|
||||
public String getDmndErrFldName() {
|
||||
return dmndErrFldName;
|
||||
}
|
||||
|
||||
public String getRspnsErrChngIDName() {
|
||||
return rspnsErrChngIDName;
|
||||
}
|
||||
|
||||
public String getRspnsErrFldName() {
|
||||
return rspnsErrFldName;
|
||||
}
|
||||
|
||||
public void setErrEAISvcName(String errEAISvcName) {
|
||||
this.errEAISvcName = errEAISvcName;
|
||||
}
|
||||
|
||||
public void setDmndErrChngIDName(String dmndErrChngIDName) {
|
||||
this.dmndErrChngIDName = dmndErrChngIDName;
|
||||
}
|
||||
|
||||
public void setDmndErrFldName(String dmndErrFldName) {
|
||||
this.dmndErrFldName = dmndErrFldName;
|
||||
}
|
||||
|
||||
public void setRspnsErrChngIDName(String rspnsErrChngIDName) {
|
||||
this.rspnsErrChngIDName = rspnsErrChngIDName;
|
||||
}
|
||||
|
||||
public void setRspnsErrFldName(String rspnsErrFldName) {
|
||||
this.rspnsErrFldName = rspnsErrFldName;
|
||||
}
|
||||
|
||||
public void setEAISvcDesc(String eaiSvcDesc) {
|
||||
this.eaiSvcDesc = eaiSvcDesc;
|
||||
}
|
||||
|
||||
public String getEAISvcDesc() {
|
||||
return eaiSvcDesc;
|
||||
}
|
||||
|
||||
public int compareTo(EAIMessage m) {
|
||||
if (getMsgRcvTm() > m.getMsgRcvTm())
|
||||
return 1;
|
||||
else if (getMsgRcvTm() == m.getMsgRcvTm())
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getGroupCoCd() {
|
||||
return groupCoCd;
|
||||
}
|
||||
|
||||
public void setGroupCoCd(String groupCoCd) {
|
||||
this.groupCoCd = groupCoCd;
|
||||
}
|
||||
|
||||
public String getSevrDstcd() {
|
||||
return sevrDstcd;
|
||||
}
|
||||
|
||||
public void setSevrDstcd(String sevrDstcd) {
|
||||
this.sevrDstcd = sevrDstcd;
|
||||
}
|
||||
|
||||
public String getTranType() {
|
||||
return tranType;
|
||||
}
|
||||
|
||||
public void setTranType(String tranType) {
|
||||
this.tranType = tranType;
|
||||
}
|
||||
|
||||
public String getRspnsChngMsgType() {
|
||||
return rspnsChngMsgType;
|
||||
}
|
||||
|
||||
public void setRspnsChngMsgType(String rspnsChngMsgType) {
|
||||
this.rspnsChngMsgType = rspnsChngMsgType;
|
||||
}
|
||||
|
||||
public String getCompanyCode() {
|
||||
return companyCode;
|
||||
}
|
||||
|
||||
public void setCompanyCode(String companyCode) {
|
||||
this.companyCode = companyCode;
|
||||
}
|
||||
|
||||
public int getSplizLength() {
|
||||
return splizLength;
|
||||
}
|
||||
|
||||
public void setSplizLength(int splizLength) {
|
||||
this.splizLength = splizLength;
|
||||
}
|
||||
|
||||
public String getAdptrInstiCode() {
|
||||
return adptrInstiCode;
|
||||
}
|
||||
|
||||
public void setAdptrInstiCode(String adptrInstiCode) {
|
||||
this.adptrInstiCode = adptrInstiCode;
|
||||
}
|
||||
|
||||
public String getUseYn() {
|
||||
return useYn;
|
||||
}
|
||||
|
||||
public void setUseYn(String useYn) {
|
||||
this.useYn = useYn;
|
||||
}
|
||||
|
||||
// public ExtMessage getExtMsg() {
|
||||
// return extMsg;
|
||||
// }
|
||||
//
|
||||
// public void setExtMsg(ExtMessage extMsg) {
|
||||
// this.extMsg = extMsg;
|
||||
// }
|
||||
public InterfaceMapper getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
public void setMapper(InterfaceMapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public StandardMessage getStandardMessage() {
|
||||
return standardMessage;
|
||||
}
|
||||
|
||||
public void setStandardMessage(StandardMessage standardMessage) {
|
||||
this.standardMessage = standardMessage;
|
||||
}
|
||||
|
||||
|
||||
public StandardMessage getSubMessage() {
|
||||
return subMessage;
|
||||
}
|
||||
|
||||
public void setSubMessage(StandardMessage subMessage) {
|
||||
this.subMessage = subMessage;
|
||||
}
|
||||
|
||||
public String getExtBizCd() {
|
||||
return extBizCd;
|
||||
}
|
||||
|
||||
public void setExtBizCd(String extBizCd) {
|
||||
this.extBizCd = extBizCd;
|
||||
}
|
||||
|
||||
public String getTxId() {
|
||||
return txId;
|
||||
}
|
||||
|
||||
public void setTxId(String txId) {
|
||||
this.txId = txId;
|
||||
}
|
||||
|
||||
public String getRefKey() {
|
||||
return refKey;
|
||||
}
|
||||
|
||||
public void setRefKey(String refKey) {
|
||||
this.refKey = refKey;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getInternalExternalDvcd() {
|
||||
return internalExternalDvcd;
|
||||
}
|
||||
|
||||
public void setInternalExternalDvcd(String internalExternalDvcd) {
|
||||
this.internalExternalDvcd = internalExternalDvcd;
|
||||
}
|
||||
|
||||
public String getApiEnabledYn() {
|
||||
return apiEnabledYn;
|
||||
}
|
||||
|
||||
public void setApiEnabledYn(String apiEnabledYn) {
|
||||
this.apiEnabledYn = apiEnabledYn;
|
||||
}
|
||||
|
||||
public String getAuthType() {
|
||||
return authType;
|
||||
}
|
||||
|
||||
public void setAuthType(String authType) {
|
||||
this.authType = authType;
|
||||
}
|
||||
|
||||
public String getClientIp() {
|
||||
return clientIp;
|
||||
}
|
||||
|
||||
public void setClientIp(String clientIp) {
|
||||
this.clientIp = clientIp;
|
||||
}
|
||||
|
||||
public String getApiCacheYn() {
|
||||
return apiCacheYn;
|
||||
}
|
||||
|
||||
public void setApiCacheYn(String apiCacheYn) {
|
||||
this.apiCacheYn = apiCacheYn;
|
||||
}
|
||||
|
||||
public String getApiCacheType() {
|
||||
return apiCacheType;
|
||||
}
|
||||
|
||||
public void setApiCacheType(String apiCacheType) {
|
||||
this.apiCacheType = apiCacheType;
|
||||
}
|
||||
|
||||
public String getAuthkeyfieldname() {
|
||||
return authkeyfieldname;
|
||||
}
|
||||
|
||||
public void setAuthkeyfieldname(String authkeyfieldname) {
|
||||
this.authkeyfieldname = authkeyfieldname;
|
||||
}
|
||||
|
||||
public String getAuthCheckdYn() {
|
||||
return authCheckdYn;
|
||||
}
|
||||
|
||||
public void setAuthCheckdYn(String authCheckdYn) {
|
||||
this.authCheckdYn = authCheckdYn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
EAIMessage cloned = (EAIMessage) super.clone();
|
||||
if (svcMsgs != null) {
|
||||
cloned.setSvcMsgs((List<ServiceMessage>) ((ArrayList<ServiceMessage>) svcMsgs).clone());
|
||||
}
|
||||
if (mapper != null)
|
||||
cloned.setMapper(mapper);
|
||||
if (standardMessage != null)
|
||||
cloned.setStandardMessage((StandardMessage) standardMessage.clone());
|
||||
if (subMessage != null)
|
||||
cloned.setSubMessage((StandardMessage) subMessage.clone());
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
String data = null;
|
||||
if (standardMessage != null) {
|
||||
try {
|
||||
standardMessage.setBizData(data, null);
|
||||
} catch (Exception e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
if (subMessage != null) {
|
||||
try {
|
||||
subMessage.setBizData(data, null);
|
||||
} catch (Exception e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
if (svcMsgs != null) {
|
||||
svcMsgs.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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.message.loader.CondPerRtgInfoLoader;
|
||||
import com.eactive.eai.common.message.loader.EAIMessageLoader;
|
||||
import com.eactive.eai.common.message.loader.EAIReferenceMessageLoader;
|
||||
import com.eactive.eai.common.message.loader.ServiceMessageLoader;
|
||||
import com.eactive.eai.common.message.mapper.CondPerRtgInfoMapper;
|
||||
import com.eactive.eai.common.message.mapper.EAIMessageMapper;
|
||||
import com.eactive.eai.common.message.mapper.ServiceMessageMapper;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.message.CondPerRtgInfoEntity;
|
||||
import com.eactive.eai.data.entity.onl.message.EAIMessageEntity;
|
||||
import com.eactive.eai.data.entity.onl.message.EAIReferenceMessage;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class EAIMessageDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
EAIMessageLoader eaiMessageService;
|
||||
|
||||
@Autowired
|
||||
EAIMessageMapper eaiMessageMapper;
|
||||
|
||||
@Autowired
|
||||
ServiceMessageLoader serviceMessageLoader;
|
||||
|
||||
@Autowired
|
||||
ServiceMessageMapper serviceMessageMapper;
|
||||
|
||||
@Autowired
|
||||
EAIReferenceMessageLoader eaiReferenceMessageService;
|
||||
|
||||
@Autowired
|
||||
CondPerRtgInfoLoader condPerRtgInfoLoader;
|
||||
|
||||
@Autowired
|
||||
CondPerRtgInfoMapper condPerRtgInfoMapper;
|
||||
|
||||
public Map<String, EAIMessage> getAllEAIMessages() throws DAOException {
|
||||
try {
|
||||
|
||||
List<EAIMessageEntity> eaiMessageEntities = eaiMessageService.findByUseynOrderByEaisvcname("1");
|
||||
logger.info("[ @@ Load EAIMessage Configuration - starting >>>>>>>>>>>>>>>>> ]");
|
||||
|
||||
Map<String, EAIMessage> eaiMessages = new HashMap<>();
|
||||
for (EAIMessageEntity eaiMessageEntity : eaiMessageEntities) {
|
||||
EAIMessage eaiMessage = getEAIMessage(eaiMessageEntity);
|
||||
eaiMessages.put(eaiMessage.getEAISvcCd(), eaiMessage);
|
||||
}
|
||||
return eaiMessages;
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICMM101"));
|
||||
}
|
||||
}
|
||||
|
||||
private EAIMessage getEAIMessage(EAIMessageEntity eaiMessageEntity) {
|
||||
EAIMessage eaiMessage = eaiMessageMapper.toVo(eaiMessageEntity);
|
||||
|
||||
mapEaiReference(eaiMessageEntity, eaiMessage);
|
||||
|
||||
mapCondPerRtgInfo(eaiMessageEntity, eaiMessage);
|
||||
return eaiMessage;
|
||||
}
|
||||
|
||||
private void mapCondPerRtgInfo(EAIMessageEntity eaiMessageEntity, EAIMessage eaiMessage) {
|
||||
|
||||
eaiMessageEntity.getServiceMessages().stream().forEach(serviceMessageEntity -> {
|
||||
List<CondPerRtgInfoEntity> condPerRtgInfoEntities = serviceMessageEntity.getCondPerRtgInfos();
|
||||
|
||||
List<CondPerRtgInfo> condPerRtgInfos = new ArrayList<>();
|
||||
condPerRtgInfoEntities.forEach(condPerRtgInfoEntity -> {
|
||||
CondPerRtgInfo condPerRtgInfo = new CondPerRtgInfo();
|
||||
condPerRtgInfos.add(condPerRtgInfo);
|
||||
});
|
||||
|
||||
ServiceMessage serviceMessage = eaiMessage.getSvcMsg(serviceMessageEntity.getId().getSvcprcssno() - 1);
|
||||
serviceMessage.setCondPerRtgInfo(condPerRtgInfos);
|
||||
});
|
||||
}
|
||||
|
||||
private void mapEaiReference(EAIMessageEntity eaiMessageEntity, EAIMessage eaiMessage) {
|
||||
|
||||
eaiMessageEntity.getServiceMessages().stream().forEach(serviceMessageEntity -> {
|
||||
List<EAIReferenceMessage> eaiReferenceMessages = serviceMessageEntity.getEaiReferenceMessages();
|
||||
|
||||
String[] refmsgidnames = eaiReferenceMessages.stream().map(EAIReferenceMessage::getRefmsgidname)
|
||||
.toArray(String[]::new);
|
||||
|
||||
ServiceMessage serviceMessage = eaiMessage.getSvcMsg(serviceMessageEntity.getId().getSvcprcssno() - 1);
|
||||
serviceMessage.setRefMsgIDs(refmsgidnames);
|
||||
});
|
||||
}
|
||||
|
||||
public EAIMessage getEAIMessagesByCode(String code) {
|
||||
EAIMessageEntity eaiMessageEntity = eaiMessageService.getById(code);
|
||||
return getEAIMessage(eaiMessageEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
public interface EAIMessageKeys {
|
||||
public static final String YES_FLAG = "1"; // 2005.10.18 CK Y --> 1
|
||||
public static final String NO_FLAG = "0"; // 2005.10.18 CK N --> 0
|
||||
public static final String SYNC_SVC = "SYNC";
|
||||
public static final String ASYNC_SVC = "ASYN";
|
||||
public static final String ACKONLY_SVC = "AKON";
|
||||
public static final String SINGLE_PROCESS = "SINGLE";
|
||||
public static final String PUBLISH_PROCESS = "PUB";
|
||||
public static final String COMPLEX_PROCESS = "COMPLEX";
|
||||
public static final String PARALLEL_COMPLEX_PROCESS = "PCOMPLEX";
|
||||
|
||||
// property 에 응답코드를 설정
|
||||
public static final String ELINK_RET_CODE = "ELINK_RET_CODE";
|
||||
public static final String EAI_DEFAULT_CODE = "ESBEAI111111";
|
||||
public static final String EAI_SUCCESS_CODE = "ESBEAI000000";
|
||||
public static final String EAI_BLOCKED_CODE = "RECEAIIRP070";
|
||||
public static final String EAI_INFLOW_BLOCKED_CODE = "RECEAIIRP072";
|
||||
//-------------------------------------------------------------
|
||||
// 2007.07.12 DHLEE
|
||||
// 강길수과장 요청 : SNATMProcess의 CAP[51] 에러인 경우에만 BWK_FAILMSG_CODE 사용
|
||||
// 업무데이터 값에 의한 오류응답메시지는 BWK_ERRMSG_CODE 를 사용 EAI_SUCCESS_CODE 와 동일한 값
|
||||
//-------------------------------------------------------------
|
||||
public static final String BWK_FAILMSG_CODE = "RIBEAI999999";
|
||||
public static final String BWK_ERRMSG_CODE = "ESBEAI000000";
|
||||
//-------------------------------------------------------------
|
||||
|
||||
public static final String TRANTYPE_REAL = "R"; // 실제 거래 처리
|
||||
public static final String TRANTYPE_TAS = "T"; // TAS 로 거래처리
|
||||
public static final String TRANTYPE_STOP = "S"; // EAI에서 수신만하고 STOP
|
||||
public static final String TRANTYPE_FROMTAS = "F"; // TAS 기동 거래
|
||||
public static final String TRANTYPE_DUMMYROUT = "D"; // 더미단말 라우팅
|
||||
public static final String TAS_BIZ_CODE = "TAS_BIZ_CODE";
|
||||
|
||||
public static final String RSPNSCHNGMSGTYPE_RES = "0";
|
||||
public static final String RSPNSCHNGMSGTYPE_ERR = "1";
|
||||
|
||||
public static final String DUMMY_TEST_CASE_ID = "TTTTTTT"; // 'T' 7개
|
||||
|
||||
public static final String REAL_PRCSS_TIME = "REAL_PRCSS_TIME"; // 실제처리시간
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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.dao.DAOException;
|
||||
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;
|
||||
import com.eactive.eai.common.util.ObjectUtil;
|
||||
|
||||
@Component
|
||||
public class EAIMessageManager implements Lifecycle {
|
||||
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
private Map<String, EAIMessage> eaiMsgs = new HashMap<>();
|
||||
private boolean started;
|
||||
private LifecycleSupport lifecycle = new LifecycleSupport(this);
|
||||
|
||||
@Autowired
|
||||
EAIMessageDAO eaiMessageDAO;
|
||||
|
||||
public static EAIMessageManager getInstance() {
|
||||
return ApplicationContextProvider.getContext().getBean(EAIMessageManager.class);
|
||||
}
|
||||
|
||||
public void start() throws LifecycleException {
|
||||
if (started)
|
||||
throw new LifecycleException("RECEAICMM201");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
|
||||
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICMM202"));
|
||||
}
|
||||
started = true;
|
||||
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
|
||||
}
|
||||
|
||||
private void init() throws DAOException {
|
||||
eaiMsgs = eaiMessageDAO.getAllEAIMessages();
|
||||
}
|
||||
|
||||
public synchronized void reload() throws Exception {
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("EAIMessageManager] reload all Started ...");
|
||||
}
|
||||
init();
|
||||
if (logger.isWarn()) {
|
||||
logger.warn("EAIMessageManager] reload all finished ...");
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void reload(String keyName) throws Exception {
|
||||
EAIMessage msg = eaiMessageDAO.getEAIMessagesByCode(keyName);
|
||||
if (msg != null) {
|
||||
if ("1".equals(msg.getUseYn())) {
|
||||
eaiMsgs.put(keyName, msg);
|
||||
} else {
|
||||
eaiMsgs.remove(keyName);
|
||||
logger.warn("EAIMessageManager] reload key[" + keyName + "] useYn[0] removed");
|
||||
}
|
||||
} else {
|
||||
throw new Exception("EAIMessage not found in Database : key[" + keyName + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws LifecycleException {
|
||||
if (!started)
|
||||
throw new LifecycleException("RECEAICMM203");
|
||||
|
||||
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
|
||||
|
||||
eaiMsgs.clear();
|
||||
|
||||
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 EAIMessage getEAIMessage(String eaiSvcCd) throws Exception {
|
||||
EAIMessage aMsg = eaiMsgs.get(eaiSvcCd);
|
||||
if (aMsg != null) {
|
||||
try {
|
||||
return (EAIMessage) ObjectUtil.deepCopy(aMsg);
|
||||
} catch (Exception e) {
|
||||
throw new Exception(ExceptionUtil.getErrorCode(e, "RECEAICMM204"), e);
|
||||
}
|
||||
} else {
|
||||
return aMsg;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAllEAISvcCd() {
|
||||
Iterator<String> it = this.eaiMsgs.keySet().iterator();
|
||||
String[] svcCd = new String[this.eaiMsgs.size()];
|
||||
for (int i = 0; it.hasNext(); i++) {
|
||||
svcCd[i] = it.next();
|
||||
if (svcCd[i] == null)
|
||||
svcCd[i] = "";
|
||||
}
|
||||
Arrays.sort(svcCd);
|
||||
return svcCd;
|
||||
}
|
||||
|
||||
public void removeEAIMessage(String code) {
|
||||
eaiMsgs.remove(code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
public interface ExtMessageKeys {
|
||||
public static final String GROUP_HEADER = "Header";
|
||||
public static final String GROUP_STD_HEADER = "stdheader";
|
||||
public static final String FIELD_SERVICE_ID = "service_id";
|
||||
public static final String FIELD_TRAN_TYPE = "outputMesgTycd";
|
||||
public static final String GROUP_STD_COMMON = "stdcommon";
|
||||
public static final String FIELD_USERID = "usr_id";
|
||||
public static final String FIELD_DLNG_TMNL_NO = "DLNG_TMNL_NO";
|
||||
public static final String FIELD_ROFC_CD = "ROFC_CD";
|
||||
public static final String FIELD_BRN_CD = "BRN_CD";
|
||||
public static final String FIELD_RSPNS_RSLT_DVSN_CD = "RSPNS_RSLT_DVSN_CD";
|
||||
|
||||
public static final String GROUP_SYSTEM_HEADER = "systemHeader";
|
||||
public static final String FIELD_TLGR_TYP_DVSN_CD = "TLGR_TYP_DVSN_CD";
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
/**
|
||||
* EAI 인터페이스 타입에 대한 코드를 상수로 정의
|
||||
*/
|
||||
public interface IFType {
|
||||
// Sync - Sync
|
||||
public static final String SS = "SS";
|
||||
|
||||
// Async - Async
|
||||
public static final String AA = "AA";
|
||||
|
||||
// Sync = Async
|
||||
public static final String SA = "SA";
|
||||
|
||||
// Async - Sync
|
||||
public static final String AS = "AS";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
/**
|
||||
* 업무메시지의 타입에 대한 상수를 정의
|
||||
*/
|
||||
public interface MessageType {
|
||||
// ASCII
|
||||
public static final String ASC = "ASC";
|
||||
|
||||
// EBCDIC
|
||||
public static final String EBC = "EBC";
|
||||
|
||||
// Java Value Object
|
||||
public static final String JOB = "JOB";
|
||||
|
||||
// Tuxedo FML
|
||||
public static final String FML = "FML";
|
||||
|
||||
// Tuxedo FML32
|
||||
public static final String F32 = "F32";
|
||||
|
||||
// XML
|
||||
public static final String XML = "XML";
|
||||
public static final String XML_ENCODE = "euc-kr";
|
||||
// public static final String UXML = "UXL";
|
||||
// public static final String UXML_ENCODE = "utf-8";
|
||||
// EUC-KR JSON
|
||||
public static final String JSON = "JSN";
|
||||
public static final String JSON_ENCODE = "euc-kr";
|
||||
// UTF-8 JSON
|
||||
// public static final String UJSON = "UJN";
|
||||
// public static final String UJSON_ENCODE = "utf-8";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceMessage implements EAIMessageKeys, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String eAISvcCd; // EAI서비스명[TSEAIHE02.EAISvcName]
|
||||
private int svcPssSeq; // 서비스처리번호[TSEAIHE02.SvcPrcssNo]
|
||||
private String psvItfTp; // 수동인터페이스구분명[TSEAIHE02.ManulIntfacDsticName] - PassiveInterfaceType - [SYNC|ASYN|AKON]
|
||||
private String psvBwkSysNm; // 수동시스템업무구분코드[TSEAIHE02.ManulSysBzwkDstcd] - PassiveBusinessWorkSystemName - [ 3|4 자리 KB표준업무시스템명 사용 ]
|
||||
private String psvSysID; // 수동시스템ID명[TSEAIHE02.ManulSysIDName] - PassiveSystemIdentifier - KB표준시스템ID Naming Rule을 따른다.
|
||||
private String psvSysSvcCd; // 수동시스템서비스구분명[TSEAIHE02.ManulSysSvcDsticName] - PassiveSystemServiceCode -
|
||||
private String psvSysItfTp; // 수동시스템어댑터업무그룹명[TSEAIHE02.ManulSysAdptrBzwkGroupName] - PassiveSystemInterfaceType -[Adapter_업무명_OUT]
|
||||
private String flOvrCls; // 장애극복여부[TSEAIHE02.FlovrYn] - FailOverClassification -[Y|N]
|
||||
private String cnvEn; // 변환유무[TSEAIHE02.ChngEonot] - ConversionExistenceOrNot -[Y|N]
|
||||
private String cnvMsgID; // 변환메시지ID명[TSEAIHE02.ChngMsgIDName] - ConversionMessageIdentifier
|
||||
private String rspMsgRefID; // 응답메시지ID - ResponseMessageReferenceIdentifier
|
||||
private String bsRspMsgCprVl; // 기본응답메시지비교내용[TSEAIHE02.BascRspnsMsgCmprCtnt] - BasisResponseMessageCompareValue
|
||||
private String bsRspCnvEn; // 기본응답변환유무[TSEAIHE02.BascRspnsChngEonot] - BasisResponseConversionExistenceOrNot -[Y|N]
|
||||
private String bsRspCnvMsgID; // 기본응답변환메시지ID명[TSEAIHE02.BascRspnsChngMsgIDName] - BasisResponseConversionMessageIdentifier
|
||||
private String errRspMsgCprVl; // 오류응답메시지비교내용[TSEAIHE02.ErrRspnsMsgCmprCtnt] - ErrorResponseMessageCompareValue
|
||||
private String errRspCnvEn; // 오류응답변환유무[TSEAIHE02.ErrRspnsChngEonot] - ErrorResponseConversionExistenceOrNot -[Y|N]
|
||||
private String errRspCnvMsgID; // 오류응답변환메시지ID명[TSEAIHE02.ErrRspnsChngMsgIDName] - ErrorResposneConversionIdentifier
|
||||
private String keyMgtMsgVl; // 키관리메시지값 - KeyManagementMessageValue
|
||||
private int nxtSvcPssSeq; // 다음서비스처리번호[TSEAIHE02.NextSvcPrcssNo] - NextServiceProcessSequence
|
||||
private String outbRtnNm; // 아웃바운드라우팅명[TSEAIHE02.OutbndRoutName] - OutboundRoutingName
|
||||
private int tmoVl; // 타임아웃값[TSEAIHE02.ToutVal] - TimeoutValue(단위: 초)
|
||||
private String cpnsSvcPssCd; // 보상서비스처리구분명[TSEAIHE02.CmpenSvcPrcssDsticName] - CompensationServiceProcessCode
|
||||
private String tmRefMsgID; // 타이머참고메시지ID - TimerReferenceMessageIdentifier
|
||||
|
||||
private String supplDelYn; //추가삭제여부[TSEAIHE02.SupplDelYn] -[Y/N]
|
||||
private String hdrCtrlDstcd; //헤더제어구분코드[TSEAIHE02.HdrCtrlDstcd] -[01/02]삭제추가/추가삭제
|
||||
private String hdrRefClsName; //참고틀래스명[TSEAIHE02.HdrRefClsName] -com.eactive.eai.common.header.PPSHeaderUtil
|
||||
|
||||
private String restOption; //REST 옵션[TSEAIHE02.restOption]
|
||||
private String timeoutCode; //REST 옵션[TSEAIHE02.timeoutCode]
|
||||
|
||||
private String[] refMsgIDs; // 입력메시지IDS[TSEAIMS02.refmsgidno] - ReferenceMessageIdentifiers
|
||||
private List<CondPerRtgInfo> condPerRtgInfo; // 조건부라우팅정보테이블 - ConditionPerRoutingInformationArragement - key-필드명, value-비교값
|
||||
|
||||
public String getBsRspCnvEn() {
|
||||
return bsRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isBsRspCnvEn() {
|
||||
return this.bsRspCnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setBsRspCnvEn(String bsRspCnvEn) {
|
||||
this.bsRspCnvEn = bsRspCnvEn;
|
||||
}
|
||||
|
||||
public String getBsRspCnvMsgID() {
|
||||
return bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setBsRspCnvMsgID(String bsRspCnvMsgID) {
|
||||
this.bsRspCnvMsgID = bsRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getBsRspMsgCprVl() {
|
||||
return bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setBsRspMsgCprVl(String bsRspMsgCprVl) {
|
||||
this.bsRspMsgCprVl = bsRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getCnvEn() {
|
||||
return cnvEn;
|
||||
}
|
||||
|
||||
public boolean isCnvEn() {
|
||||
return this.cnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setCnvEn(String cnvEn) {
|
||||
this.cnvEn = cnvEn;
|
||||
}
|
||||
|
||||
public String getCnvMsgID() {
|
||||
return cnvMsgID;
|
||||
}
|
||||
|
||||
public void setCnvMsgID(String cnvMsgID) {
|
||||
this.cnvMsgID = cnvMsgID;
|
||||
}
|
||||
|
||||
public List<CondPerRtgInfo> getCondPerRtgInfo() {
|
||||
return condPerRtgInfo;
|
||||
}
|
||||
|
||||
public boolean hasCondPerRtgInfo() {
|
||||
return (this.condPerRtgInfo != null && !this.condPerRtgInfo.isEmpty());
|
||||
}
|
||||
|
||||
public void setCondPerRtgInfo(List<CondPerRtgInfo> condPerRtgInfo) {
|
||||
this.condPerRtgInfo = condPerRtgInfo;
|
||||
}
|
||||
|
||||
public String getCpnsSvcPssCd() {
|
||||
return cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public void setCpnsSvcPssCd(String cpnsSvcPssCd) {
|
||||
this.cpnsSvcPssCd = cpnsSvcPssCd;
|
||||
}
|
||||
|
||||
public String getErrRspCnvEn() {
|
||||
return errRspCnvEn;
|
||||
}
|
||||
|
||||
public boolean isErrRspCnvEn() {
|
||||
return this.errRspCnvEn.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setErrRspCnvEn(String errRspCnvEn) {
|
||||
this.errRspCnvEn = errRspCnvEn;
|
||||
}
|
||||
|
||||
public String getErrRspCnvMsgID() {
|
||||
return errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public void setErrRspCnvMsgID(String errRspCnvMsgID) {
|
||||
this.errRspCnvMsgID = errRspCnvMsgID;
|
||||
}
|
||||
|
||||
public String getErrRspMsgCprVl() {
|
||||
return errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public void setErrRspMsgCprVl(String errRspMsgCprVl) {
|
||||
this.errRspMsgCprVl = errRspMsgCprVl;
|
||||
}
|
||||
|
||||
public String getFlOvrCls() {
|
||||
return flOvrCls;
|
||||
}
|
||||
|
||||
public boolean hasFailOver() {
|
||||
return this.flOvrCls.equals(YES_FLAG);
|
||||
}
|
||||
|
||||
public void setFlOvrCls(String flOvrCls) {
|
||||
this.flOvrCls = flOvrCls;
|
||||
}
|
||||
|
||||
public String getKeyMgtMsgVl() {
|
||||
return keyMgtMsgVl;
|
||||
}
|
||||
|
||||
public void setKeyMgtMsgVl(String keyMgtMsgVl) {
|
||||
this.keyMgtMsgVl = keyMgtMsgVl;
|
||||
}
|
||||
|
||||
public int getNxtSvcPssSeq() {
|
||||
return nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public void setNxtSvcPssSeq(int nxtSvcPssSeq) {
|
||||
this.nxtSvcPssSeq = nxtSvcPssSeq;
|
||||
}
|
||||
|
||||
public String getOutbRtnNm() {
|
||||
return outbRtnNm;
|
||||
}
|
||||
|
||||
public void setOutbRtnNm(String outbRtnNm) {
|
||||
this.outbRtnNm = outbRtnNm;
|
||||
}
|
||||
|
||||
public String getPsvBwkSysNm() {
|
||||
return psvBwkSysNm;
|
||||
}
|
||||
|
||||
public void setPsvBwkSysNm(String psvBwkSysNm) {
|
||||
this.psvBwkSysNm = psvBwkSysNm;
|
||||
}
|
||||
|
||||
public String getPsvItfTp() {
|
||||
return psvItfTp;
|
||||
}
|
||||
|
||||
public boolean isSyncItfTp() {
|
||||
return this.psvItfTp.equals(SYNC_SVC);
|
||||
}
|
||||
|
||||
public boolean isAckItfTp() {
|
||||
return this.psvItfTp.equals(ACKONLY_SVC);
|
||||
}
|
||||
|
||||
public void setPsvItfTp(String psvItfTp) {
|
||||
this.psvItfTp = psvItfTp;
|
||||
}
|
||||
|
||||
public String getPsvSysID() {
|
||||
return psvSysID;
|
||||
}
|
||||
|
||||
public void setPsvSysID(String psvSysID) {
|
||||
this.psvSysID = psvSysID;
|
||||
}
|
||||
|
||||
public String getPsvSysItfTp() {
|
||||
return psvSysItfTp;
|
||||
}
|
||||
|
||||
public void setPsvSysItfTp(String psvSysItfTp) {
|
||||
this.psvSysItfTp = psvSysItfTp;
|
||||
}
|
||||
|
||||
public String getPsvSysSvcCd() {
|
||||
return psvSysSvcCd;
|
||||
}
|
||||
|
||||
public void setPsvSysSvcCd(String psvSysSvcCd) {
|
||||
this.psvSysSvcCd = psvSysSvcCd;
|
||||
}
|
||||
|
||||
public String[] getRefMsgIDs() {
|
||||
return refMsgIDs;
|
||||
}
|
||||
|
||||
public void setRefMsgIDs(String[] refMsgIDs) {
|
||||
this.refMsgIDs = refMsgIDs;
|
||||
}
|
||||
|
||||
public String getRspMsgRefID() {
|
||||
return rspMsgRefID;
|
||||
}
|
||||
|
||||
public void setRspMsgRefID(String rspMsgRefID) {
|
||||
this.rspMsgRefID = rspMsgRefID;
|
||||
}
|
||||
|
||||
public int getTmoVl() {
|
||||
return tmoVl;
|
||||
}
|
||||
|
||||
public boolean hasTimeOut() {
|
||||
return (this.tmoVl > 0);
|
||||
}
|
||||
|
||||
public void setTmoVl(int tmoVl) {
|
||||
this.tmoVl = tmoVl;
|
||||
}
|
||||
|
||||
public String getTmRefMsgID() {
|
||||
return tmRefMsgID;
|
||||
}
|
||||
|
||||
public void setTmRefMsgID(String tmRefMsgID) {
|
||||
this.tmRefMsgID = tmRefMsgID;
|
||||
}
|
||||
|
||||
public String getEAISvcCd() {
|
||||
return eAISvcCd;
|
||||
}
|
||||
|
||||
public void setEAISvcCd(String svcCd) {
|
||||
eAISvcCd = svcCd;
|
||||
}
|
||||
|
||||
public int getSvcPssSeq() {
|
||||
return svcPssSeq;
|
||||
}
|
||||
|
||||
public void setSvcPssSeq(int seq) {
|
||||
svcPssSeq = seq;
|
||||
}
|
||||
|
||||
public String getHdrCtrlDstcd() {
|
||||
return hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public void setHdrCtrlDstcd(String hdrCtrlDstcd) {
|
||||
this.hdrCtrlDstcd = hdrCtrlDstcd;
|
||||
}
|
||||
|
||||
public String getHdrRefClsName() {
|
||||
return hdrRefClsName;
|
||||
}
|
||||
|
||||
public void setHdrRefClsName(String hdrRefClsName) {
|
||||
this.hdrRefClsName = hdrRefClsName;
|
||||
}
|
||||
|
||||
public String getSupplDelYn() {
|
||||
return supplDelYn;
|
||||
}
|
||||
|
||||
public void setSupplDelYn(String supplDelYn) {
|
||||
this.supplDelYn = supplDelYn;
|
||||
}
|
||||
|
||||
public String getRestOption() {
|
||||
return restOption;
|
||||
}
|
||||
|
||||
public void setRestOption(String restOption) {
|
||||
this.restOption = restOption;
|
||||
}
|
||||
|
||||
public String getTimeoutCode() {
|
||||
return timeoutCode;
|
||||
}
|
||||
|
||||
public void setTimeoutCode(String timeoutCode) {
|
||||
this.timeoutCode = timeoutCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.eactive.eai.common.message.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
|
||||
import com.eactive.eai.common.message.CondPerRtgInfo;
|
||||
import com.eactive.eai.data.entity.onl.message.CondPerRtgInfoEntity;
|
||||
import com.eactive.eai.data.mapper.BaseMapperConfig;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(config = BaseMapperConfig.class)
|
||||
public interface CondPerRtgInfoMapper extends GenericMapper<CondPerRtgInfo, CondPerRtgInfoEntity> {
|
||||
@Mapping(source = "cmprctnt", target = "ruleCprTxt")
|
||||
@Mapping(source = "rsultprcssno", target = "rsultPrcssNo")
|
||||
@Mapping(source = "rulefldgroupname", target = "ruleGrpNm")
|
||||
@Mapping(source = "rulefldname", target = "ruleColNm")
|
||||
|
||||
@Override
|
||||
CondPerRtgInfo toVo(CondPerRtgInfoEntity entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
CondPerRtgInfoEntity toEntity(CondPerRtgInfo vo);
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user