camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1238389 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-jaxb/ components/camel-jaxb/src/test/ components/camel-jms/
Date Tue, 31 Jan 2012 10:51:30 GMT
Author: davsclaus
Date: Tue Jan 31 10:51:30 2012
New Revision: 1238389

URL: http://svn.apache.org/viewvc?rev=1238389&view=rev
Log:
CAMEL-4962: Added messageId to MDC logging

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MDCTest.java
    camel/branches/camel-2.9.x/components/camel-jaxb/   (props changed)
    camel/branches/camel-2.9.x/components/camel-jaxb/src/test/   (props changed)
    camel/branches/camel-2.9.x/components/camel-jms/   (props changed)

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 10:51:30 2012
@@ -1 +1 @@
-/camel/trunk:1235643,1236639,1236667,1237666,1237807,1238225,1238229
+/camel/trunk:1235643,1236639,1236667,1237666,1237807,1238225,1238229,1238387

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java?rev=1238389&r1=1238388&r2=1238389&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/MDCUnitOfWork.java
Tue Jan 31 10:51:30 2012
@@ -34,6 +34,7 @@ public class MDCUnitOfWork extends Defau
 
     public static final String MDC_BREADCRUMB_ID = "breadcrumbId";
     public static final String MDC_EXCHANGE_ID = "exchangeId";
+    public static final String MDC_MESSAGE_ID = "messageId";
     public static final String MDC_CORRELATION_ID = "correlationId";
     public static final String MDC_ROUTE_ID = "routeId";
     public static final String MDC_CAMEL_CONTEXT_ID = "camelContextId";
@@ -43,6 +44,7 @@ public class MDCUnitOfWork extends Defau
 
     private final String originalBreadcrumbId;
     private final String originalExchangeId;
+    private final String originalMessageId;
     private final String originalCorrelationId;
     private final String originalRouteId;
     private final String originalCamelContextId;
@@ -53,14 +55,17 @@ public class MDCUnitOfWork extends Defau
 
         // remember existing values
         this.originalExchangeId = MDC.get(MDC_EXCHANGE_ID);
+        this.originalMessageId = MDC.get(MDC_MESSAGE_ID);
         this.originalBreadcrumbId = MDC.get(MDC_BREADCRUMB_ID);
         this.originalCorrelationId = MDC.get(MDC_CORRELATION_ID);
         this.originalRouteId = MDC.get(MDC_ROUTE_ID);
         this.originalCamelContextId = MDC.get(MDC_CAMEL_CONTEXT_ID);
         this.originalTransactionKey = MDC.get(MDC_TRANSACTION_KEY);
 
-        // must add exchange id in constructor
+        // must add exchange and message id in constructor
         MDC.put(MDC_EXCHANGE_ID, exchange.getExchangeId());
+        String msgId = exchange.hasOut() ? exchange.getOut().getMessageId() : exchange.getIn().getMessageId();
+        MDC.put(MDC_MESSAGE_ID, msgId);
         // the camel context id is from exchange
         MDC.put(MDC_CAMEL_CONTEXT_ID, exchange.getContext().getName());
         // and add optional correlation id
@@ -140,6 +145,11 @@ public class MDCUnitOfWork extends Defau
         } else {
             MDC.remove(MDC_EXCHANGE_ID);
         }
+        if (this.originalMessageId != null) {
+            MDC.put(MDC_MESSAGE_ID, originalMessageId);
+        } else {
+            MDC.remove(MDC_MESSAGE_ID);
+        }
         if (this.originalCorrelationId != null) {
             MDC.put(MDC_CORRELATION_ID, originalCorrelationId);
         } else {
@@ -176,6 +186,7 @@ public class MDCUnitOfWork extends Defau
         private final AsyncCallback delegate;
         private final String breadcrumbId;
         private final String exchangeId;
+        private final String messageId;
         private final String correlationId;
         private final String routeId;
         private final String camelContextId;
@@ -183,6 +194,7 @@ public class MDCUnitOfWork extends Defau
         private MDCCallback(AsyncCallback delegate) {
             this.delegate = delegate;
             this.exchangeId = MDC.get(MDC_EXCHANGE_ID);
+            this.messageId = MDC.get(MDC_MESSAGE_ID);
             this.breadcrumbId = MDC.get(MDC_BREADCRUMB_ID);
             this.correlationId = MDC.get(MDC_CORRELATION_ID);
             this.camelContextId = MDC.get(MDC_CAMEL_CONTEXT_ID);
@@ -206,6 +218,9 @@ public class MDCUnitOfWork extends Defau
                     if (exchangeId != null) {
                         MDC.put(MDC_EXCHANGE_ID, exchangeId);
                     }
+                    if (messageId != null) {
+                        MDC.put(MDC_MESSAGE_ID, messageId);
+                    }
                     if (correlationId != null) {
                         MDC.put(MDC_CORRELATION_ID, correlationId);
                     }

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MDCTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MDCTest.java?rev=1238389&r1=1238388&r2=1238389&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MDCTest.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MDCTest.java
Tue Jan 31 10:51:30 2012
@@ -60,6 +60,7 @@ public class MDCTest extends ContextTest
                             public void process(Exchange exchange) throws Exception {
                                 assertEquals("route-a", MDC.get("routeId"));
                                 assertEquals(exchange.getExchangeId(), MDC.get("exchangeId"));
+                                assertEquals(exchange.getIn().getMessageId(), MDC.get("messageId"));
                             }
                         })
                         .to("log:foo").to("direct:b");
@@ -69,6 +70,7 @@ public class MDCTest extends ContextTest
                             public void process(Exchange exchange) throws Exception {
                                 assertEquals("route-b", MDC.get("routeId"));
                                 assertEquals(exchange.getExchangeId(), MDC.get("exchangeId"));
+                                assertEquals(exchange.getIn().getMessageId(), MDC.get("messageId"));
                             }
                         })
                         .to("log:bar").to("mock:result");

Propchange: camel/branches/camel-2.9.x/components/camel-jaxb/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 10:51:30 2012
@@ -1 +1 @@
-/camel/trunk/components/camel-jaxb:1235643,1236403-1236663,1236667,1237148,1237666,1237807,1238225,1238229
+/camel/trunk/components/camel-jaxb:1235643,1236403-1236663,1236667,1237148,1237666,1237807,1238225,1238229,1238387

Propchange: camel/branches/camel-2.9.x/components/camel-jaxb/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 10:51:30 2012
@@ -1 +1 @@
-/camel/trunk/components/camel-jaxb/src/test:1235643,1236403-1236663,1236667,1237148,1237230,1237666,1237807,1238225,1238229
+/camel/trunk/components/camel-jaxb/src/test:1235643,1236403-1236663,1236667,1237148,1237230,1237666,1237807,1238225,1238229,1238387

Propchange: camel/branches/camel-2.9.x/components/camel-jms/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 10:51:30 2012
@@ -1 +1 @@
-/camel/trunk/components/camel-jms:1235643,1236639,1236667,1237666,1237807,1238060,1238225,1238229
+/camel/trunk/components/camel-jms:1235643,1236639,1236667,1237666,1237807,1238060,1238225,1238229,1238387



Mime
View raw message