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 2020/12/14 08:22:01 UTC

[camel-spring-boot-examples] branch master updated: CAMEL-15940: camel-spring-boot - Issue with property placeholder in an example

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 98cbe72  CAMEL-15940: camel-spring-boot - Issue with property placeholder in an example
98cbe72 is described below

commit 98cbe721ff5ee63faa03b7683e3678fe3971ef61
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Dec 14 09:18:50 2020 +0100

    CAMEL-15940: camel-spring-boot - Issue with property placeholder in an example
---
 .../cluster-node/pom.xml                               | 18 ++----------------
 .../examples/cluster/ClusterNodeConfiguration.java     | 13 +++++++++++--
 .../src/main/resources/application.properties          | 12 ++----------
 .../readme.adoc                                        |  4 ++--
 4 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml b/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
index 28a4f43..8216eac 100644
--- a/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
+++ b/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
@@ -54,18 +54,8 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-undertow</artifactId>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -73,10 +63,6 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.springboot</groupId>
-            <artifactId>camel-spring-boot-starter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel.springboot</groupId>
             <artifactId>camel-atomix-starter</artifactId>
         </dependency>
     </dependencies>
diff --git a/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java b/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
index edc9b97..30f2549 100644
--- a/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
+++ b/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.examples.cluster;
 
+import java.util.UUID;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -23,6 +25,13 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class ClusterNodeConfiguration {
 
+    private String nodeId = UUID.randomUUID().toString();
+
+    @Bean
+    public String nodeId() {
+        return nodeId;
+    }
+
     @Bean
     public RouteBuilder routeBuilder() {
         return new RouteBuilder() {
@@ -33,13 +42,13 @@ public class ClusterNodeConfiguration {
                 // this node.
                 from("timer:heartbeat?period=10000")
                     .routeId("heartbeat")
-                    .log("HeartBeat route (timer) {{node.id}} ...");
+                    .log("HeartBeat route (timer) ${sys.nodeId} ...");
 
                 // This route is configured to be clustered so it will be started
                 // by the controller only when this node is leader
                 from("timer:clustered?period=5000")
                     .routeId("clustered")
-                    .log("Clustered route (timer) {{node.id}} ...");
+                    .log("Clustered route (timer) ${sys.nodeId} ...");
             }
         };
     }
diff --git a/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties b/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
index 9bdcc4d..a96a140 100644
--- a/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
+++ b/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
@@ -24,24 +24,16 @@ logging.level.org.apache.camel.impl.cluster = DEBUG
 logging.level.org.apache.camel.component.atomix = DEBUG
 logging.level.org.apache.camel.examples.cluster = DEBUG
 
-management.endpoints.enabled-by-default = false
-management.endpoints.jmx.enabled = false
-management.endpoint.health.enabled = true
-
-management.server.port = -1
-
-node.id = ${random.uuid}
-
 camel.springboot.name = SampleClusteredRouteController
-camel.springboot.jmx-enabled = false
 
 camel.clustered.controller.enabled = true
 camel.clustered.controller.namespace = camel
 camel.clustered.controller.initial-delay = 5000
 
+# local route that is no clustered
 camel.clustered.controller.routes.heartbeat.clustered = false
 
 camel.component.atomix.cluster.service.enabled = true
 camel.component.atomix.cluster.service.mode = client
 camel.component.atomix.cluster.service.nodes = localhost:8700
-camel.component.atomix.cluster.service.id = ${node.id}
+camel.component.atomix.cluster.service.id = ${nodeId}
diff --git a/camel-example-spring-boot-clustered-route-controller/readme.adoc b/camel-example-spring-boot-clustered-route-controller/readme.adoc
index aa3471f..ffcbf70 100644
--- a/camel-example-spring-boot-clustered-route-controller/readme.adoc
+++ b/camel-example-spring-boot-clustered-route-controller/readme.adoc
@@ -13,11 +13,11 @@ This example shows how to work with a simple Apache Camel application using Spri
 
 3. in a separate shell, run the first camel node
 
-    mvn -pl cluster-node spring-boot:run
+    mvn -pl cluster-node spring-boot:run -DnodeId=foo
 
 4. in a separate shell, run the second camel node
 
-    mvn -pl cluster-node spring-boot:run
+    mvn -pl cluster-node spring-boot:run -DnodeId=bar
 
 === Help and contributions