Running Camel standalone and have it keep running

If you are using Camel as a standalone Java application, then Camel provides a Main class you can reuse to more easily boot up Camel and keep it running until the JVM terminates, for example when pressing ctrl + c.

The Main class is provided in the following two components

Using camel-core JAR example

Available as of Camel 2.6

The following example shows how you can create your main class, named MainExample and use the Main class from Camel.

{snippet:id=e1|lang=java|title=MainExample|url=camel/trunk/camel-core/src/test/java/org/apache/camel/main/MainExample.java}

Using camel-spring JAR example

This would be similar to the camel-core JAR example, however you would use the Main class from the org.apache.camel.spring package.
The Main class from camel-spring JAR has many more options and is prepared for booting Camel from Spring XML files.

See Also