[camel] branch master updated (063c39a -> 4032f91)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated (063c39a -> 4032f91)

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

gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 063c39a  Merge pull request #3621 from kawakamimanabu/typo_jclouds
     new a1dd2bd  Add the clearModelReferences flag to camel-main
     new 8b2be9d  Rename the DataFormatTransformerReifier correctly
     new 251dd33  CAMEL-14684: add unit test and update migration guide
     new 4032f91  Add MDC logging infos during camel context initialization

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/AbstractCamelContext.java    |  7 ++
 ...fier.java => DataFormatTransformerReifier.java} |  4 +-
 .../reifier/transformer/TransformerReifier.java    |  2 +-
 .../BodyOnlyAggregationStrategyTest.java           | 90 ++++++++++++++++++++++
 .../camel-main-configuration-metadata.json         |  1 +
 .../camel/main/DefaultConfigurationConfigurer.java |  1 +
 .../camel/main/DefaultConfigurationProperties.java |  9 +++
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 22 ++++++
 8 files changed, 133 insertions(+), 3 deletions(-)
 rename core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/{DataFormatTransformeReifier.java => DataFormatTransformerReifier.java} (89%)
 create mode 100644 core/camel-core/src/test/java/org/apache/camel/processor/aggregator/BodyOnlyAggregationStrategyTest.java

Reply | Threaded
Open this post in threaded view
|

[camel] 01/04: Add the clearModelReferences flag to camel-main

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

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a1dd2bd2c46105a2810a345c13a3bfdc98c88c66
Author: Guillaume Nodet <[hidden email]>
AuthorDate: Tue Mar 10 08:42:43 2020 +0100

    Add the clearModelReferences flag to camel-main
---
 .../resources/META-INF/camel-main-configuration-metadata.json    | 1 +
 .../org/apache/camel/main/DefaultConfigurationConfigurer.java    | 1 +
 .../org/apache/camel/main/DefaultConfigurationProperties.java    | 9 +++++++++
 3 files changed, 11 insertions(+)

diff --git a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 0aa9ff4..7d8987f 100644
--- a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -21,6 +21,7 @@
     { "name": "camel.main.beanIntrospectionExtendedStatistics", "description": "Sets whether bean introspection uses extended statistics. The default is false.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean" },
     { "name": "camel.main.beanIntrospectionLoggingLevel", "description": "Sets the logging level used by bean introspection, logging activity of its usage. The default is TRACE.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "object", "javaType": "org.apache.camel.LoggingLevel", "enum": [ "ERROR", "WARN", "INFO", "DEBUG", "TRACE", "OFF" ] },
     { "name": "camel.main.caseInsensitiveHeaders", "description": "Whether to use case sensitive or insensitive headers. Important: When using case sensitive (this is set to false). Then the map is case sensitive which means headers such as content-type and Content-Type are two different keys which can be a problem for some protocols such as HTTP based, which rely on case insensitive headers. However case sensitive implementations can yield faster performance. Therefore use case sensitiv [...]
+    { "name": "camel.main.clearModelReferences", "description": null, "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "boolean", "javaType": "boolean" },
     { "name": "camel.main.consumerTemplateCacheSize", "description": "Consumer template endpoints cache size.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int", "defaultValue": 1000 },
     { "name": "camel.main.durationHitExitCode", "description": "Sets the exit code for the application if duration was hit", "sourceType": "org.apache.camel.main.MainConfigurationProperties", "type": "integer", "javaType": "int" },
     { "name": "camel.main.durationMaxIdleSeconds", "description": "To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Camel for a short while.", "sourceType": "org.apache.camel.main.DefaultConfigurationProperties", "type": "integer", "javaType": "int" },
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index 8d83156..a576f72 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -154,6 +154,7 @@ public final class DefaultConfigurationConfigurer {
         camelContext.setMDCLoggingKeysPattern(config.getMdcLoggingKeysPattern());
         camelContext.setLoadTypeConverters(config.isLoadTypeConverters());
         ecc.setAllowAddingNewRoutes(config.isAllowAddingNewRoutes());
+        ecc.setClearModelReferences(config.isClearModelReferences());
 
         if (camelContext.getManagementStrategy().getManagementAgent() != null) {
             camelContext.getManagementStrategy().getManagementAgent().setEndpointRuntimeStatisticsEnabled(config.isEndpointRuntimeStatisticsEnabled());
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index 2d5f19d..cc2b2d5 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -67,6 +67,7 @@ public abstract class DefaultConfigurationProperties<T> {
     private boolean useDataType;
     private boolean useBreadcrumb;
     private boolean allowAddingNewRoutes = true;
+    private boolean clearModelReferences;
     private ManagementStatisticsLevel jmxManagementStatisticsLevel = ManagementStatisticsLevel.Default;
     private String jmxManagementNamePattern = "#name#";
     private boolean jmxCreateConnector;
@@ -657,6 +658,14 @@ public abstract class DefaultConfigurationProperties<T> {
         this.allowAddingNewRoutes = allowAddingNewRoutes;
     }
 
+    public boolean isClearModelReferences() {
+        return clearModelReferences;
+    }
+
+    public void setClearModelReferences(boolean clearModelReferences) {
+        this.clearModelReferences = clearModelReferences;
+    }
+
     public ManagementStatisticsLevel getJmxManagementStatisticsLevel() {
         return jmxManagementStatisticsLevel;
     }

Reply | Threaded
Open this post in threaded view
|

[camel] 02/04: Rename the DataFormatTransformerReifier correctly

gnodet
In reply to this post by gnodet
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8b2be9d858f7214edfe5dd2f549a152c0ce24eca
Author: Guillaume Nodet <[hidden email]>
AuthorDate: Tue Mar 10 10:07:45 2020 +0100

    Rename the DataFormatTransformerReifier correctly
---
 ...FormatTransformeReifier.java => DataFormatTransformerReifier.java} | 4 ++--
 .../java/org/apache/camel/reifier/transformer/TransformerReifier.java | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformeReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformerReifier.java
similarity index 89%
rename from core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformeReifier.java
rename to core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformerReifier.java
index 9eb7d6f..da12fa9 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformeReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/DataFormatTransformerReifier.java
@@ -24,9 +24,9 @@ import org.apache.camel.reifier.dataformat.DataFormatReifier;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.Transformer;
 
-public class DataFormatTransformeReifier extends TransformerReifier<DataFormatTransformerDefinition> {
+public class DataFormatTransformerReifier extends TransformerReifier<DataFormatTransformerDefinition> {
 
-    public DataFormatTransformeReifier(CamelContext camelContext, TransformerDefinition definition) {
+    public DataFormatTransformerReifier(CamelContext camelContext, TransformerDefinition definition) {
         super(camelContext, (DataFormatTransformerDefinition)definition);
     }
 
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/TransformerReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/TransformerReifier.java
index f141d26..b1e77c0 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/TransformerReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/transformer/TransformerReifier.java
@@ -35,7 +35,7 @@ public abstract class TransformerReifier<T> extends AbstractReifier {
     static {
         Map<Class<?>, BiFunction<CamelContext, TransformerDefinition, TransformerReifier<? extends TransformerDefinition>>> map = new HashMap<>();
         map.put(CustomTransformerDefinition.class, CustomTransformeReifier::new);
-        map.put(DataFormatTransformerDefinition.class, DataFormatTransformeReifier::new);
+        map.put(DataFormatTransformerDefinition.class, DataFormatTransformerReifier::new);
         map.put(EndpointTransformerDefinition.class, EndpointTransformeReifier::new);
         TRANSFORMERS = map;
         ReifierStrategy.addReifierClearer(TransformerReifier::clearReifiers);

Reply | Threaded
Open this post in threaded view
|

[camel] 03/04: CAMEL-14684: add unit test and update migration guide

gnodet
In reply to this post by gnodet
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 251dd33787c4a22e3d6edc54104b8f5a2fbc5f03
Author: Guillaume Nodet <[hidden email]>
AuthorDate: Tue Mar 10 10:56:08 2020 +0100

    CAMEL-14684: add unit test and update migration guide
---
 .../BodyOnlyAggregationStrategyTest.java           | 90 ++++++++++++++++++++++
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 22 ++++++
 2 files changed, 112 insertions(+)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/BodyOnlyAggregationStrategyTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/BodyOnlyAggregationStrategyTest.java
new file mode 100644
index 0000000..ca654c4
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/BodyOnlyAggregationStrategyTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.aggregator;
+
+import org.apache.camel.AggregationStrategy;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExtendedExchange;
+import org.apache.camel.builder.DeadLetterChannelBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * Unit test for CAMEL-14684
+ */
+public class BodyOnlyAggregationStrategyTest extends ContextTestSupport {
+
+    @Test
+    public void exceptionRouteTest() throws Exception {
+        getMockEndpoint("mock:error").expectedMessageCount(1);
+        getMockEndpoint("mock:failingRoute").expectedMessageCount(1);
+        getMockEndpoint("mock:nextRoute").expectedMessageCount(0);
+
+        template.sendBody("direct:start", null);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                DeadLetterChannelBuilder deadLetterChannelBuilder = deadLetterChannel("direct:error");
+                deadLetterChannelBuilder.setUseOriginalMessage(true);
+
+                from("direct:failingRoute")
+                        .errorHandler(deadLetterChannelBuilder)
+                        .to("mock:failingRoute")
+                        .throwException(new RuntimeException("Boem!"));
+
+                from("direct:error")
+                        .to("mock:error");
+
+                from("direct:nextRoute")
+                        .to("mock:nextRoute");
+
+                from("direct:start")
+                        .enrich("direct:failingRoute", new BodyOnlyAggregationStrategy())
+                        .to("direct:nextRoute");
+            }
+        };
+    }
+
+    /**
+     * This aggregation strategy will only take the body from the called route and returns the old exchange.
+     * Only the property CamelErrorHandlerHandled is taken from the route to make sure the route stops on an exception.
+     */
+    public static class BodyOnlyAggregationStrategy implements AggregationStrategy {
+
+        @Override
+        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+            oldExchange.getIn().setBody(newExchange.getIn().getBody());
+
+            oldExchange.adapt(ExtendedExchange.class).setErrorHandlerHandled(
+                    newExchange.adapt(ExtendedExchange.class).getErrorHandlerHandled()
+            );
+            // deprecated usage:
+            // if (newExchange.getProperties().get(Exchange.ERRORHANDLER_HANDLED) != null) {
+            //    oldExchange.getProperties().put(Exchange.ERRORHANDLER_HANDLED, newExchange.getProperties().get(Exchange.ERRORHANDLER_HANDLED));
+            //}
+
+            return oldExchange;
+        }
+    }
+}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index 234ebf7..08dd296 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -421,6 +421,28 @@ Should now be:
     exchange.setRollbackOnly(true);
 ----
 
+==== Exchange.ERRORHANDLER_HANDLED
+
+The exchange property `Exchange.ERRORHANDLER_HANDLED` was used to indicate that the error handling mechanism for a given exchange
+had completed.  This property sometimes had to be conveyed by aggregation strategies, so instead of
+
+[source,java]
+----
+    oldExchange.getProperties().put(
+            Exchange.ERRORHANDLER_HANDLED,
+            newExchange.getProperties().get(Exchange.ERRORHANDLER_HANDLED));
+----
+
+one should now use:
+
+[source,java]
+----
+    Boolean handled = newExchange.adapt(ExtendedExchange.class)
+            .getErrorHandlerHandled();
+    oldExchange.adapt(ExtendedExchange.class)
+            .setErrorHandlerHandled(handled);
+----
+
 ==== ModelHelper removed
 
 The class `org.apache.camel.model.ModelHelper` has been removed. Instead you can use its functionality from `ExtendedCamelContext` by

Reply | Threaded
Open this post in threaded view
|

[camel] 04/04: Add MDC logging infos during camel context initialization

gnodet
In reply to this post by gnodet
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4032f91a33edea842934602654a9d1cd0dad2f88
Author: Guillaume Nodet <[hidden email]>
AuthorDate: Tue Mar 10 10:56:37 2020 +0100

    Add MDC logging infos during camel context initialization
---
 .../java/org/apache/camel/impl/engine/AbstractCamelContext.java    | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 9de3839..868bf2d 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -2565,6 +2565,13 @@ public abstract class AbstractCamelContext extends ServiceSupport
     }
 
     @Override
+    public void init() {
+        try (MDCHelper mdcHelper = new MDCHelper()) {
+            super.init();
+        }
+    }
+
+    @Override
     public void stop() {
         try (MDCHelper mdcHelper = new MDCHelper()) {
             super.stop();