Easy integration of Services with Apache Camel

What is Apache Camel

Apache camel is an integration framework based on known Enterprise Integration Patterns. Camel empowers you to define routing and mediation rules in a variety of domain-specific languages, including a Java-based Fluent API, Spring or Blueprint XML Configuration files.

The Apache Software Foundation oversaw 339 projects in 2019 — with a robust community of over 3,000 committers tweaking a huge 59,309,787 lines of code.

The most active project, by commits, was Apache Camel — a tool designed to allow enterprise developers to integrate a huge range of applications.

But as businesses seek to integrate more applications — e.g. to make combined use of the data they generate — Apache Camel is growing more important.

“You can use Java, Spring XML, Scala or Groovy. Almost every technology you can imagine is available, for example HTTP, FTP, JMS, EJB, JPA, RMI, JMS, JMX, LDAP, Netty etc. Besides, own custom components can be created very easily.”

Some of the DSL examples are

  • Java DSL

from (“file:/tmp”).to(“jms:aQueue”);

  • Spring DSL

<route>

  <from uri=”file:/tmp”/>

  <to uri=”jms:aQueue”/>

</route>

  • Scala DSL

from “file:/tmp” -> “jms:aQueue”

In all the above examples, we define a routing rule that will load files in the “/tmp” directory into memory,

Here is the Architecture ….

The use of Apache Camel……

When your application is getting data from various sources then Apache camel is best suggested. At a certain moment, when adding more sources, the code is getting littered with various client libraries and custom code that does message transformation is a good use case for Apache Camel. There is a clear way to define the integration and transformation required for the data from these sources. Besides, you can easily set up in-memory queueing to prevent overloading of certain calls in the application using for example the SEDA component. SEDA creates a pool of threads to process incoming messages. Also, Direct VM and VM components are provided to send messages to applications running on the same Java virtual machine

The framework also provides one set of concepts and models to argue about integration issues. The same concepts of endpoint and consumer can be used when getting data from an MQTT topic or when files are dropped in a directory or when processing a REST request. While Apache Camel is expressive and declarative, it does add complexity. A language is introduced in the codebase that a lot of developers are not familiar with.

Whats the Future…?

Apache Camel could be very useful in a system with microservices. In this case you have many services working together and Camel can play a role in integration. It is possible to create an elegant solution to do multiple calls to different services and combine the results. It also shows that Apache Camel provides support for circuit breaking like Hystrix. Another nice addition is a component for communicating with a cache provider like Ehcache. For the future of Apache Camel it would be benefical to have more components for communication with cloud services.

An alternative to Apache Camel is for example Spring Integration, which has similar features, but people tend to favor the syntax of Apache Camel. Another alternative is Mule ESB, but this is a more ready-to-use platform than a framework.

Related Posts

Leave a Reply