In this post I would like to introduce a way to configure Apache Camel version 2.24.1 with the SQL component and Spring Boot 2.1. During the configuration of the project with such technology I encountered few problems, so I would like to describe it in a simple way.

This is root project build.gradle file:

plugins {
	id 'org.springframework.boot' version '2.1.7.RELEASE'
	id 'io.spring.dependency-management' version '1.0.8.RELEASE'
	id 'java'

group = 'pl.codeaddict'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-jdbc'
	implementation 'org.apache.camel:camel-spring-boot-starter:2.24.0'
	runtimeOnly ''
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	implementation 'org.apache.camel:camel-jdbc-starter:2.24.0'
	implementation 'org.apache.camel:camel-sql-starter:2.24.0'
	compileOnly 'org.projectlombok:lombok:1.18.8'
	annotationProcessor 'org.projectlombok:lombok:1.18.8'

As you can see when using Spring Boot, we should use Apache Camel starters and not standard Camel dependencies:

implementation 'org.apache.camel:camel-jdbc-starter:2.24.0'
implementation 'org.apache.camel:camel-sql-starter:2.24.0'

Below is the configuration from the file:


I added configuration of the connection to the MS SQL database. I wanted to show how the Apache Camel SQL component works. An unusual thing is the parameter camel.springboot.main-run-controller=true, it allows you to keep the application alive if you do not use Spring’s web components ( spring-boot-starter-web).

The whole application consists basically of one Apache Camel route which is to fetch rows from the database, map them to objects and log them in the console:

public class QueueSelectRoute extends RouteBuilder {

    public void configure() throws Exception {
                .to("sql:SELECT * FROM event_queue?dataSource=#dataSource")
                .process(xchg -> {
                    List<Map<String, Object>> row = xchg.getIn().getBody(List.class);
                            .map((x) -> {
                                EventQueue eventQueue = new EventQueue();
                                return eventQueue;
                .log(LoggingLevel.INFO,"******Database query executed - body:${body}******");



Note the use of ?dataSource=#dataSource. The dataSource name points to the DataSource object configured by Spring, it can be changed to another one and thus use different DataSource in different routes. Adding this parameter is required for proper operation of the application.

I added simple Liquibase scripts to the project to simplify project launch. You can also run docker container with MS SQL using below command:

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=QWE45rty' --name camel_example_db -p 1433:1433 -d

When your container is up you can run Liquibase scripts which will add simple tables and a few rows of data:

 ./gradlew -p db-schema update

Remember that this should be run from the main project directory and not from the db-schema catalog.

You can now start the applications by running ./gradlew bootRun command in project directory.

This is it! You can find all the source code in my repository GitHub account. Have fun and thanks for reading!