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

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


The following commit(s) were added to refs/heads/master by this push:
     new a655a71  "CAMEL-14557:added 
camel-example-spring-boot-clustered-route-controller"
a655a71 is described below

commit a655a71b8fa9f9c7965a76cdb278bfdb704aea85
Author: Kodanda Ramu Kakarla <kkaka...@kkakarla.pnq.csb>
AuthorDate: Mon Apr 6 12:52:29 2020 +0530

    "CAMEL-14557:added camel-example-spring-boot-clustered-route-controller"
---
 .../README.adoc                                    |  30 +++++++
 .../cluster-bootstrap/pom.xml                      |  64 +++++++++++++
 .../camel/examples/cluster/ClusterBootstrap.java   |  36 ++++++++
 .../cluster/ClusterBootstrapConfiguration.java     |  44 +++++++++
 .../src/main/resources/application.properties      |  23 +++++
 .../cluster-node/pom.xml                           | 100 +++++++++++++++++++++
 .../apache/camel/examples/cluster/ClusterNode.java |  36 ++++++++
 .../examples/cluster/ClusterNodeConfiguration.java |  47 ++++++++++
 .../src/main/resources/application.properties      |  47 ++++++++++
 .../pom.xml                                        |  47 ++++++++++
 10 files changed, 474 insertions(+)

diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/README.adoc 
b/examples/camel-example-spring-boot-clustered-route-controller/README.adoc
new file mode 100644
index 0000000..aa3471f
--- /dev/null
+++ b/examples/camel-example-spring-boot-clustered-route-controller/README.adoc
@@ -0,0 +1,30 @@
+== Camel Clustered Route Controller Example Spring Boot
+
+This example shows how to work with a simple Apache Camel application using 
Spring Boot and a Clustered Route Controller.
+
+=== How to run
+
+1. build the project:
+    mvn clean package
+
+2. in a shell, run the cluster node
+
+    mvn -pl cluster-bootstrap spring-boot:run
+
+3. in a separate shell, run the first camel node
+
+    mvn -pl cluster-node spring-boot:run
+
+4. in a separate shell, run the second camel node
+
+    mvn -pl cluster-node spring-boot:run
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
new file mode 100644
index 0000000..5a46fac
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.example</groupId>
+        
<artifactId>camel-example-spring-boot-clustered-route-controller</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+    </parent>
+
+    
<artifactId>camel-example-spring-boot-clustered-route-controller-cluster-bootstrap</artifactId>
+    <name>Camel :: Example :: Spring Boot :: Clustered Route Controller :: 
Cluster Bootstrap</name>
+    <description>Bootstrap an Atomix Cluster (single node)</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter</artifactId>
+            <version>${spring-boot-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.atomix</groupId>
+            <artifactId>atomix-all</artifactId>
+            <version>${atomix-version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
new file mode 100644
index 0000000..17793ea
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrap.java
@@ -0,0 +1,36 @@
+/*
+ * 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.examples.cluster;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Atomix bootstrap node.
+ */
+@SpringBootApplication
+public class ClusterBootstrap {
+
+    /**
+     * A main method to start this application.
+     */
+    public static void main(String[] args) {
+        SpringApplication.run(ClusterBootstrap.class, args);
+    }
+}
+//CHECKSTYLE:ON
\ No newline at end of file
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
new file mode 100644
index 0000000..2f900a6
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/java/org/apache/camel/examples/cluster/ClusterBootstrapConfiguration.java
@@ -0,0 +1,44 @@
+/*
+ * 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.examples.cluster;
+
+import io.atomix.AtomixReplica;
+import io.atomix.catalyst.transport.Address;
+import io.atomix.catalyst.transport.netty.NettyTransport;
+import io.atomix.copycat.server.storage.Storage;
+import io.atomix.copycat.server.storage.StorageLevel;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ClusterBootstrapConfiguration {
+    @Value("${cluster.address}")
+    private String address;
+
+    @Bean(destroyMethod = "shutdown")
+    public AtomixReplica atomix() {
+        return AtomixReplica.builder(new Address(address))
+            .withTransport(new NettyTransport())
+            .withStorage(Storage.builder()
+                .withStorageLevel(StorageLevel.MEMORY)
+                .build())
+            .build()
+            .bootstrap()
+            .join();
+    }
+}
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
new file mode 100644
index 0000000..32d417f
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-bootstrap/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+debug = false
+
+logging.level.org.springframework = INFO
+logging.level.io.atomix = DEBUG
+
+cluster.address = 127.0.0.1:8700
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
new file mode 100644
index 0000000..d9a5dd3
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.example</groupId>
+        
<artifactId>camel-example-spring-boot-clustered-route-controller</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+    </parent>
+
+    
<artifactId>camel-example-spring-boot-clustered-route-controller-cluster-node</artifactId>
+    <name>Camel :: Example :: Spring Boot :: Clustered Route Controller :: 
Cluster Node</name>
+    <description>Bootstrap an Camel Cluster Node</description>
+
+    <dependencyManagement>
+        <dependencies>
+            <!-- Spring Boot BOM -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring.boot-version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <!-- Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel.springboot</groupId>
+                <artifactId>camel-spring-boot-dependencies</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <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>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </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>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNode.java
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNode.java
new file mode 100644
index 0000000..d5a5a18
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNode.java
@@ -0,0 +1,36 @@
+/*
+ * 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.examples.cluster;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ */
+@SpringBootApplication
+public class ClusterNode {
+
+    /**
+     * A main method to start this application.
+     */
+    public static void main(String[] args) {
+        SpringApplication.run(ClusterNode.class, args);
+    }
+}
+//CHECKSTYLE:ON
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
new file mode 100644
index 0000000..b5b09dc
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/java/org/apache/camel/examples/cluster/ClusterNodeConfiguration.java
@@ -0,0 +1,47 @@
+/*
+ * 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.examples.cluster;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ClusterNodeConfiguration {
+
+    @Bean
+    public RouteBuilder routeBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                // This route is configured to be local (see 
application.properties)
+                // so it will be started regardless of the leadership status if
+                // this node.
+                from("timer:heartbeat?period=10s")
+                    .routeId("heartbeat")
+                    .log("HeartBeat route (timer) {{node.id}} ...");
+
+                // 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=5s")
+                    .routeId("clustered")
+                    .log("Clustered route (timer) {{node.id}} ...");
+            }
+        };
+    }
+
+}
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
new file mode 100644
index 0000000..fbaf9c1
--- /dev/null
+++ 
b/examples/camel-example-spring-boot-clustered-route-controller/cluster-node/src/main/resources/application.properties
@@ -0,0 +1,47 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+debug = false
+
+logging.level.org.springframework = INFO
+logging.level.io.atomix = DEBUG
+logging.level.org.apache.camel.cluster = DEBUG
+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 = 5s
+
+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}
diff --git 
a/examples/camel-example-spring-boot-clustered-route-controller/pom.xml 
b/examples/camel-example-spring-boot-clustered-route-controller/pom.xml
new file mode 100644
index 0000000..32b83de
--- /dev/null
+++ b/examples/camel-example-spring-boot-clustered-route-controller/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.example</groupId>
+        <artifactId>examples</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+    </parent>
+
+    
<artifactId>camel-example-spring-boot-clustered-route-controller</artifactId>
+    <name>Camel :: Example :: Spring Boot :: Clustered Route Controller</name>
+    <description>An example showing how to work with Camel's Clustered Route 
Controller and Spring Boot</description>
+    <packaging>pom</packaging>
+
+    <properties>
+        <category>Clustering</category>
+
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <spring.boot-version>${spring-boot-version}</spring.boot-version>
+    </properties>
+
+    <modules>
+        <module>cluster-bootstrap</module>
+        <module>cluster-node</module>
+    </modules>
+</project>

Reply via email to