거래파일로그(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.message.MessageType;
|
||||
import com.eactive.eai.common.util.CommonLib;
|
||||
import com.eactive.eai.common.util.TxFileLogger;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
@@ -119,6 +121,8 @@ public class HttpClient5AdapterServiceBody extends HttpClient5AdapterServiceSupp
|
||||
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
||||
}
|
||||
|
||||
TxFileLogger.logTxFile(tempProp, sendData, "[OUT_SEND]");
|
||||
|
||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||
HttpContext context = new BasicHttpContext();
|
||||
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
||||
@@ -147,6 +151,7 @@ public class HttpClient5AdapterServiceBody extends HttpClient5AdapterServiceSupp
|
||||
}
|
||||
|
||||
stopWatch.stop();
|
||||
TxFileLogger.logTxFile(tempProp, responseString, "[OUT_RECV]");
|
||||
|
||||
|
||||
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.property.PropManager;
|
||||
import com.eactive.eai.common.util.CommonLib;
|
||||
import com.eactive.eai.common.util.TxFileLogger;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.kjbank.encrypt.exchange.crypto.AES256Cipher;
|
||||
@@ -428,6 +429,8 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
"SEND [" + sendData + "]" + CommonLib.getDumpMessage(sendData));
|
||||
}
|
||||
|
||||
TxFileLogger.logTxFile(tempProp, sendData, "[OUT_SEND]");
|
||||
|
||||
String uuid = tempProp.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||
HttpContext context = new BasicHttpContext();
|
||||
context.setAttribute(TransactionContextKeys.TRANSACTION_UUID, uuid);
|
||||
@@ -473,10 +476,13 @@ public class HttpClient5AdapterServiceRest extends HttpClient5AdapterServiceSupp
|
||||
|
||||
responseHeaders = response.getHeaders();
|
||||
|
||||
TxFileLogger.logTxFile(tempProp, new String(responseMessage, vo.getEncode()), "[OUT_RECV]");
|
||||
|
||||
if (logger.isDebug()) {
|
||||
logger.debug("[received status]" + status);
|
||||
logger.debug("HttpClientAdapterServiceRest] RECV (" + vo.getAdapterGroupName() + ") = [" + responseMessage + "]");
|
||||
}
|
||||
|
||||
}
|
||||
} catch (ConnectException e) {
|
||||
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();
|
||||
|
||||
// UUID 생성 : UUID에서 - 없는 32자리
|
||||
String uuid = "";
|
||||
uuid = UUIDGenerator.getUUID().toString().replaceAll("-", "");
|
||||
String uuid = prop.getProperty(TransactionContextKeys.TRANSACTION_UUID);
|
||||
uuid = uuid == null ? UUIDGenerator.getUUID().toString().replaceAll("-", "") : uuid;
|
||||
// UUID 생성 : UUID = server구분4자리 + UUID
|
||||
/*
|
||||
String uuid = "";
|
||||
|
||||
@@ -4,11 +4,17 @@ import java.net.SocketTimeoutException;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.eactive.eai.common.TransactionContextKeys;
|
||||
import com.eactive.eai.common.circuitBreaker.CircuitBreakerManager;
|
||||
import com.eactive.eai.common.circuitBreaker.type.TypedCircuitBreakerManager;
|
||||
import com.eactive.eai.util.PropertiesUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import io.github.resilience4j.circuitbreaker.CircuitBreaker;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.eactive.eai.adapter.AdapterGroupVO;
|
||||
@@ -99,7 +105,32 @@ public class HTTPProcess extends DefaultProcess {
|
||||
this.timeout = iTimeoutValue * 1000;
|
||||
this.tempProp.put(INTERFACE_TIME_OUT, "" + this.timeout);
|
||||
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.resEaiMsg = setResponseForOutbound(this.resEaiMsg);
|
||||
if (!com.eactive.eai.adapter.Keys.IF_STANDARD.equals(this.adptrMsgPtrnCd)) {
|
||||
|
||||
Reference in New Issue
Block a user