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 2023/05/13 19:20:06 UTC

[camel] branch main updated (a00c41d5540 -> 7534370e10b)

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

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


    from a00c41d5540 CAMEL-19337: camel-core-model - Fix circuitBreaker some options should be attributes and not elements.
     new 25abd42293b CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.
     new 7534370e10b CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.

The 2 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:
 .../SpringResilienceRouteFallbackTest.xml          |  5 +--
 .../resilience4j/SpringResilienceRouteOkTest.xml   |  5 +--
 .../org/apache/camel/model/circuitBreaker.json     |  3 +-
 .../org/apache/camel/model/onFallback.json         |  2 +-
 .../camel/model/CircuitBreakerDefinition.java      |  9 ++---
 .../apache/camel/model/OnFallbackDefinition.java   |  9 ++---
 .../java/org/apache/camel/xml/in/ModelParser.java  | 28 ++++++++++------
 .../java/org/apache/camel/xml/out/ModelWriter.java |  1 +
 .../ROOT/pages/camel-4-migration-guide.adoc        | 38 ++++++++++++++++++++++
 9 files changed, 70 insertions(+), 30 deletions(-)


[camel] 01/02: CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 25abd42293b4de20c2b739f03d101dea1209dca1
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat May 13 20:58:21 2023 +0200

    CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.
---
 .../SpringResilienceRouteFallbackTest.xml          |  5 +---
 .../resilience4j/SpringResilienceRouteOkTest.xml   |  5 +---
 .../org/apache/camel/model/circuitBreaker.json     |  3 ++-
 .../org/apache/camel/model/onFallback.json         |  2 +-
 .../camel/model/CircuitBreakerDefinition.java      |  9 +++----
 .../apache/camel/model/OnFallbackDefinition.java   |  9 +++----
 .../java/org/apache/camel/xml/in/ModelParser.java  | 28 ++++++++++++++--------
 .../java/org/apache/camel/xml/out/ModelWriter.java |  1 +
 8 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteFallbackTest.xml b/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteFallbackTest.xml
index 573408cf428..cb64cbce721 100644
--- a/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteFallbackTest.xml
+++ b/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteFallbackTest.xml
@@ -40,10 +40,7 @@
     <route>
       <from uri="direct:start.with.timeout.enabled"/>
       <circuitBreaker>
-        <resilience4jConfiguration>
-          <timeoutEnabled>true</timeoutEnabled>
-          <timeoutDuration>2000</timeoutDuration>
-        </resilience4jConfiguration>
+        <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
         <throwException exceptionType="java.lang.IllegalArgumentException" message="Forced"/>
         <onFallback>
           <transform>
diff --git a/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteOkTest.xml b/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteOkTest.xml
index 71e831dc042..6f7eded1a55 100644
--- a/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteOkTest.xml
+++ b/components/camel-resilience4j/src/test/resources/org/apache/camel/component/resilience4j/SpringResilienceRouteOkTest.xml
@@ -40,10 +40,7 @@
     <route>
       <from uri="direct:start.with.timeout.enabled"/>
       <circuitBreaker>
-        <resilience4jConfiguration>
-          <timeoutEnabled>true</timeoutEnabled>
-          <timeoutDuration>2000</timeoutDuration>
-        </resilience4jConfiguration>
+        <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
         <to uri="direct:foo"/>
         <onFallback>
           <transform>
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/circuitBreaker.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/circuitBreaker.json
index da76484728a..49cf060b694 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/circuitBreaker.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/circuitBreaker.json
@@ -12,9 +12,10 @@
     "output": false
   },
   "properties": {
+    "configuration": { "kind": "attribute", "displayName": "Configuration", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a circuit breaker configuration (such as resillience4j, or microprofile-fault-tolerance) to use for configuring the circuit breaker EIP." },
     "resilience4jConfiguration": { "kind": "element", "displayName": "Resilience4j Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.model.Resilience4jConfigurationDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Configures the circuit breaker to use Resilience4j with the given configuration." },
     "faultToleranceConfiguration": { "kind": "element", "displayName": "Fault Tolerance Configuration", "required": false, "type": "object", "javaType": "org.apache.camel.model.FaultToleranceConfigurationDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Configures the circuit breaker to use MicroProfile Fault Tolerance with the given configuration." },
-    "configuration": { "kind": "attribute", "displayName": "Configuration", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Refers to a circuit breaker configuration (such as resillience4j, or microprofile-fault-tolerance) to use for configuring the circuit breaker EIP." },
+    "onFallback": { "kind": "element", "displayName": "On Fallback", "required": false, "type": "object", "javaType": "org.apache.camel.model.OnFallbackDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "The fallback route path to execute that does not go over the network. This should be a static or cached result that can immediately be returned upon failure. If the fallback requires network connection then use onFallbackViaNetwork() ." },
     "disabled": { "kind": "attribute", "displayName": "Disabled", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime." },
     "id": { "kind": "attribute", "displayName": "Id", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" },
     "description": { "kind": "element", "displayName": "Description", "required": false, "type": "object", "javaType": "org.apache.camel.model.DescriptionDefinition", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" }
diff --git a/core/camel-core-model/src/generated/resources/org/apache/camel/model/onFallback.json b/core/camel-core-model/src/generated/resources/org/apache/camel/model/onFallback.json
index d0d40c7d8e2..b2b4daf3bd1 100644
--- a/core/camel-core-model/src/generated/resources/org/apache/camel/model/onFallback.json
+++ b/core/camel-core-model/src/generated/resources/org/apache/camel/model/onFallback.json
@@ -9,7 +9,7 @@
     "javaType": "org.apache.camel.model.OnFallbackDefinition",
     "abstract": false,
     "input": true,
-    "output": false
+    "output": true
   },
   "properties": {
     "fallbackViaNetwork": { "kind": "attribute", "displayName": "Fallback Via Network", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the fallback goes over the network. If the fallback will go over the network it is another possible point of failure. It is important to execute the fallback command on a separate thread-pool, otherwise if t [...]
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/CircuitBreakerDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/CircuitBreakerDefinition.java
index b7de31616c8..18151a4263c 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/CircuitBreakerDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/CircuitBreakerDefinition.java
@@ -25,10 +25,8 @@ import jakarta.xml.bind.annotation.XmlAttribute;
 import jakarta.xml.bind.annotation.XmlElement;
 import jakarta.xml.bind.annotation.XmlElementRef;
 import jakarta.xml.bind.annotation.XmlRootElement;
-import jakarta.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.annotations.DslProperty;
 
 /**
  * Route messages in a fault tolerance way using Circuit Breaker
@@ -38,14 +36,13 @@ import org.apache.camel.spi.annotations.DslProperty;
 @XmlAccessorType(XmlAccessType.FIELD)
 public class CircuitBreakerDefinition extends OutputDefinition<CircuitBreakerDefinition> {
 
+    @XmlAttribute
+    private String configuration;
     @XmlElement
     private Resilience4jConfigurationDefinition resilience4jConfiguration;
     @XmlElement
     private FaultToleranceConfigurationDefinition faultToleranceConfiguration;
-    @XmlAttribute
-    private String configuration;
-    @DslProperty
-    @XmlTransient
+    @XmlElement
     private OnFallbackDefinition onFallback;
 
     public CircuitBreakerDefinition() {
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/OnFallbackDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
index 76e53daa8fc..3a36a05b451 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/OnFallbackDefinition.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.model;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -33,11 +34,13 @@ import org.apache.camel.spi.Metadata;
 @Metadata(label = "eip,routing")
 @XmlRootElement(name = "onFallback")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class OnFallbackDefinition extends OutputDefinition<OnFallbackDefinition> {
+public class OnFallbackDefinition extends ProcessorDefinition<OnFallbackDefinition> implements OutputNode {
 
     @XmlAttribute
     @Metadata(label = "advanced", defaultValue = "false", javaType = "java.lang.Boolean")
     private String fallbackViaNetwork;
+    @XmlElementRef
+    private List<ProcessorDefinition<?>> outputs = new ArrayList<>();
 
     public OnFallbackDefinition() {
     }
@@ -47,10 +50,8 @@ public class OnFallbackDefinition extends OutputDefinition<OnFallbackDefinition>
         return outputs;
     }
 
-    @XmlElementRef
-    @Override
     public void setOutputs(List<ProcessorDefinition<?>> outputs) {
-        super.setOutputs(outputs);
+        this.outputs = outputs;
     }
 
     @Override
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index 744b36e8a12..3817d6e971a 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -246,6 +246,7 @@ public class ModelParser extends BaseParser {
         }, (def, key) -> {
             switch (key) {
                 case "faultToleranceConfiguration": def.setFaultToleranceConfiguration(doParseFaultToleranceConfigurationDefinition()); break;
+                case "onFallback": def.setOnFallback(doParseOnFallbackDefinition()); break;
                 case "resilience4jConfiguration": def.setResilience4jConfiguration(doParseResilience4jConfigurationDefinition()); break;
                 default: return outputDefinitionElementHandler().accept(def, key);
             }
@@ -260,6 +261,22 @@ public class ModelParser extends BaseParser {
         return doParse(new FaultToleranceConfigurationDefinition(),
             faultToleranceConfigurationCommonAttributeHandler(), noElementHandler(), noValueHandler());
     }
+    protected OnFallbackDefinition doParseOnFallbackDefinition() throws IOException, XmlPullParserException {
+        return doParse(new OnFallbackDefinition(), (def, key, val) -> {
+            if ("fallbackViaNetwork".equals(key)) {
+                def.setFallbackViaNetwork(val);
+                return true;
+            }
+            return processorDefinitionAttributeHandler().accept(def, key, val);
+        }, (def, key) -> {
+            ProcessorDefinition v = doParseProcessorDefinitionRef(key);
+            if (v != null) { 
+                doAdd(v, def.getOutputs(), def::setOutputs);
+                return true;
+            }
+            return optionalIdentifiedDefinitionElementHandler().accept(def, key);
+        }, noValueHandler());
+    }
     protected ClaimCheckDefinition doParseClaimCheckDefinition() throws IOException, XmlPullParserException {
         return doParse(new ClaimCheckDefinition(), (def, key, val) -> {
             switch (key) {
@@ -666,15 +683,6 @@ public class ModelParser extends BaseParser {
             return true;
         }, noElementHandler(), noValueHandler());
     }
-    protected OnFallbackDefinition doParseOnFallbackDefinition() throws IOException, XmlPullParserException {
-        return doParse(new OnFallbackDefinition(), (def, key, val) -> {
-            if ("fallbackViaNetwork".equals(key)) {
-                def.setFallbackViaNetwork(val);
-                return true;
-            }
-            return processorDefinitionAttributeHandler().accept(def, key, val);
-        }, outputDefinitionElementHandler(), noValueHandler());
-    }
     protected OutputTypeDefinition doParseOutputTypeDefinition() throws IOException, XmlPullParserException {
         return doParse(new OutputTypeDefinition(), (def, key, val) -> {
             switch (key) {
@@ -3233,6 +3241,7 @@ public class ModelParser extends BaseParser {
             case "choice": return doParseChoiceDefinition();
             case "otherwise": return doParseOtherwiseDefinition();
             case "circuitBreaker": return doParseCircuitBreakerDefinition();
+            case "onFallback": return doParseOnFallbackDefinition();
             case "claimCheck": return doParseClaimCheckDefinition();
             case "convertBodyTo": return doParseConvertBodyDefinition();
             case "delay": return doParseDelayDefinition();
@@ -3252,7 +3261,6 @@ public class ModelParser extends BaseParser {
             case "multicast": return doParseMulticastDefinition();
             case "onCompletion": return doParseOnCompletionDefinition();
             case "onException": return doParseOnExceptionDefinition();
-            case "onFallback": return doParseOnFallbackDefinition();
             case "pausable": return doParsePausableDefinition();
             case "pipeline": return doParsePipelineDefinition();
             case "policy": return doParsePolicyDefinition();
diff --git a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index d0c94e503f5..c9c248c3faa 100644
--- a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -1113,6 +1113,7 @@ public class ModelWriter extends BaseWriter {
         doWriteElement("faultToleranceConfiguration", def.getFaultToleranceConfiguration(), this::doWriteFaultToleranceConfigurationDefinition);
         doWriteList(null, null, def.getOutputs(), this::doWriteProcessorDefinitionRef);
         doWriteElement("resilience4jConfiguration", def.getResilience4jConfiguration(), this::doWriteResilience4jConfigurationDefinition);
+        doWriteElement("onFallback", def.getOnFallback(), this::doWriteOnFallbackDefinition);
         endElement();
     }
     protected void doWriteClaimCheckDefinition(


[camel] 02/02: CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7534370e10b0fee52f2cba47a0f6d0e870f2cd6a
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat May 13 21:19:52 2023 +0200

    CAMEL-19337: camel-core-model - Fix circuitBreaker onFallback not exposed correctly in model.
---
 .../ROOT/pages/camel-4-migration-guide.adoc        | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
index 66813d44372..16a00c44c9f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4-migration-guide.adoc
@@ -152,6 +152,44 @@ that contains the input and outgoing (if `InOut`) messages.
 The default xml serialization using `ModelToXMLDumper` has been improved and now uses a generated xml
 serializer located in the `camel-xml-io` module instead of the JAXB based one from `camel-jaxb`.
 
+== CircuitBreaker EIP
+
+The following options in `camel-resilience4j` was mistakenly not defined as attributes:
+
+|===
+| *Option*
+| bulkheadEnabled
+| bulkheadMaxConcurrentCalls
+| bulkheadMaxWaitDuration
+| timeoutEnabled
+| timeoutExecutorService
+| timeoutDuration
+| timeoutCancelRunningFuture
+|===
+
+These options were not exposed in YAML DSL, and in XML DSL you need to migrate from:
+
+[source,xml]
+----
+<circuitBreaker>
+    <resilience4jConfiguration>
+        <timeoutEnabled>true</timeoutEnabled>
+        <timeoutDuration>2000</timeoutDuration>
+    </resilience4jConfiguration>
+...
+</circuitBreaker>
+----
+
+To use attributes instead:
+
+[source,xml]
+----
+<circuitBreaker>
+    <resilience4jConfiguration timeoutEnabled="true" timeoutDuration="2000"/>
+...
+</circuitBreaker>
+----
+
 == Component changes
 
 === camel-azure-cosmosdb