summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java45
1 files changed, 43 insertions, 2 deletions
diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
index 212460d7..03a49221 100644
--- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
+++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/utils/TransactionIdUtils.java
@@ -36,6 +36,11 @@ import lombok.extern.slf4j.Slf4j;
public class TransactionIdUtils {
/**
+ * To correlate technical logs over one single request.
+ */
+ public static final String MDC_REQUEST_ID = "amTxidHttpRequest";
+
+ /**
* To correlate technical logs over one single transactions.
*/
public static final String MDC_TRANSACTION_ID = "transactionId";
@@ -79,8 +84,9 @@ public class TransactionIdUtils {
*
*/
public static void removeAllLoggingVariables() {
- removeSessionId();
+ removeRequestId();
removeTransactionId();
+ removeSessionId();
removeServiceProviderId();
removeRemoteHost();
@@ -105,6 +111,42 @@ public class TransactionIdUtils {
}
/**
+ * Get Id to correlate technical logs over one single request.
+ *
+ * @return Unique transaction Id
+ */
+ public static String getRequestId() {
+ return org.slf4j.MDC.get(MDC_REQUEST_ID);
+
+ }
+
+ /**
+ * Set new random requestId as an UUID.
+ */
+ public static void setRequestId() {
+ org.slf4j.MDC.put(MDC_REQUEST_ID, UUID.randomUUID().toString());
+
+ }
+
+ /**
+ * Set Id to correlate technical logs over one single request.
+ *
+ * @param transactionId Unique transaction Id
+ */
+ public static void setRequestId(final String transactionId) {
+ org.slf4j.MDC.put(MDC_REQUEST_ID, transactionId);
+
+ }
+
+ /**
+ * Remove requestId for Logging.
+ */
+ public static void removeRequestId() {
+ org.slf4j.MDC.remove(MDC_REQUEST_ID);
+
+ }
+
+ /**
* Get Id to correlate technical logs over one single transactions.
*
* @return Unique transaction Id
@@ -185,5 +227,4 @@ public class TransactionIdUtils {
}
-
}