Apache Camel is an open-source integration framework that implements Enterprise Integration Patterns (EIPs). It enables communication between applications, APIs, databases, messaging systems, cloud services, and files using a simple routing engine.
| Concept | Description |
|---|---|
| CamelContext | Runtime container that manages routes and components. |
| Route | Flow of messages from source to destination. |
| Processor | Custom business logic executed inside routes. |
| Exchange | Message container carrying body, headers, and properties. |
| Message | Actual payload being processed. |
| DSL | Description |
|---|---|
| Java DSL | Programmatic route configuration. |
| Spring XML DSL | XML-based route definitions. |
| YAML DSL | Declarative route configuration. |
| Groovy / Kotlin | Alternative DSLs. |
| Pattern | Usage |
|---|---|
| Content-Based Router | Route based on message content. |
| Splitter | Break one message into many. |
| Aggregator | Combine multiple messages. |
| Recipient List | Dynamic routing to multiple endpoints. |
| Wire Tap | Copy message to another route. |
| Dead Letter Channel | Handles failed messages. |
| Retry / Redelivery | Retry failed processing. |
| Idempotent Consumer | Avoid duplicate processing. |
| Category | Components |
|---|---|
| File | file, ftp, sftp |
| Messaging | jms, kafka, rabbitmq, activemq |
| HTTP | http, rest, servlet, netty-http |
| Database | jdbc, sql, jpa, mybatis |
| Cloud | aws-sqs, azure-storage-queue, gcp-pubsub |
| Scheduling | timer, quartz |
| Feature | Description |
|---|---|
| DefaultErrorHandler | Retries with backoff policy. |
| DeadLetterChannel | Moves failed messages to DLQ. |
| OnException | Handle specific exceptions. |
| Try-Catch-Finally | Structured exception handling. |
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
Camel routes are automatically discovered and loaded by Spring Boot.
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-rabbitmq-starter</artifactId>
</dependency>
<route id="direct-to-rabbitmq">
<from uri="direct:sendToRabbit"/>
<to uri=
"rabbitmq:exchange1?routingKey=mykey&queue=myqueue"/>
</route>
<route id="rabbitmq-to-logger">
<from uri=
"rabbitmq:exchange1?routingKey=mykey&queue=myqueue"/>
<log message=
"Received from RabbitMQ: ${body}"/>
</route>
Combines billing, inventory, and shipping messages into a complete order.
from("direct:transactions")
.choice()
.when(simple("${body.amount} > 500000"))
.to("direct:manualReview")
.otherwise()
.to("direct:autoProcess");
from("direct:bulkInvoice")
.split()
.jsonpath("$.items")
.to("direct:processLineItem");
from("direct:orderShipped")
.recipientList(header("emailRecipients"));
from("direct:paymentProcessed")
.wireTap("direct:auditService")
.to("direct:continueProcessing");
from("direct:startApproval")
.routingSlip(header("approvalSteps"));
errorHandler(
deadLetterChannel("jms:deadLetterQueue")
.maximumRedeliveries(3)
.redeliveryDelay(2000)
);
from("direct:paymentRequest")
.to("bean:paymentService");
| Tool | Purpose |
|---|---|
| CamelTestSupport | Unit testing Camel routes. |
| AdviceWith | Modify routes during testing. |
| JMX | Monitor routes and metrics. |
| Hawt.io | Web UI for route monitoring. |
| Jolokia | JMX over HTTP. |
| Abbreviation | Meaning |
|---|---|
| EIP | Enterprise Integration Pattern |
| DSL | Domain Specific Language |
| JMS | Java Message Service |
| DLQ | Dead Letter Queue |
| SEDA | Staged Event Driven Architecture |
| JMX | Java Management Extensions |
| KEDA | Kubernetes Event Driven Autoscaling |
| OAS | OpenAPI Specification |
Source Endpoint
|
v
Route
|
v
Processor
|
v
Transformation
|
v
Destination Endpoint
Apache Camel is an integration framework that implements Enterprise Integration Patterns (EIPs) to connect different systems.
from("file:input")
.to("jms:queue:orders");
CamelContext is the runtime container that manages routes, components, endpoints, and services.
CamelContext context = new DefaultCamelContext();
context.start();
Exchange is the message container that carries data between endpoints.
exchange.getIn().getBody(String.class);
Processor: Contains business logic.
Route: Defines message flow.
from("direct:start")
.process(new MyProcessor())
.to("log:output");
Enterprise Integration Patterns are reusable solutions for integration problems.
Examples: Splitter, Aggregator, Router, Filter, Dead Letter Channel.
Splitter: Splits one message into multiple messages.
Aggregator: Combines multiple messages into one.
from("direct:start")
.split(body())
.to("log:item");
Handles failed messages and redirects them to an error queue.
errorHandler(
deadLetterChannel("jms:queue:error")
);
Routes messages based on content or conditions.
from("direct:start")
.choice()
.when(header("type").isEqualTo("A"))
.to("direct:A")
.otherwise()
.to("direct:B");
SEDA (Staged Event-Driven Architecture) enables asynchronous processing using an in-memory queue.
from("seda:orders")
.to("bean:orderService");
| Camel K | Camel Spring Boot |
|---|---|
| Runs natively on Kubernetes/OpenShift | Runs as Spring Boot application |
| Serverless Integration | Microservice Integration |
| Lightweight | Full Spring Ecosystem |
Use RabbitMQ component to publish and consume messages.
from("rabbitmq:orders")
.to("bean:orderProcessor");
management.endpoints.web.exposure.include=*