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 2021/04/27 10:14:25 UTC

[camel-spring-boot] 01/02: CAMEL-16552: camel-spring-boot - Configuring route templates trouble setting route id when using spring yaml configuration

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

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

commit ac93e17835cd3650c003f2947b7997f9c8b5730f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Apr 27 12:09:04 2021 +0200

    CAMEL-16552: camel-spring-boot - Configuring route templates trouble setting route id when using spring yaml configuration
---
 .../CamelRouteTemplateAutoConfiguration.java              | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routetemplate/CamelRouteTemplateAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routetemplate/CamelRouteTemplateAutoConfiguration.java
index 437e73b..3fc76b7 100644
--- a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routetemplate/CamelRouteTemplateAutoConfiguration.java
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/routetemplate/CamelRouteTemplateAutoConfiguration.java
@@ -43,10 +43,21 @@ public class CamelRouteTemplateAutoConfiguration {
         PropertiesRouteTemplateParametersSource source = new PropertiesRouteTemplateParametersSource();
         int counter = 0;
         for (Map<String, String> e : rt.getConfig()) {
+            boolean customRouteId = true;
+            String routeId = e.remove("routeId");
+            if (routeId == null) {
+                routeId = e.remove("route-id");
+            }
+            if (routeId == null) {
+                routeId = String.valueOf(counter);
+                customRouteId = false;
+            }
             for (Map.Entry<String, String> entry : e.entrySet()) {
-                source.addParameter(String.valueOf(counter), entry.getKey(), entry.getValue());
+                source.addParameter(routeId, entry.getKey(), entry.getValue());
+            }
+            if (!customRouteId) {
+                counter++;
             }
-            counter++;
         }
 
         camelContext.getRegistry().bind("CamelSpringBootRouteTemplateParametersSource", RouteTemplateParameterSource.class, source);