What is Apache Camel?

I recently had an opportunity to get to know Apache Camel and I have to say I'm impressed by how powerful and easy it is to use. In this first post of my blog I'm going to explain what Camel is and show a basic example of how to use it.

Apache Camel is an Open Source Java Framework based on Enterprise Integration Patterns. If you don't know what Enterprise Integration Patterns are, I suggest you to read about it first.

Enterprise Integration Patterns - EIPs


EIPs offer solutions for Enterprise Integration problems. Patterns use messages which are transported from component to component through message channels. EIPs describes how to route messages, transform messages, distribute them to different endpoints and how application connects to other.

A simple example would be to transfer csv file data to a relational database which resides in a different system.

This would be easily implemented with Apache Camel.

Apache Camel


Basically Camel is a routing engine for messages. You define routing rules, select sources where to get the message, define what to do with the message and tell where to finally send the message.One of the most impressing things with Camel is, it can handle almost any kind of protocol and data.

You can use Java, Scala or XML to define routine rules and business logic with Camel's Domain-Specific Language (DSL). Or you can use them all at the same time.

Following route is equilavent with all three languages:

Java DSL:
from("ftp://foo@myserver?password=secret").to("file:src/data");

Spring DSL:

<from uri="ftp://foo@myserver?password=secret"/>
<to uri="file:src/data"/>


Scala DSL:
from "file:data/inbox" -> "jms:queue:order"

Camel implements EIPs with routes, processors and endpoints. 

A route starts from an endpoint and ends to an endpoint. This process is defined in a processor. A route can chain multiple EIPs so you can can create as complicated routes as you wish.