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


The following commit(s) were added to refs/heads/main by this push:
     new dc04c3c61670 CAMEL-22997: camel-jbang - Using circuit breakers can 
cause an error creating processor (#21435)
dc04c3c61670 is described below

commit dc04c3c61670628ec7e5fb4ae3d2cd298e8b5567
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Feb 12 22:23:18 2026 +0100

    CAMEL-22997: camel-jbang - Using circuit breakers can cause an error 
creating processor (#21435)
---
 .../main/resources/quarkus-dependencies.properties |  3 +-
 .../camel/dsl/jbang/core/commands/ExportTest.java  | 32 +++++++++++++++++++++
 .../camel-jbang-core/src/test/resources/MyCB.java  | 33 ++++++++++++++++++++++
 .../main/download/CircuitBreakerDownloader.java    | 23 +++++++++++++--
 4 files changed, 87 insertions(+), 4 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/quarkus-dependencies.properties
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/quarkus-dependencies.properties
index bd4bd10ecab2..f9eca1b8d5d7 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/quarkus-dependencies.properties
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/quarkus-dependencies.properties
@@ -15,4 +15,5 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 
-org.messaginghub\:pooled-jms = io.quarkiverse.messaginghub:quarkus-pooled-jms
\ No newline at end of file
+org.messaginghub\:pooled-jms = io.quarkiverse.messaginghub:quarkus-pooled-jms
+camel\:resilience4j = 
org.apache.camel.quarkus:camel-quarkus-microprofile-fault-tolerance
\ No newline at end of file
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index e99e3bc9e641..d3e1f13a7ec5 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -542,6 +542,38 @@ class ExportTest {
         }
     }
 
+    @ParameterizedTest
+    @MethodSource("runtimeProvider")
+    public void shouldExportCircuitBreaker(RuntimeType rt) throws Exception {
+        LOG.info("shouldExportCircuitBraeker {}", rt);
+        Export command = createCommand(rt, new String[] { 
"src/test/resources/MyCB.java" },
+                "--gav=examples:route:1.0.0", "--dir=" + workingDir, 
"--quiet");
+        int exit = command.doCall();
+
+        Assertions.assertEquals(0, exit);
+        Model model = readMavenModel();
+        Assertions.assertEquals("examples", model.getGroupId());
+        Assertions.assertEquals("route", model.getArtifactId());
+        Assertions.assertEquals("1.0.0", model.getVersion());
+
+        if (rt == RuntimeType.main) {
+            Assertions.assertTrue(containsDependency(model.getDependencies(), 
"org.apache.camel", "camel-resilience4j", null));
+        } else if (rt == RuntimeType.springBoot) {
+            Assertions.assertTrue(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.springboot", "camel-resilience4j-starter",
+                            null));
+        } else if (rt == RuntimeType.quarkus) {
+            // quarkus does not have resilience4j but uses mp-fault-tolenrance
+            Assertions.assertFalse(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.quarkus", "camel-quarkus-resilience4j",
+                            null));
+            Assertions.assertTrue(
+                    containsDependency(model.getDependencies(), 
"org.apache.camel.quarkus",
+                            "camel-quarkus-microprofile-fault-tolerance",
+                            null));
+        }
+    }
+
     @ParameterizedTest
     @MethodSource("runtimeProvider")
     public void shouldExportSecretBean(RuntimeType rt) throws Exception {
diff --git a/dsl/camel-jbang/camel-jbang-core/src/test/resources/MyCB.java 
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/MyCB.java
new file mode 100755
index 000000000000..0e90d161972c
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/MyCB.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+// use modeline to configure properties directly in the same source file
+// camel-k: language=java name=Cool property=period=1000
+
+public class MyCB extends org.apache.camel.builder.RouteBuilder {
+
+  @Override
+  public void configure() throws Exception {
+      // Write your routes here, for example:
+      from("direct:start")
+          .circuitBreaker()
+              .to("http://fooservice.com/slow";)
+          .onFallback()
+              .transform().constant("Fallback message")
+          .end()
+          .to("mock:result");
+  }
+}
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
index 1acbbb04de9d..f68a78fb3788 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/CircuitBreakerDownloader.java
@@ -16,10 +16,12 @@
  */
 package org.apache.camel.main.download;
 
+import org.apache.camel.Processor;
 import org.apache.camel.model.CircuitBreakerDefinition;
 import org.apache.camel.model.ModelCamelContext;
-import org.apache.camel.reifier.ProcessReifier;
 import org.apache.camel.reifier.ProcessorReifier;
+import org.apache.camel.spi.ProcessorFactory;
+import org.apache.camel.support.PluginHelper;
 
 /**
  * When using circuit breakers then we need to download the runtime 
implementation
@@ -56,11 +58,26 @@ public final class CircuitBreakerDownloader {
                                     
downloader.downloadDependency("org.apache.camel", 
"camel-microprofile-fault-tolerance",
                                             
route.getCamelContext().getVersion());
                                 }
+                            } else {
+                                // use resilience4j as default
+                                
downloader.downloadDependency("org.apache.camel", "camel-resilience4j",
+                                        route.getCamelContext().getVersion());
                             }
                         }
+                        // circuit breakers uses a processor factory (which 
supports using downloaded JARs)
+                        return new ProcessorReifier<>(route, cb) {
+                            @Override
+                            public Processor createProcessor() throws 
Exception {
+                                final ProcessorFactory processorFactory
+                                        = 
PluginHelper.getProcessorFactory(getCamelContext());
+                                if (processorFactory != null) {
+                                    return 
processorFactory.createProcessor(route, cb);
+                                }
+                                return null;
+                            }
+                        };
                     }
-                    // use core reifier now we have downloaded JARs if needed
-                    return ProcessReifier.coreReifier(route, 
processorDefinition);
+                    return null;
                 });
     }
 

Reply via email to