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 2016/03/17 11:54:48 UTC

[1/3] camel git commit: CAMEL-9719: Camel Spring Boot Starter

Repository: camel
Updated Branches:
  refs/heads/master 9e990ba46 -> 7c05e621f


CAMEL-9719: Camel Spring Boot Starter


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/89218fd7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/89218fd7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/89218fd7

Branch: refs/heads/master
Commit: 89218fd7ff7b6b40e0306396f065e3bfc14064d4
Parents: 9e990ba
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 17 10:02:46 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 17 11:54:25 2016 +0100

----------------------------------------------------------------------
 apache-camel/pom.xml                            | 12 +++
 .../src/main/descriptors/common-bin.xml         |  2 +
 .../camel-spring-boot-sample/pom.xml            | 87 ++++++++++++++++++++
 .../camel-spring-boot-sample/readme.adoc        | 20 +++++
 .../src/main/java/sample/camel/SampleBean.java  | 31 +++++++
 .../sample/camel/SampleCamelApplication.java    | 34 ++++++++
 .../java/sample/camel/SampleCamelRouter.java    | 30 +++++++
 .../src/main/resources/application.properties   | 23 ++++++
 .../camel/SampleCamelApplicationTest.java       | 47 +++++++++++
 .../camel-spring-boot-starter/pom.xml           | 46 +++++++++++
 .../src/main/resources/META-INF/spring.provides | 18 ++++
 components/camel-spring-boot-starter/pom.xml    | 38 +++++++++
 parent/pom.xml                                  | 21 +++++
 13 files changed, 409 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 26c86aa..00d1021 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -776,6 +776,18 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring-boot</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring-boot-starter</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring-boot-sample</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-spring-integration</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 9c1b121..c797dff 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -205,6 +205,8 @@
         <include>org.apache.camel:camel-splunk</include>
         <include>org.apache.camel:camel-spring</include>
         <include>org.apache.camel:camel-spring-batch</include>
+        <include>org.apache.camel:camel-spring-boot</include>
+        <include>org.apache.camel:camel-spring-boot-starter</include>
         <include>org.apache.camel:camel-spring-integration</include>
         <include>org.apache.camel:camel-spring-javaconfig</include>
         <include>org.apache.camel:camel-spring-ldap</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml b/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml
new file mode 100644
index 0000000..48df175
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/pom.xml
@@ -0,0 +1,87 @@
+<?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</groupId>
+    <artifactId>camel-spring-boot-starter-parent</artifactId>
+    <version>2.17-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-spring-boot-sample</artifactId>
+  <name>Camel :: Spring Boot :: Sample</name>
+  <description>Spring Boot Apache Camel Sample</description>
+
+  <properties>
+    <spring.boot-version>${spring-boot-version}</spring.boot-version>
+    <camel-version>${project.version}</camel-version>
+  </properties>
+
+  <!-- import Spring-Boot and Camel BOM -->
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-dependencies</artifactId>
+        <version>${spring.boot-version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>${camel-version}</version>
+        <type>pom</type>
+        <scope>import</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring-boot-starter</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-stream</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+        <version>${spring-boot-version}</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc b/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc
new file mode 100644
index 0000000..d5d75c4
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/readme.adoc
@@ -0,0 +1,20 @@
+= Spring Boot Camel Sample
+
+This example shows how to work with a simple Apache Camel application using Spring Boot.
+
+The example generates messages using timer trigger, writes them to standard output.
+
+== Camel routes
+
+The Camel route is located in the `SampleCamelRouter` class. In this class the route
+starts from a timer, that triggers every 2nd second and calls a Spring Bean `SampleBean`
+which returns a message, that is routed to a stream endpoint which writes to standard output.
+
+== Using Camel components
+
+Apache Camel provides 200+ components which you can use to integrate and route messages between many systems
+and data formats. To use any of these Camel components, add the component as a dependency to your project.
+
+== More information
+
+You can find more information about Apache Camel at the website: http://camel.apache.org/

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
new file mode 100644
index 0000000..0161acf
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
@@ -0,0 +1,31 @@
+/**
+ * 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 sample.camel;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component("myBean")
+public class SampleBean {
+
+    @Value("greeting")
+    private String say;
+
+    public String saySomething() {
+        return say;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
new file mode 100644
index 0000000..fe4e4dd
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
@@ -0,0 +1,34 @@
+/**
+ * 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 sample.camel;
+
+import org.apache.camel.spring.boot.CamelSpringBootApplicationController;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.ConfigurableApplicationContext;
+
+@SpringBootApplication
+public class SampleCamelApplication {
+
+    public static void main(String[] args) {
+        ConfigurableApplicationContext ctx = new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args);
+
+        // keep the JVM running as Camel uses only daemon threads in the sample
+        CamelSpringBootApplicationController controller = ctx.getBean(CamelSpringBootApplicationController.class);
+        controller.blockMainThread();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
new file mode 100644
index 0000000..d3c2dd4
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
@@ -0,0 +1,30 @@
+/**
+ * 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 sample.camel;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class SampleCamelRouter extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("timer:{{timer.name}}?period={{timer.period}}")
+                .transform(method("myBean", "saySomething"))
+                .to("stream:out");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..eb5bdee
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/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.
+#
+
+spring.main.sources: sample.camel.SampleCamelRouter
+
+greeting = Hello World
+
+timer.name = myTimer
+timer.period = 2000

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
new file mode 100644
index 0000000..e5a097c
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.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 sample.camel;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.NotifyBuilder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertTrue;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringApplicationConfiguration(SampleCamelApplication.class)
+public class SampleCamelApplicationTest {
+
+    @Autowired
+    private CamelContext camelContext;
+
+    @Test
+    public void shouldProduceMessages() throws Exception {
+        // we expect that one or more messages is automatic done by the Camel
+        // route as it uses a timer to trigger
+        NotifyBuilder notify = new NotifyBuilder(camelContext).whenDone(1).create();
+
+        assertTrue(notify.matches(10, TimeUnit.SECONDS));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml b/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml
new file mode 100644
index 0000000..bd5d6a8
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-starter/pom.xml
@@ -0,0 +1,46 @@
+<?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</groupId>
+    <artifactId>camel-spring-boot-starter-parent</artifactId>
+    <version>2.17-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-spring-boot-starter</artifactId>
+  <name>Camel :: Spring Boot :: Starter</name>
+  <description>Spring Boot Apache Camel Starter</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring-boot</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides b/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000..32b9d63
--- /dev/null
+++ b/components/camel-spring-boot-starter/camel-spring-boot-starter/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+provides: camel-spring-boot
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/components/camel-spring-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/pom.xml b/components/camel-spring-boot-starter/pom.xml
new file mode 100644
index 0000000..ae7d147
--- /dev/null
+++ b/components/camel-spring-boot-starter/pom.xml
@@ -0,0 +1,38 @@
+<?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>
+    <artifactId>components</artifactId>
+    <groupId>org.apache.camel</groupId>
+    <version>2.17-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-spring-boot-starter-parent</artifactId>
+  <packaging>pom</packaging>
+  <name>Camel :: Spring-Boot :: Parent</name>
+  <description>Camel Spring-Boot parent</description>
+
+  <modules>
+    <module>camel-spring-boot-starter</module>
+    <module>camel-spring-boot-sample</module>
+  </modules> 
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/89218fd7/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 81a5c45..69cd698 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1589,6 +1589,16 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-spring-boot-starter</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-spring-boot-sample</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-spring-integration</artifactId>
         <version>${project.version}</version>
       </dependency>
@@ -2222,6 +2232,17 @@
         <artifactId>spring-security-core</artifactId>
         <version>${spring-security-version}</version>
       </dependency>
+      <!-- spring-boot support -->
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter</artifactId>
+        <version>${spring-boot-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-web</artifactId>
+        <version>${spring-boot-version}</version>
+      </dependency>
 
       <dependency>
         <groupId>org.scala-lang</groupId>


[3/3] camel git commit: CAMEL-9719: Camel Spring Boot Starter

Posted by da...@apache.org.
CAMEL-9719: Camel Spring Boot Starter


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c05e621
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c05e621
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c05e621

Branch: refs/heads/master
Commit: 7c05e621f4d48c0042062f82cbf5dec5201e72b9
Parents: 28c83d5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 17 11:49:34 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 17 11:54:38 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/sample/camel/SampleBean.java           |  7 +++++++
 .../main/java/sample/camel/SampleCamelApplication.java   | 11 ++++++++++-
 .../src/main/java/sample/camel/SampleCamelRouter.java    |  7 +++++++
 .../src/main/resources/application.properties            |  4 ----
 .../java/sample/camel/SampleCamelApplicationTest.java    |  2 ++
 5 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
index 0161acf..ec7b3dd 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleBean.java
@@ -19,6 +19,12 @@ package sample.camel;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+/**
+ * A bean that returns a message when you call the {@link #saySomething()} method.
+ * <p/>
+ * Uses <tt>@Component("myBean")</tt> to register this bean with the name <tt>myBean</tt>
+ * that we use in the Camel route to lookup this bean.
+ */
 @Component("myBean")
 public class SampleBean {
 
@@ -28,4 +34,5 @@ public class SampleBean {
     public String saySomething() {
         return say;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
index 8a68b69..e90caf3 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
@@ -19,10 +19,19 @@ package sample.camel;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
 
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ * <p/>
+ * See the <tt>application.properties</tt> where the
+ */
 @SpringBootApplication
 public class SampleCamelApplication {
 
+    /**
+     * A main method to start this application.
+     */
     public static void main(String[] args) {
-        new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args).registerShutdownHook();
+        new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
index 5ce9cb7..4e0422e 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
@@ -17,7 +17,14 @@
 package sample.camel;
 
 import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
 
+/**
+ * A simple Camel route that triggers from a timer and calls a bean and prints to system out.
+ * <p/>
+ * Use <tt>@Component</tt> to make Camel auto detect this route when starting.
+ */
+@Component
 public class SampleCamelRouter extends RouteBuilder {
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
index 9270963..ab11489 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
@@ -15,9 +15,6 @@
 # limitations under the License.
 #
 
-spring.main.sources: sample.camel.SampleCamelRouter
-
-
 # the name of Camel
 camel.springboot.name = SampleCamel
 
@@ -25,7 +22,6 @@ camel.springboot.name = SampleCamel
 camel.springboot.main-run-controller = true
 
 
-
 # properties used in the Camel route and beans
 # --------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7c05e621/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
index e5a097c..501f7ac 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/test/java/sample/camel/SampleCamelApplicationTest.java
@@ -23,6 +23,7 @@ import org.apache.camel.builder.NotifyBuilder;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.IntegrationTest;
 import org.springframework.boot.test.SpringApplicationConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
@@ -30,6 +31,7 @@ import static org.junit.Assert.assertTrue;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @SpringApplicationConfiguration(SampleCamelApplication.class)
+@IntegrationTest("camel.springboot.main-run-controller=false")
 public class SampleCamelApplicationTest {
 
     @Autowired


[2/3] camel git commit: CAMEL-9720: camel-spring-boot - Make it easy to keep the JVM running

Posted by da...@apache.org.
CAMEL-9720: camel-spring-boot - Make it easy to keep the JVM running


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/28c83d58
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/28c83d58
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/28c83d58

Branch: refs/heads/master
Commit: 28c83d58db7c50be9aecbcd81b45af5004bcb304
Parents: 89218fd
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Mar 17 11:15:22 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Mar 17 11:54:32 2016 +0100

----------------------------------------------------------------------
 .../sample/camel/SampleCamelApplication.java    |  8 +---
 .../java/sample/camel/SampleCamelRouter.java    |  2 +-
 .../src/main/resources/application.properties   | 15 ++++++-
 .../boot/CamelConfigurationProperties.java      | 13 ++++++
 .../spring/boot/CamelMainRunController.java     | 47 ++++++++++++++++++++
 .../CamelSpringBootApplicationController.java   | 45 ++++++++++++++++---
 .../apache/camel/spring/boot/FatJarRouter.java  |  2 +-
 .../camel/spring/boot/RoutesCollector.java      | 24 +++++++---
 8 files changed, 133 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
index fe4e4dd..8a68b69 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelApplication.java
@@ -16,19 +16,13 @@
  */
 package sample.camel;
 
-import org.apache.camel.spring.boot.CamelSpringBootApplicationController;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.ConfigurableApplicationContext;
 
 @SpringBootApplication
 public class SampleCamelApplication {
 
     public static void main(String[] args) {
-        ConfigurableApplicationContext ctx = new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args);
-
-        // keep the JVM running as Camel uses only daemon threads in the sample
-        CamelSpringBootApplicationController controller = ctx.getBean(CamelSpringBootApplicationController.class);
-        controller.blockMainThread();
+        new SpringApplicationBuilder().sources(SampleCamelApplication.class).run(args).registerShutdownHook();
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
index d3c2dd4..5ce9cb7 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/java/sample/camel/SampleCamelRouter.java
@@ -22,7 +22,7 @@ public class SampleCamelRouter extends RouteBuilder {
 
     @Override
     public void configure() throws Exception {
-        from("timer:{{timer.name}}?period={{timer.period}}")
+        from("timer:hello?period={{timer.period}}")
                 .transform(method("myBean", "saySomething"))
                 .to("stream:out");
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
index eb5bdee..9270963 100644
--- a/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
+++ b/components/camel-spring-boot-starter/camel-spring-boot-sample/src/main/resources/application.properties
@@ -17,7 +17,20 @@
 
 spring.main.sources: sample.camel.SampleCamelRouter
 
+
+# the name of Camel
+camel.springboot.name = SampleCamel
+
+# we want the main thread to keep running
+camel.springboot.main-run-controller = true
+
+
+
+# properties used in the Camel route and beans
+# --------------------------------------------
+
+# what to say
 greeting = Hello World
 
-timer.name = myTimer
+# how often to trigger the timer
 timer.period = 2000

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
index c8f1793..41b90df 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -60,6 +60,12 @@ public class CamelConfigurationProperties {
      */
     private String xmlRests = "classpath:camel-rest/*.xml";
 
+    /**
+     * Whether to use the main run controller to ensure the Spring-Boot application
+     * keeps running until being stopped or the JVM terminated.
+     */
+    private boolean mainRunController;
+
     // Getters & setters
 
     public boolean isJmxEnabled() {
@@ -118,4 +124,11 @@ public class CamelConfigurationProperties {
         this.xmlRests = xmlRests;
     }
 
+    public boolean isMainRunController() {
+        return mainRunController;
+    }
+
+    public void setMainRunController(boolean mainRunController) {
+        this.mainRunController = mainRunController;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.java
new file mode 100644
index 0000000..a09ade4
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelMainRunController.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.spring.boot;
+
+import org.apache.camel.CamelContext;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * Controller to keep the main running and perform graceful shutdown when the JVM is stopped.
+ */
+public class CamelMainRunController {
+
+    private final CamelSpringBootApplicationController controller;
+    private final Thread daemon;
+
+    public CamelMainRunController(ApplicationContext applicationContext, CamelContext camelContext) {
+        controller = new CamelSpringBootApplicationController(applicationContext, camelContext);
+        daemon = new Thread(new DaemonTask(), "CamelMainRunController");
+    }
+
+    public void start() {
+        daemon.run();
+    }
+
+    private final class DaemonTask implements Runnable {
+
+        @Override
+        public void run() {
+            controller.run();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
index abafd8a..bbca474 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelSpringBootApplicationController.java
@@ -18,20 +18,25 @@ package org.apache.camel.spring.boot;
 
 import java.util.Collections;
 import java.util.Map;
-
+import java.util.concurrent.CountDownLatch;
 import javax.annotation.PreDestroy;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
-import org.apache.camel.main.MainSupport;
+import org.apache.camel.main.Main;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
 
 public class CamelSpringBootApplicationController {
 
-    private final MainSupport mainSupport;
+    private static final Logger LOG = LoggerFactory.getLogger(CamelSpringBootApplicationController.class);
+
+    private final Main main;
+    private final CountDownLatch latch = new CountDownLatch(1);
 
     public CamelSpringBootApplicationController(final ApplicationContext applicationContext, final CamelContext camelContext) {
-        this.mainSupport = new MainSupport() {
+        this.main = new Main() {
             @Override
             protected ProducerTemplate findOrCreateCamelTemplate() {
                 return applicationContext.getBean(ProducerTemplate.class);
@@ -41,20 +46,46 @@ public class CamelSpringBootApplicationController {
             protected Map<String, CamelContext> getCamelContextMap() {
                 return Collections.singletonMap("camelContext", camelContext);
             }
+
+            @Override
+            protected void doStop() throws Exception {
+                LOG.debug("Controller is shutting down CamelContext");
+                try {
+                    super.doStop();
+                } finally {
+                    latch.countDown();
+                }
+            }
         };
     }
 
-    public void blockMainThread() {
+    /**
+     * Runs the application and blocks the main thread and shutdown Camel graceful when the JVM is stopping.
+     */
+    public void run() {
+        LOG.debug("Controller is starting and waiting for Spring-Boot to stop or JVM to terminate");
         try {
-            mainSupport.run();
+            main.run();
+            // keep the daemon thread running
+            LOG.debug("Waiting for CamelContext to complete shutdown");
+            latch.await();
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
+        LOG.debug("CamelContext shutdown complete.");
+    }
+
+    /**
+     * @deprecated use {@link #run()}
+     */
+    @Deprecated
+    public void blockMainThread() {
+        run();
     }
 
     @PreDestroy
     private void destroy() {
-        mainSupport.completed();
+        main.completed();
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarRouter.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarRouter.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarRouter.java
index 94458ef..f5a376c 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarRouter.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/FatJarRouter.java
@@ -26,7 +26,7 @@ public class FatJarRouter extends RouteBuilder {
         ApplicationContext applicationContext = new SpringApplication(FatJarRouter.class).run(args);
         CamelSpringBootApplicationController applicationController =
                 applicationContext.getBean(CamelSpringBootApplicationController.class);
-        applicationController.blockMainThread();
+        applicationController.run();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/28c83d58/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
index 61b5378..6d589e5 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
@@ -64,11 +64,13 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
     // Overridden
 
     @Override
-    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
-        ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();
+    public void onApplicationEvent(ContextRefreshedEvent event) {
+        ApplicationContext applicationContext = event.getApplicationContext();
+
         // only listen to context refresh of "my" applicationContext
         if (this.applicationContext.equals(applicationContext)) {
-            CamelContext camelContext = contextRefreshedEvent.getApplicationContext().getBean(CamelContext.class);
+
+            CamelContext camelContext = event.getApplicationContext().getBean(CamelContext.class);
 
             // only add and start Camel if its stopped (initial state)
             if (camelContext.getStatus().isStopped()) {
@@ -100,16 +102,26 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
                     }
 
                     for (CamelContextConfiguration camelContextConfiguration : camelContextConfigurations) {
-                        LOG.debug("CamelContextConfiguration found. Invoking: {}", camelContextConfiguration);
+                        LOG.debug("CamelContextConfiguration found. Invoking beforeApplicationStart: {}", camelContextConfiguration);
                         camelContextConfiguration.beforeApplicationStart(camelContext);
                     }
 
-                    camelContext.start();
+                    if (configurationProperties.isMainRunController()) {
+                        LOG.info("Starting CamelMainRunController to ensure the main thread keeps running");
+                        CamelMainRunController controller = new CamelMainRunController(applicationContext, camelContext);
+                        // controller will start Camel
+                        controller.start();
+                    } else {
+                        // start camel manually
+                        camelContext.start();
+                    }
 
                     for (CamelContextConfiguration camelContextConfiguration : camelContextConfigurations) {
+                        LOG.debug("CamelContextConfiguration found. Invoking afterApplicationStart: {}", camelContextConfiguration);
                         camelContextConfiguration.afterApplicationStart(camelContext);
                     }
 
+
                 } catch (Exception e) {
                     throw new CamelSpringBootInitializationException(e);
                 }
@@ -117,7 +129,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
                 LOG.debug("Camel already started, not adding routes.");
             }
         } else {
-            LOG.debug("Ignore ContextRefreshedEvent: {}", contextRefreshedEvent);
+            LOG.debug("Ignore ContextRefreshedEvent: {}", event);
         }
     }