Getting Started with Apache Camel – With SpringBoot

Getting started with Apache Camel

In this blog article, I want to show you how to get started with apache camel. Less to read and see more code 🙂 Let’s get started!

First, check out this spring boot projekt.

First Route

Now go to class CamelRoute. This shoud now look like this


This is your first exposure to a camel route. As you can see you have to extend from „RouteBuilder„. This is now the area you can define your own camel routes.

In this case, we have the timer-component from camel. This means we trigger this route every 10000 milliseconds.

Next, we log „test“, which you should see every 10 seconds. In the next step, we set the content of our body. And in the final step, we send it to the file endpoint. If you search for the directory outputPath, there should be a file generated. (Sometimes the directory doesn’t always show up in the IDEA if spring-boot is still running. Refresh the directories and you should see it 😉 )


Congratulation, you just saw your first camel route.

Let’s shortly dig a bit deeper into what actually happened.

From – Timer

In Apache Camel, the „from“ is a keyword used to specify the starting endpoint of a route. An endpoint is a location where Camel can receive messages, e.g. JMS messages. In our case, we have a Timer-Endpoint, which starts itself periodically. The URI of the endpoint follows the „from“ keyword, and it marks the beginning of the route definition. But you can use any component you want in the from part. Camel offers ALOT of components (JMS, DB, Rest, File), so you are free to experiment yourself. Checkout my other guides to see how they work 🙂

Set Body – Introduction to Exchange and Body

To route, the messages from Point A to B (from timer to file) camel containerizes the message in an exchange object. The message has a body, which will be written to the file-content.

To File Endpoint

Now in the last step, we are sending our exchange to the file endpoint. We define the targetpath and the filename. As said before, the content of the file is determined by the body of the exchange-message. You can use many more optional parameters, check out the file-component of camel. To see the file-component more in actions and how to play around more, check out this page.

Check out my tutorial Beginner Guide!

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Scroll to Top