Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed typos

...

Available as of Camel 2.15

Spring Boot component provide provides auto-configuration for the 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.

...

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 the Camel for you.

Camel Spring Boot Starter

...

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

...

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

Code Block
languagejava
@Configuration
public class MyAppConfig {

  @Autowired
  CamelContext camelContext;

  @Bean
  MyService myService() {
    return new DefaultMyService(camelContext);
  }

}

...

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

Code Block
languagejava
@Component
public class MyRouter extends RouteBuilder {

  @Override
  public void configure() throws Exception {
    from("jms:invoices").to("file:/invoices");
  }

}


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

...

Spring Boot auto-configuration automatically connect 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 application.properties file:  

...

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

...

This feature is available starting from the 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 doesn't 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.

...