Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the asciidoc in the repository:

Spring Boot

Available as of Camel 2.15

Spring Boot component provides auto-configuration for Apache Camel. Our opinionated auto-configuration of the Camel context auto-detects Camel routes available in the Spring context and registers the key Camel utilities (like producer template, consumer template and the type converter) as beans.

Maven users will need to add the following dependency to their pom.xml in order to use this component:

camel-spring-boot jar comes with the spring.factories file, so as soon as you add that dependency into your classpath, Spring Boot will automatically auto-configure Camel for you.

Camel Spring Boot Starter

Available as of Camel 2.17

Apache Camel ships a Spring Boot Starter module that allows you to develop Spring Boot applications using starters. There is a sample application in the source code also.

To use the starter, add the following to your spring boot pom.xml file:

Then you can just add classes with your Camel routes such as:

Then these routes will be started automatically. To keep the main thread blocked so that Camel stays up, either include the spring-boot-starter-web dependency, or add camel.springboot.main-run-controller=true to your or application.yml file. 

You can further customize the Camel application in the or application.yml file with camel.springboot.* properties.

Auto-Configured Camel Context

The most important piece of functionality provided by the Camel auto-configuration is CamelContext instance. Camel auto-configuration creates a SpringCamelContext for you and takes care of the proper initialization and shutdown of that context. The created Camel context is also registered in the Spring application context (under camelContext bean name), so you can access it just as  any other Spring bean.

Auto-Detecting Camel Routes

Camel auto-configuration collects all the RouteBuilder instances from the Spring context and automatically injects them into the provided CamelContext. That means that creating new Camel route with the Spring Boot starter is as simple as adding the @Component annotated class to your classpath:

...or creating a new route RouteBuilder bean in your @Configuration class:

Camel properties

Spring Boot auto-configuration automatically connects to Spring Boot external configuration (like properties placeholders, OS environment variables or system properties) with the Camel properties support. It basically means that any property defined in file:  

...or set via system property...

...can be used as placeholders in Camel route:

Custom Camel Context Configuration

If you would like to perform some operations on CamelContext bean created by Camel auto-configuration, register CamelContextConfiguration instance in your Spring context:

Method CamelContextConfiguration#beforeApplicationStart(CamelContext) will be called just before the Spring context is started, so the CamelContext instance passed to this callback is fully auto-configured. You can add many instances of CamelContextConfiguration into your Spring context - all of them will be executed.

Disabling JMX

To disable JMX of the auto-configured CamelContext use camel.springboot.jmxEnabled property (JMX is enabled by default). For example you could add the following property to your file:

Auto-Configured Consumer and Producer Templates

Camel auto-configuration provides pre-configured ConsumerTemplate and ProducerTemplate instances. You can simply inject them into your Spring-managed beans:

By default consumer templates and producer templates come with the endpoint cache sizes set to 1000. You can change those values via the following Spring properties:

Auto-Configured TypeConverter

Camel auto-configuration registers a TypeConverter instance named typeConverter in the Spring context.

Spring Type Conversion API Bridge

Spring comes with the powerful type conversion API. Spring API happens to be very similar to the Camel type converter API. As those APIs are so similar, Camel Spring Boot automatically registers a bridge converter (SpringTypeConverter) that delegates to the Spring conversion API.That means that out-of-the-box Camel will treat Spring Converters like Camel ones. With this approach you can enjoy both Camel and Spring converters accessed via Camel TypeConverter API:


Under the hood Camel Spring Boot delegates conversion to the Spring's ConversionService instances available in the application context. If no ConversionService instance is available, Camel Spring Boot auto-configuration will create one for you.

Disabling Type Conversions Features

If you don't want Camel Spring Boot to register type-conversions related features (like TypeConverter instance or Spring bridge) set the camel.springboot.typeConversion property to false.

Fat Jars and Fat Wars

The easiest way to create a Camel-aware Spring Boot fat jar/war is to extend the org.apache.camel.spring.boot.FatJarRouter class:



...and add the following property to your file:


It is also recommended to define your main class explicitly in the Spring Boot Maven plugin configuration: 

In order to turn your fat jar into fat war, add the following class extending  org.apache.camel.spring.boot.FatWarInitializer to your project:

Blocking Main Thread

This feature is available starting from Camel 2.15.2. Camel applications extending FatJarRouter by default block the main thread of the application. It means that after you start your fat jar, your application waits for Ctrl+C signal and does not exit immediately. If you would like to achieve similar behavior for non-FatJarRouter applications, retrieve CamelSpringBootApplicationController bean from your ApplicationContext and use the former to block the main thread of your application using CamelSpringBootApplicationController#blockMainThread() method.

Adding XML Routes

By default you can put Camel XML routes in the classpath under the directory camel, which camel-spring-boot will auto detect and include. From Camel 2.17: you can configure the directory name or turn this off using the configuration option:

The XML files should be Camel XML routes (not CamelContext) such as

Adding Rest-DSL

Available since Camel 2.18

By default you can put Camel Rest-DSL XML routes in the classpath under the directory camel-rest, which camel-spring-boot will auto detect and include.


You can configure the directory name or turn this off using the configuration option:

The Rest-DSL XML files should be Camel XML rests (not CamelContext) such as

Unit Tests

Below is a sample unit test set up for camel spring-boot. 

See Also

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram