You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/10/24 10:01:13 UTC

[camel] branch camel-2.21.x updated: CAMEL-12626: Fixed tracer not working if redelivery turned on error handler.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.21.x by this push:
     new 642ce34  CAMEL-12626: Fixed tracer not working if redelivery turned on error handler.
642ce34 is described below

commit 642ce345fbaae629e38879ff870178480bbd09fb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jul 9 15:20:37 2018 +0200

    CAMEL-12626: Fixed tracer not working if redelivery turned on error handler.
---
 .../processor/interceptor/DefaultChannel.java      |  2 +
 .../interceptor/TracingRedeliveryIssueTest.java    | 58 ++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
index 50500e3..71eed69 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultChannel.java
@@ -332,6 +332,8 @@ public class DefaultChannel extends CamelInternalProcessor implements ModelChann
                 if (redeliveryPossible) {
                     // okay we can redeliver then we need to change the output in the error handler
                     // to use us which we then wrap the call so we can capture before/after for redeliveries as well
+                    Processor currentOutput = ((RedeliveryErrorHandler) errorHandler).getOutput();
+                    instrumentationProcessor.setProcessor(currentOutput);
                     ((RedeliveryErrorHandler) errorHandler).changeOutput(instrumentationProcessor);
                 }
             }
diff --git a/camel-core/src/test/java/org/apache/camel/processor/interceptor/TracingRedeliveryIssueTest.java b/camel-core/src/test/java/org/apache/camel/processor/interceptor/TracingRedeliveryIssueTest.java
new file mode 100644
index 0000000..60843b0
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/interceptor/TracingRedeliveryIssueTest.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.interceptor;
+
+import junit.framework.TestCase;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+
+public class TracingRedeliveryIssueTest extends TestCase {
+
+    public void testTracing() throws Exception {
+        DefaultCamelContext context = new DefaultCamelContext();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(defaultErrorHandler().maximumRedeliveries(3).redeliveryDelay(2000L));
+
+                from("direct:start").to("mock:result");
+            }
+        });
+
+        // Enable Tracer.
+        context.setTracing(true);
+        Tracer tracer = new Tracer();
+        tracer.setDestinationUri("mock:traced");
+        context.setDefaultTracer(tracer);
+        context.start();
+
+        MockEndpoint result = context.getEndpoint("mock:result", MockEndpoint.class);
+        result.setExpectedMessageCount(1);
+        MockEndpoint traced = context.getEndpoint("mock:traced", MockEndpoint.class);
+        traced.setExpectedMessageCount(1);
+
+        ProducerTemplate template = context.createProducerTemplate();
+        template.sendBody("direct:start", "foo");
+
+        MockEndpoint.assertIsSatisfied(result, traced);
+
+        context.stop();
+    }
+
+}