Spring Boot Tutorial - Integrate Spring Boot + Apache Camel | JavaInUse

Spring Boot Tutorial- Integrate Spring Boot+ Apache Camel

In this example we see how to use Apache Camel with a Spring Boot Application.
Apache Camel is a rule-based routing and mediation engine that provides a Java object-based implementation of the Enterprise Integration Patterns using an API (or declarative Java Domain Specific Language) to configure routing and mediation rules. More tutorials for Apache Camel can be found in Apache Camel Section


This tutorial is explained in the below Youtube Video.

Lets Begin-

Maven Project will be as follows-

In the Maven we need the camel dependency.Maven will be as follows-
<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/xsd/maven-4.0.0.xsd">


Create the SpringBootHelloWorldApplication.java as below-
package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringBootHelloWorldApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringBootHelloWorldApplication.class, args);
Next we add class with the Camel routes.This routes will be started automatically.
package com.javainuse;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

public class MyRoute extends RouteBuilder {

	public void configure() throws Exception {

To keep the main thread blocked so that Camel stays up,add camel.springboot.main-run-controller=true to the application.properties.

This is the only code needed to get started.
Compile and the run the SpringBootHelloWorldApplication.java as a Java application.

As can be seen above one route has been started. It copies files from inputFolder to the outputFolder.

Download Source Code

Download it -
Spring Boot + Apache Camel

See Also

Spring Boot Hello World Application- Create simple controller and jsp view using Maven Spring Boot Tutorial-Spring Data JPA Spring Boot + Simple Security Configuration Pagination using Spring Boot Simple Example Spring Boot + ActiveMQ Hello world Example Spring Boot + Swagger Example Hello World Example Spring Boot + Swagger- Understanding the various Swagger Annotations Spring Boot Main Menu Spring Boot Interview Questions