Introduction to Apache Camel: Part 1
By: Arun Mannuru
Tags: Java, Apache Camel, Middleware Pattern, Apache, Enterprise Integration

Learn Apache Camel architecture and how to implement some simple Camel Enterprise Integration Patterns

Overview

Camel is open source integration framework designed to integrate systems simply and easily. Apache Camel provides implementations of various Enterprise Integration Patterns (EIP).

It makes integration easier by providing connectivity to a very large variety of transports and APIs. Eg.. FTP to Kafka, HTTP to Kafka, FTP to HTTP etc.., as shown in fig (a):

Fig (a)

In distributed systems application development, connecting to different external systems is a complex process, as each system might have its own transportation channel and processes. Different systems use different message formats and so communication between systems will requires transformation of these messages.

Implementing code for end-to-end communication between the systems is one solution. However, this leads to tight coupling between the systems.Any change in one system will cause a lot of refactoring.

The best approach to this type of problem is to use a middleware framework. Middleware framework reduces complexity and provides a more flexible approach by adding and using a tier between the systems.

What is Apache Camel ?

Apache Camel is a light weight middleware framework that implements all EIPs and uses them either to run as a standalone application or in various containers. Apache Camel provides us with a number of components. Making use of these components will enable us to interact with other external systems. For example when using an ActiveMQ component we expose an ActiveMQ endpoint for interaction with external systems.

Apache Camel routes can be written in various Domain Specific Language(DSL). Most popular are :

Java DSL — A Java based DSL:

from(“file:inbox/fileName=text.csv”) .to(“file:outbox/fileName=”text.txt””);

Spring XML — A XML based DSL in Spring XML files:

<route>

<from uri=”file:inbox/fileName=”text.csv”/>

<to uri=”jms:queue:pedidos”/>

</route>

Architecture:

Camel Architecture consists of three components:

a) Routing Engine,

b) Processor and

c) Components

As illustrated in the following figure:

fig(b)

a) Routing Engine : Routing engine provides an endpoint interface to connect to external systems.Eg.., from(externalSystem). to(yourSystem).

b) Processor: The processors module is used for manipulating and mediating messages between endpoints. The EIPs that I mentioned earlier are implemented in this module.

c) Components: Apache Camel provides several pre-built components. Make use of them to communicate with external systems. Eg.., Camel-Kafka is used for communicating with Apache Kafka message brokers.

Conclusion:

Apache Camel is a lightweight integration tool that does not require an individual machine to use your integration system, and the language is very simple to understand. Moreover, it is an open source project, so everybody can collaborate with it, and we can consult the official documentation in the Apache Camel website http://camel.apache.org

References:

[a] Apache Camel — Documentation Architecture. http://camel.apache.org/architecture.html

[b] HOHPE, Gregor — Messaging Patterns Overview. http://www.enterpriseintegrationpatterns.com/patterns/messaging/