거래파일로그(SIFT_LOGGER) 출력기능 개발
- UUID별로 거래파일로그 생성
This commit is contained in:
+5
@@ -7,6 +7,8 @@ import com.eactive.eai.adapter.http.client.HttpClientAdapterVO;
|
|||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
import com.eactive.eai.common.message.MessageType;
|
import com.eactive.eai.common.message.MessageType;
|
||||||
import com.eactive.eai.common.util.CommonLib;
|
import com.eactive.eai.common.util.CommonLib;
|
||||||
|
import com.eactive.eai.common.util.TxFileLogger;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.HttpStatus;
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.time.StopWatch;
|
import org.apache.commons.lang3.time.StopWatch;
|
||||||
@@ -119,6 +121,8 @@ public class HttpClient5AdapterServiceBody extends HttpClient5AdapterServiceSupp
|
|||||||
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TxFileLogger.logTxFile(tempProp, sendData, "[OUT_SEND]");
|
||||||
|
|
||||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||||
HttpContext context = new BasicHttpContext();
|
HttpContext context = new BasicHttpContext();
|
||||||
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
||||||
@@ -147,6 +151,7 @@ public class HttpClient5AdapterServiceBody extends HttpClient5AdapterServiceSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
|
TxFileLogger.logTxFile(tempProp, responseString, "[OUT_RECV]");
|
||||||
|
|
||||||
|
|
||||||
if (status >= 400 && status < 500) {
|
if (status >= 400 && status < 500) {
|
||||||
|
|||||||
+6
@@ -75,6 +75,7 @@ import com.eactive.eai.common.exception.ExceptionUtil;
|
|||||||
import com.eactive.eai.common.message.MessageType;
|
import com.eactive.eai.common.message.MessageType;
|
||||||
import com.eactive.eai.common.property.PropManager;
|
import com.eactive.eai.common.property.PropManager;
|
||||||
import com.eactive.eai.common.util.CommonLib;
|
import com.eactive.eai.common.util.CommonLib;
|
||||||
|
import com.eactive.eai.common.util.TxFileLogger;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
import com.kjbank.encrypt.exchange.crypto.AES256Cipher;
|
import com.kjbank.encrypt.exchange.crypto.AES256Cipher;
|
||||||
@@ -428,6 +429,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TxFileLogger.logTxFile(tempProp, sendData, "[OUT_SEND]");
|
||||||
|
|
||||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||||
HttpContext context = new BasicHttpContext();
|
HttpContext context = new BasicHttpContext();
|
||||||
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
||||||
@@ -473,10 +476,13 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
|||||||
|
|
||||||
responseHeaders = response.getHeaders();
|
responseHeaders = response.getHeaders();
|
||||||
|
|
||||||
|
TxFileLogger.logTxFile(tempProp, new String(responseMessage, vo.getEncode()), "[OUT_RECV]");
|
||||||
|
|
||||||
if (logger.isDebug()) {
|
if (logger.isDebug()) {
|
||||||
logger.debug("[received status]" + status);
|
logger.debug("[received status]" + status);
|
||||||
logger.debug("HttpClientAdapterServiceRest] RECV (" + vo.getAdapterGroupName() + ") = [" + responseMessage + "]");
|
logger.debug("HttpClientAdapterServiceRest] RECV (" + vo.getAdapterGroupName() + ") = [" + responseMessage + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (ConnectException e) {
|
} catch (ConnectException e) {
|
||||||
if (logger.isDebug() && "N".equals(vo.getTestCallYn())) {
|
if (logger.isDebug() && "N".equals(vo.getTestCallYn())) {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.eactive.eai.common.util;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class TxFileLogger {
|
||||||
|
|
||||||
|
private static Logger siftLogger = Logger.getLogger(Logger.LOGGER_SIFT);
|
||||||
|
|
||||||
|
public static void logTxFile(Properties transactionProp, String message, String prefix) {
|
||||||
|
if (siftLogger.isInfoEnabled()) {
|
||||||
|
siftLogger.info(prefix + message);
|
||||||
|
if (siftLogger.isDebugEnabled())
|
||||||
|
siftLogger.debug(CommonLib.getDumpMessage(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -129,8 +129,8 @@ public class RequestProcessor extends RequestProcessorSupport {
|
|||||||
String testMasterYn = adptGrpVO.getTestMasterYn();
|
String testMasterYn = adptGrpVO.getTestMasterYn();
|
||||||
|
|
||||||
// UUID 생성 : UUID에서 - 없는 32자리
|
// UUID 생성 : UUID에서 - 없는 32자리
|
||||||
String uuid = "";
|
String uuid = prop.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||||
uuid = UUIDGenerator.getUUID().toString().replaceAll("-", "");
|
uuid = uuid == null ? UUIDGenerator.getUUID().toString().replaceAll("-", "") : uuid;
|
||||||
// UUID 생성 : UUID = server구분4자리 + UUID
|
// UUID 생성 : UUID = server구분4자리 + UUID
|
||||||
/*
|
/*
|
||||||
String uuid = "";
|
String uuid = "";
|
||||||
|
|||||||
@@ -4,11 +4,17 @@ import java.net.SocketTimeoutException;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import com.eactive.eai.common.TransactionContextKeys;
|
import com.eactive.eai.common.TransactionContextKeys;
|
||||||
|
import com.eactive.eai.common.circuitBreaker.CircuitBreakerManager;
|
||||||
|
import com.eactive.eai.common.circuitBreaker.type.TypedCircuitBreakerManager;
|
||||||
import com.eactive.eai.util.PropertiesUtil;
|
import com.eactive.eai.util.PropertiesUtil;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
|
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||||
@@ -99,7 +105,32 @@ public class HTTPProcess extends DefaultProcess {
|
|||||||
this.timeout = iTimeoutValue * 1000;
|
this.timeout = iTimeoutValue * 1000;
|
||||||
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
||||||
try {
|
try {
|
||||||
|
// API별 이용
|
||||||
|
String apiId = reqEaiMsg.getEAISvcCd();
|
||||||
|
CircuitBreaker circuitBreaker = TypedCircuitBreakerManager.getInstance().getCircuitBreaker(apiId);
|
||||||
|
|
||||||
|
// 디폴트 이용
|
||||||
|
if(circuitBreaker == null) {
|
||||||
|
String circuitBreakerUseYn = PropManager.getInstance().getProperty("CircuitBreaker", "useYn");
|
||||||
|
if ("Y".equals(circuitBreakerUseYn))
|
||||||
|
circuitBreaker = CircuitBreakerManager.getInstance().getCircuitBreaker(apiId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (circuitBreaker != null) {
|
||||||
|
// ObjectMapper 인스턴스 생성
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
// 서킷 브레이커의 메트릭 정보와 상태 정보를 직접 Node로 변환
|
||||||
|
ObjectNode combinedNode = objectMapper.createObjectNode();
|
||||||
|
combinedNode.put("state", circuitBreaker.getState().toString());
|
||||||
|
combinedNode.set("metrics", objectMapper.valueToTree(circuitBreaker.getMetrics()));
|
||||||
|
|
||||||
|
logger.info("CircuitBreaker state " + combinedNode.toString());
|
||||||
|
this.resObject = circuitBreaker.executeCallable(() -> HttpSender
|
||||||
|
.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp));
|
||||||
|
} else {
|
||||||
this.resObject = HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp);
|
this.resObject = HttpSender.callService(this.adapterGroupName, this.outboundProp, this.reqObject, this.tempProp);
|
||||||
|
}
|
||||||
// 응답코드에 대한 처리
|
// 응답코드에 대한 처리
|
||||||
this.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
|
this.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
|
||||||
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user