In the earlier post, we have seen What is Apache Camel ? In this tutorial, we will learn about Why to use Apache Camel ?
When we have many frameworks available, you might think why to use Apache Camel ? What features does Apache Camel provide etc. ? Let’s see what is Apache Camel and the features it provides and why to use Apache Camel.
Apache Camel is an open-source integration framework based on Enterprise Integration Patterns. This framework allows you to define your own routing rules, decide from which message sources to accept messages and determine how to process/translate/enrich and send those messages to other destinations.
Apache Camel is an integration framework with rich set of features. Using these features we can develop applications easily. Due to these rich set of features in Camel, we should Apache Camel.
It provides following features:
1) Routing and mediation engine
2) Enterprise integration patterns (EIPs)
3) Domain-specific language (DSL)
4) Extensive component library
5) Payload-agnostic router
6) POJO model
7) Easy configuration
Let’s see each of these in detail.
1) Routing and mediation engine:
The main feature of Camel is its routing and mediation engine. Apache Camel acts as routing engine and will move a message around, based on the route’s configuration. Routes in Camel are configured with a combination of enterprise integration patterns and a domain-specific language.
2) Enterprise integration patterns (EIPs):
Enterprise integration patterns are known design patterns that provide solutions to issues/problems faced during application integration. Camel is heavily based on EIPs. Patterns are divided into seven sections:
1. Messaging Systems
2. Messaging Channels
3. Message Constructions
4. Message Routing
5. Message Transformation
6. Messaging endpoints
7. System management
3) Domain-specific language (DSL):
All integration routes are defined in Camel through its own domain-specific language (DSL). Camel offers multiple DSLs in regular programming languages such as Java, Scala, Groovy, and it also allows routing rules to be specified in XML. The purpose of the DSL is to allow the developer to focus on the integration problem
rather than on the tool—the programming language.
Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes in a variety of domain-specific languages (DSL) as listed below.
Java DSL – A Java based DSL using the fluent builder style.
Spring XML – A XML based DSL in Spring XML files
Blueprint XML – A XML based DSL in OSGi Blueprint XML files
Rest DSL – A DSL to define REST services using a REST style in either Java or XML.
Groovy DSL – A Groovy based DSL using Groovy programming language
Scala DSL – A Scala based DSL using Scala programming language
Annotation DSL – Use annotations in Java beans.
4) Extensive component library:
Camel provides an extensive library of more than 80 components.
5) Payload-agnostic router:
Camel is payload-agnostic. This means that it can support any kind of message. Depending on the endpoints, it could be required to convert from one format to another. Camel can route any kind of payload—you aren’t restricted to carrying XML payloads.
6) POJO model:
Camel allows to use beans anywhere and anytime in the integration projects.
7) Easy Configuration:
Configuring endpoints as routes is very easy in Camel. Camel uses a different approach based on URI. The endpoint itself and its configuration are on the URI. The URI is human readable and provides the details of the endpoint, which is the endpoint component and the endpoint configuration.
Camel itself is very light. The Camel core is only around 2 MB, and contains everything required to run Camel.