What is Apache Camel
August 14, 2020

What Is Apache Camel?

Open Source

Apache Camel, with its ability to handle complex aggregations, automatic error handling, and reduce boilerplate code used in complex integrations, is a top choice among open source middleware technologies.

In this blog, we give an overview of Apache Camel, including  how it works, its benefits, use cases, and how to apply it in your stack.

What Is Apache Camel?

Apache Camel is an open source framework for message-oriented middleware.

Apache Camel is the industry standard for reducing boilerplate code for complex integrations — while maintaining features like:

  • Automatic error handling
  • Redelivery policies.
  • The ability to handle complex aggregations.

Camel is a domain-specific language that’s an implementation of the enterprise integration patterns. It helps organizations solve some very specific problems.

Save Thousands on Middleware

Should you be paying for middleware? Find out. Watch the webinar below to learn how you can save thousands by using middleware like Camel.


Top Apache Camel Benefits

There are many benefits to using Camel. One of the biggest Camel benefits is that the testing of the Camel framework is outsourced to the community.

For example, the Camel framework is based on Spring. If you’re utilizing Spring data to consume data from a Postgres database, the only business logic your team is responsible for writing a test harness for is in your implementation of the Spring framework. Your development team isn’t writing unit tests to validate that Spring Data returns rows and columns as it should from the JDBC datasource, or any of the underlying technology that that framework is built off of. JNDI, the JVM, the Linux Kernel. 

There’s a lot that goes into a stack. And Apache Camel is the best choice to handle complexities of the code for handling the routing, transformation, scheduling, error handing, redelivery, and aggregation of batches and streams of messages.

Exercise to Introduce Apache Camel to New Developers

There’s a little exercise I like to do when introducing Apache Camel to new developers and development managers. I ask about a complex integration problem that the enterprise is currently facing or has written a solution around in the past.

For example, I've heard about the output of a timekeeping system disconnected from an API in a remote site like a factory that needs to be consumed to run payroll. Shell scripts automate the movement of this file via FTP. Certain columns need to be dropped for privacy, maybe because of GDPR or State of California privacy requirements regarding PII. 

There are sed, awk, and complicated, hard-to-test, easy-to-fail transformations that eventually connect to another integration, such as curling against a real API into the main NetSuite system for payroll.

Then, I ask about how many total lines of code are used to create the solution. Usually. it takes 100s or even 1,000s of lines of code if there’s error handling, complex transformations, routing, and aggregation.

Apache Camel can handle even the most complex of scenarios in 10, maybe 20 lines of code.

Overview of the Apache Camel Framework

Camel can handle complexity because it is an amazing component-driven, message-oriented routing, and normalization framework. The Camel framework is based on Spring. So, you can program Camel “routes” as XML, Scala, and — my favorite — fluent-style Java code. 

Camel provides an inversion of control (IoC) approach to data routing. This approach allows for a seamless transition of messaging data between a wide variety of integration components.

This variety can mean 100s of well-tested components. Consuming from OracleMQ, stripping a sensitive field like SSN from the JSON, and placing those messages onto a Kafka queue? Three lines of code.

Here's how it looks in the Camel framework:

apache camel example

The first line consumes messages from JMS, like ActiveMQ. The second uses JsonPath to pull the SSN from the record and replaces all SSN patterns with XXX-XXX-1234. The third line places the transformed message onto a Kafka topic.

How Camel Works

Camel's URI-based routing methodology allows for the composition of message consumers and producers at runtime based on config flags and environment variables. A Docker container can be written to dynamically route messages to and from locations based on operator need. 

I recently worked an architecture out with a financial institution where we would utilize Camel as a cron runner, with a definitive “finished” state, and allow Kubernetes to schedule it. Their use-case was log shipping from a black box system to ElasticSearch and Kibana for reporting. But there are a ton of integrations for Camel — including over 333 stable ones

Camel components


Is Apache Camel Still Relevant?

Absolutely. Camel works great in modern DevOps environments that rely on containers and Kubernetes. Camel is compatible with GraalVM and Quarkus, which means it can create native images that utilize 10% of the same memory of a traditional cloud stack. This is game-changing for distributed cloud applications.

camel framework

Focus More Time on Code That Matter to Your Enterprise

Camel makes it simple and scalable to attach 100s of different heterogeneous service endpoints in an efficient way.  It’s component-driven approach focuses on the reduction of boilerplate code while writing integration logic. 

When you use Camel, you spend more time writing code that matters to the enterprise. 

How to Make Camel Work Better For You

There are many benefits to using Camel. But making Camel work for you, especially if you're part of a large organization, can be tricky. That's why it's best to partner with the experts.

OpenLogic by Perforce has Camel experts available to support you. We offer Apache Camel training, consultative Camel support, and so much more. 

Our Camel experts can help you with:

  • Boilerplate reduction.
  • Dynamic routing.
  • Messaging resiliency. 
  • Integration patterns.
  • Security.

Get in touch with a Camel expert today and find out how we can help you maximize Camel.

talk to a CAMEL EXPERT