Introduction
Apache camel is an open-source framework. Apache Camel is a rule-based routing and mediation engine that provides a Java object-based implementation of the Enterprise Integration Patterns using an API to configure routing and mediation rules. We can say it is a domain-specific language means that Apache Camel can support type-safe smart completion of routing rules in an integrated development environment using regular Java code without large amounts of XML configuration files, though XML configuration inside Spring is also supported.
Apache camel is an open-source framework that provides a rule-based routing and mediation engine. It essentially provides an implementation of various EIPs. It makes integration easier by providing connectivity to a huge variety of transports and APIs example, you can easily route JMS to JSON, JSON to JMS, HTTP to JMS, FTP to JMS, and even HTTP to HTTP, and connectivity to Microservices. You simply need to provide appropriate endpoints at both ends.
Overview
Camel is extensible so can say it would be very useful in the future more endpoints can be added easily to the framework. Camel is often used with Apache ServiceMix, Apache ActiveMQ, and Apache CXF in service-oriented architecture infrastructure projects
When there is a requirement to connect the systems, you will probably need to connect to some data source and then process this data to match your business requirements.
In order to do that:
1) You could develop a custom program that would do it (might be time-consuming and hard to understand, and maintain for another developer)
2) Alternatively, you could use it to do it in a standardized way (it has most of the connectors already developed for you, you just need to set it up and plug your logic – called Process):
Camel will help you to:
* Consume data from any source/format
* Process this data
Output data to any source/format
By using Apache Camel it will become very easy to understand/maintain/extend your system to another developer.
Apache Camel is developed with Enterprise Integration Patterns. And we know it is an open-source framework as well, The patterns help you to integrate systems in a good way
Apache Camel is an open-source framework. The purpose of ‘”Apache Camel”‘ is to route ‘messages’ from one ‘system’ to another one in the world. Apache camel uses different transport mechanisms. Message routing Apache Camel picks up messages using the ‘Camel based Component’ of the ‘from’ system and drops them using the ‘Camel based Component’ of the ‘to’ system. A message may route to multiple systems, but everywhere
they have to go through ‘Camel based Components’ to travel between ‘Apache Camel’s underlying transport mechanism’ and the system. Camel helps in routing, transformation, and monitoring. Its uses Routes can be described as :
When a service bus receives a particular message, it will route it through no of services/broker destinations such as queue/topics. This path is known as the route
For example, if your stock application has got some input from the analyzer, it will be processed through the application component and then the result will be published to all the registered members for the particular stock update.
Creating a custom solution for the above business problem would mean writing a lot of Java code. We would need to map and transform the Request objects from their source formats to the target format. We can use Java threads to invoke both of the airline web services in parallel set up event listeners to wait for both services to respond aggregate the responses and also manage supporting tasks like logging and exception handling. Using Apache Camel as an integration framework shortcuts a lot of programming. We can simply leverage Camel’s API and components, which are designed to resolve most web services integration tasks with standard enterprise integration patterns (EIPs). Rather than Java code, we’ll work with a streamlined domain-specific language (DSL).
Apache Camel provides DSLs based on Java, Scala, Groovy, or XML. In this case, we’ll use Camel’s XML-based Spring DSL to specify the routing and configure our integration layer.
When to use Apache camel:-
Apache Camel is awesome if you want to integrate several applications with different protocols and technologies. Why? There is one feature (besides supporting so many technologies and supporting different programming languages) that is really appreciated a lot: Every integration uses the same concepts! No matter which protocol you use. No matter which domain-specific language (DSL) you use – it can be Java, Scala, Groovy, or Spring XML. You do it the same way. Always! There is a producer, there is a consumer, there are endpoints, there are EIPs, there are custom processors and there are parameters.
It is a black box that receives messages from some endpoint and sends it to another one. Within the black box, the messages may be processed or simply redirected.

Apache Camel is an open-source framework. It is a message-oriented middleware that provides a rule-based routing and a mediation engine. You can define rules such as if it is a “milk” order redirect it to a milk vendor and if it is an “oil” order redirect it to an oil vendor, and so on. Using Camel, you will be able to implement these rules and do the routing in a familiar Java code.
It means that you can use your familiar Java IDE to define these rules in a type-safe environment. We do not need to use XML configuration files, which typically tend to be bulky. Camel through supports XML configuration through the Spring framework, if you prefer to use XML for configuring the rules. You may even use Blueprint XML Configuration files and even a Scala DSL if you are a Scala lover. It also means that you can use your favorite Java, Scala IDE, or even a simple XML editor to configure the rules.
The input to this engine can be a comma-delimited text file, a POJO (Plain Old Java Object), or XML are of the several other formats supported by Camel. Similarly, the output of the engine can be redirected to a file, to a message queue, or even to your monitor screen for you to view the orders sent to respective vendors.
Features:-
We already know Apache Camel is an open-source Java framework that essentially provides an implementation of various EIPs. Camel makes the integration easier by providing connectivity to a very large variety of transports and APIs. For example, you can easily route JMS to JSON, JSON to JMS, HTTP to JMS, FTP to JMS, even HTTP to HTTP, and connectivity to Microservices. You simply need to provide appropriate endpoints at both ends. Camel is extensible and thus in the future, more endpoints can be added easily to the framework.
Camel HelloWorld example -:
Here is its route.we use camel’s timer component
from(“timer://myTimer?period=2000”)
.setBody()
.simple(“Hello World Camel fired at ${header.firedTime}”)
.to(“stream:out”);
We can configure the timer component in the URI itself timer://myTimer?period=2000. Our timer component name is myTimer and it triggers off every 2000ms.
It sends the text ‘Hello World Camel fired at ${header.firedTime} to the standard output every 2000ms.
${header.firedTime} will be replaced with the fired time.
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class CamelHelloWorldTimerExample {
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("timer://myTimer?period=2000")
.setBody()
.simple("Hello World Camel fired at ${header.firedTime}")
.to("stream:out");
}
});
context.start();
Thread.sleep(10000);
} finally {
context.stop();
}
}
}
Conclusion
As we know Apache Camel is an open-source framework so it provides a ready-to-use framework that implements EIPs to ease your integration projects. It supports coding in domain-specific languages and also the use of XML.