Enterprise Integration Patterns and Apache Camel

Topics Covered

  • What are EIPs?
  • EIPs Defined
  • Widgets and Gadets Example
  • Apache Camel and ActiveMQ
  • EIP in Action - Camel on Karaf (Fuse)
  • EIP in Action - Fuse on OpenShift
  • EIP in Action - Docker Container
  • EIP in Action - Camel on EAP

What are Enterprise Integration Patterns (EIP)?


Need for Integration

  • Hundreds/Thousands of applications
    • custom built
    • third party
    • combination
  • Multiple Operating System Platforms
  • Countless departmental solutions
  • SAP, Oracle, Peoplesoft, etc business software
  • Many websites

What are the challenges with Enterprise Application Integration (EAI)

  • Reliability of networks
  • Speed of networks
  • Applications are Heterogenous (Languages, Platforms, Data)
  • Application changes over time

Assumptions between parties

  • Platform Technology
    • internal representations of numbers and objects
  • Location
    • Hardcoded machine addresses
  • Time
    • All components have to be available at the same time
  • Data format
    • list of parameters and their types must match

Types of Integration

  • Information consistency
  • Data Replication
  • Shared business functions
  • Service-oriented architectures
  • Distributed business processes
  • Business-to-business integration

Integration Styles

  • File Transfer
    • Produce shared data files for others to consume; consume files that others have produced
  • Shared Database
    • share data from a common database
  • Remote Procedure Invocation
    • expose procedures for remote invocation; applications invoke those to initiate behavior and exchange data
  • Messaging
    • Applications connect to a common messaging system; exchange data and invoke behavior with messages


  • Not copy-paste code samples
  • Not shrink-wrap components
  • Learned over time by trial and error
  • Learned from other Integration Architects
  • Are solutions to frequently recurring problems

EIPs are known design patterns that provide solutions to problems faced during enterprise application integration


Basic Elements of an Example Integration Solution

EIPs Defined



EIP Categories

  • Integration Styles
  • Messaging Systems
  • Messaging Channels
  • Messaging Constructions
  • Message Routing
  • Message Transformation
  • Messaging Endpoints
  • System Management

Wire Tap

How do you inspect messages that travel on a point-to-point channel?


Message Filter

How can a component avoid receiving uninteresting messages?


Recipient List

How do we route a message to a list of dynamically specified recipients?



How can we process a message if it contains multiple elements, each of which may have to be processed in a different way?


Files Transfer

How can I integrate multiple applications so that they work together and can exchange information?


Shared Database

How can I integrate multiple applications so that they work together and can exchange information?


Remote Procedure Invocation

How can I integrate multiple applications so that they work together and can exchange information?



How can I integrate multiple applications so that they work together and can exchange information?


Message Channel

How does one application communicate with another using messaging?



How can two applications connected by a message channel exchange a piece of information?


Pipes and Filters

How can we perform complex processing on a message while maintaining independence and flexibility?


Message Router

How can you decouple individual processing steps so that messages can be passed to different filters depending on a set of conditions?


Message Translator

How can systems using different data formats communicate with each other using messaging?


Message Endpoint

How does an application connect to a messaging channel to send and receive messages?


Point-to-Point Channel

How can the caller be sure that exactly one receiver will receive the document or perform the call?


Publish-Subscribe Channel

How can the sender broadcast an event to all interested receivers?


Dead Channel Letter

What will the messaging system do with a message it cannot deliver?


Guaranteed Delivery

How can the sender make sure that a message will be delivered, even if the messaging system fails?


Message Bus

What is an architecture that enables separate applications to work together, but in a decoupled fashion such that applications can be easily added or removed without affecting the others?


Command Message

How can messaging be used to invoke a procedure in another application?


Document Message

How can messaging be used to transfer data between applications?


Event Message

How can messaging be used to transmit events from one application to another?



When an application sends a message, how can it get a response from the receiver?


Return Address

How does a replier know where to send the reply?


Correlation Identifier

How does a requestor that has received a reply know which request this is the reply for?


Content-Based Router

How do we handle a situation where the implementation of a single logical function (e.g., inventory check) is spread across multiple physical systems?


Dynamic Router

How can you avoid the dependency of the router on all possible destinations while maintaining its efficiency?



How do we combine the results of individual, but related messages so that they can be processed as a whole?



How can we get a stream of related but out-of-sequence messages back into the correct order?


Composed Message Processor

How can you maintain the overall message flow when processing a message consisting of multiple elements, each of which may require different processing?



How do you maintain the overall message flow when a message needs to be sent to multiple recipients, each of which may send a reply?


Routing Slip

How do we route a message consecutively through a series of processing steps when the sequence of steps is not known at design-time and may vary for each message?


Content Enricher

How do we communicate with another system if the message originator does not have all the required data items available?


Content Filter

How do you simplify dealing with a large message, when you are interested only in a few data items?


Claim Check

How can we reduce the data volume of message sent across the system without sacrificing information content?



How do you process messages that are semantically equivalent, but arrive in a different format?


Messaging Gateway

How do you encapsulate access to the messaging system from the rest of the application?


Messaging Mapper

How do you move data between domain objects and the messaging infrastructure while keeping the two independent of each other?


Transactional Client

How can a client control its transactions with the messaging system?


Polling Consumer

How can an application consume a message when the application is ready?


Event-Driven Consumer

How can an application automatically consume messages as they become available?


Competing Consumers

How can a messaging client process multiple messages concurrently?


Message Dispatcher

How can multiple consumers on a single channel coordinate their message processing?


Selective Consumer

How can a message consumer select which messages it wishes to receive?


Durable Subscriber

How can a subscriber avoid missing messages while it’s not listening for them?


Idempotent Receiver

How can a message receiver deal with duplicate messages?


Service Activator

How can an application design a service to be invoked both via various messaging technologies and via non-messaging techniques?



How can you route a message through intermediate steps to perform validation, testing or debugging functions?


Message Store

How can we report against message information without disturbing the loosely coupled and transient nature of a messaging system?


Widgets and Gadgets  Example

  • Take Orders
  • Process Orders
  • Check Status
  • Change Address
  • New Catalog
  • Announcements 
  • Testing and Monitoring



  • Use different integration strategies such as File TransferShared Database and synchronous Messaging 
  • Routed, split and aggregated messages
  • Add functions to monitor the correct operation of the solution 
  • While the requirements for this example were admittedly simplified the issues and design trade-offs we had to consider are very real
  • The solution diagrams and descriptions highlight how we can describe a solution in a vendor-and technology-neutral language that is much more accurate than a high-level sequence diagram

Take Orders from different Channels

Order Processing Implementation using Asynchronous Messaging

Routing the inventory request

Processing Orders Items Individually

Taking orders with Enricher

Revised Order Process Implementation

Adding a Message Store To Track Order Status

Tracking a message on a wiretap

Processing Orders With a Process Manager

Inserting a Smart Proxy to Turn a Legacy System Into a Shared Service

Including Address Data in the New Order Message

Propagating Address Changes via a Separate Publish-Subscribe Channel

Updating Catalog Data via File Transfer

Sending Announcements With a Dynamic Recipient List

Inserting a Smart Proxy to Track Response Times

Inserting Test Messages to Verify Accurate Results

What is Camel?

Apache ActiveMQ

  • Supports a variety of Cross Language Clients and Protocols from Java, C, C++, C#, Ruby, Perl, Python, PHP
    • OpenWire for high performance clients in Java, C, C++, C#
    • Stomp support so that clients can be written easily in C, Ruby, Perl, Python, PHP, ActionScript/Flash, Smalltalk to talk to ActiveMQ as well as any other popular Message Broker
    • AMQP and MQTT Support
  • full support for the Enterprise Integration Patterns both in the JMS client and the Message Broker
  • Supports pluggable transport protocols such as in-VM, TCP, SSL, NIO, UDP, multicast, JGroups and JXTA transports
  • Supports very fast persistence using JDBC along with a high performance journal
  • Designed for high performance clustering, client-server, peer based communication

Apache Camel

Gregor Hohpe and Bobby Woolfe's book, Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions, contains a set of sixty five Enterprise Integration Patterns (EIPs). 

Apache Camel is an open source Java framework that focuses on making integration easier and more accessible to developers. Camel provides:
•    implementations of the widely used EIPs 
•    connectivity to multiple transports and APIs
•    easy to use Domain Specific Language (DSL) to wire EIPs and transports together 

Apache Camel Architecture

Apache Camel and DSL

Camel uses a Java Domain Specific Language or DSL for creating Enterprise Integration Patterns or Routes in a variety of domain-specific languages (DSL) which includes:

  • 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
  • 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.

The main entry points for the DSL are

  • CamelContext for creating a Camel routing rulebase
  • RouteBuilder for creating a collection of routes using the routing DSL

Get Started with Camel

Camel uses a Java based Routing Domain Specific Language (DSL) or an Xml Configuration to configure routing and mediation rules which are added to a CamelContext to implement the various Enterprise Integration Patterns.


At a high level Camel consists of a CamelContext which contains a collection of Component instances.   A Component is essentially a factory of Endpoint instances. You can explicitly configure Component instances in Java code or an IoC container like Spring or Guice, or they can be auto-discovered using URIs.


An Endpoint acts rather like a URI or URL in a web application or a Destination in a JMS system; you can communicate with an endpoint; either sending messages to it or consuming messages from it. You can then create a Producer or Consumer on an Endpoint to exchange messages with it.


The DSL makes heavy use of pluggable Languages to create an Expression or Predicate to make a truly powerful DSL which is extensible to the most suitable language depending on your needs. 


To get started with Camel:

  1. Create a CamelContext.
  2. Optionally, configure components or endpoints.
  3. Add whatever routing rules you wish using the DSL and RouteBuilder or using Xml Configuration.
  4. Start the context.

JBoss A-MQ

JBoss A-MQ is a high performance, flexible messaging platform that delivers information safely, reliably and enables Internet of Things (IoT). JBoss A-MQ can be deployed, and easily managed, in any configuration so you can deploy a network of brokers across your infrastructure whether they are on premise, in the Cloud, or in a hybrid configuration.

Integrate everything, everywhere

JBoss Fuse is an open source Enterprise Service Bus (ESB) with an elastic footprint that supports integration beyond the data center. The ability to deploy JBoss Fuse in several different configurations enables intelligent integration to all facets of your business - on premise or in the Cloud.

JBoss Fuse

Integrate everything, everywhere

Fuse on xPaaS

With OpenShift you can easily deploy and run JBoss Fuse components like messaging brokers and containers and deploy solutions to connect applications and data using the most extensive set of messaging protocols and connectors.

  • Multi-Protocol
  • Dynamic
  • Visual Design
  • Integration by the book
  • Simplify the Lifecycle
  • Connectors
  • Simplify Development
  • Scale to meet your needs

Integrate everything, everywhere

pattern-based integration, apache Camel, in the cloud

EIP in Action - Standalone


Topics Covered during the demonstration

  • how to define a Camel route using the Blueprint XML syntax
  • how to build and deploy an OSGi bundle in JBoss Fuse
  • how to combine multiple Enterprise Integration Patterns to create an integration solution
  • how to use the Wiretap EIP to copy messages as they pass through a route
  • how to use the Splitter EIP to split large messages into smaller ones
  • how to use a Recipient List EIP to dynamically determine how a message passes through a route
  • how to use the Filter EIP to filter messages and execute logic for the ones that match the filter
  • how to define and use a bean to process a message
  • how to use a direct: endpoint to link multiple smaller routes together

Scenario for Demonstration

  • First we want to make sure we retain a copy of the original orders file containing several orders for zoos around the world we received. This is done using the Wiretap EIP.   
  •  After saving the original, we want to split the file up into the individual orders. This is done using the Splitter EIP.
  •  Then we want to store the orders in separate directories by geographical region. This is done using a Recipient List EIP.  
  •  Finally, we want to filter out the orders that container more than 100 animals and generate a message for the strategic account team. This is done using a Filter EIP.

Source Files used in the demonstration

Source files in the fuse-eip-quickstart project -

  • pom.xml - the Maven POM file for building the example

In src/main -

  • java/org.jboss.fuse.examples/eip/RegionSupport.java - a Java class used to determine the region code used by the recipient list
  • resources/OSGI-INF/blueprint/eip.xml - the OSGI Blueprint file that defines the routes

In src/test -

  • data/orders.xml - the data file that can be used to test the route
  • java/RegionSupportTest.java - a JUnit test class for RegionSupport

What are Camel URI Components?

  • http://camel.apache.org/file2.html - The File component provides access to file systems, allowing files to be processed by any other Camel Components or messages from other components to be saved to disk
  • http://camel.apache.org/direct.html - The direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange.  This endpoint can be used to connect existing routes in the same camel context. 

More information: http://camel.apache.org/components.html​

OSGI Blueprint File – eip.xml

<project_home>/projects/fuse-eip-quickstart/src/main/resources/OSGI-INF/blueprint/eip.xml - OSGI Blueprint file that defines the routes for our quickstart


This is the OSGi Blueprint XML file defining the Camel context and routes.  Because the file is in the OSGI-INF/blueprint directory inside our JAR, it will be automatically activated as soon as the artifact is installed.  The root element for any OSGi Blueprint file is 'blueprint' - you also see the namespace definitions for both the Blueprint and the Camel namespaces.
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">


We are using the OSGi Blueprint XML syntax to define a bean that we use in our Camel route to determine the geographical region. The code for this bean can be found in src/main/java/org.jboss.fuse.examples/eip/RegionSupport.java

<bean id="MyRegionSupport" class="org.jboss.fuse.examples.eip.RegionSupport" />
The namespace for the camelContext element in Blueprint is 'http://camel.apache.org/schema/blueprint'. We can also define namespace prefixes we want to use in the XPath expressions in our CBR here.  We defined the namespace prefix order so that we use the namespace from the order messages in the XPath expressions.  While it is not required to assign id's to the <camelContext/> and <route/> elements, it is a good idea to set them for runtime management purposes (logging, JMX MBeans, ...)
 <camelContext xmlns="http://camel.apache.org/schema/blueprint"

OSGI Blueprint File – eip.xml

This is the main Camel route.  In Camel, you can split up routes into more manageable bits and pieces and using a direct: endpoint to link those routes together again.  In this case, files will be sent to the direct:splitter endpoint after a wiretap has sent a copy of the message to the direct:wiretap endpoint.  The routes behind these endpoints are defined below. 
    <route id="mainRoute">
            <from uri="file:work/eip/input" />
            <log message="[main]    Processing ${file:name}" />
            <wireTap uri="direct:wiretap" />
            <to uri="direct:splitter" />
            <log message="[main]    Done processing ${file:name}" />
This route starts with the direct:wiretap endpoint we used in our main route.  Whenever the wiretap in the main route sends a message to this endpoint, the route below will log a human-friendly message and store a copy of the message in the work/eip/archive directory.
        <route id="wiretapRoute">
            <from uri="direct:wiretap" />
            <log message="[wiretap]  Archiving ${file:name}" />
            <to uri="file:work/eip/archive" />

OSGI Blueprint File – eip.xml

This route starts with the direct:splitter endpoint we used in our main route.  In this route, we will split a file containing multiple <order/> elements into separate messages, so we can store the orders in a separate directory for every geographical region.
     <route id="splitterRoute">
            <from uri="direct:splitter"/>
We are using XPath to split the message body. The namespace prefix, order, used in the XPath expression was defined on the camelContext element.
Headers can be used to add meta-data to the message without altering the actual message body.  In this case, we want to keep the order XML message, but we add two additional pieces of information:
                  - the order id : we use XPath to determine the order id
                  - the geographical region : we are using a method called getRegion() on the MyRegionSupport bean we defined earlier
                <setHeader headerName="orderId">
                <setHeader headerName="region">
                    <method bean="MyRegionSupport" method="getRegion" />

OSGI Blueprint File – eip.xml

Another human-friendly log message, this time using the extra headers we just added to the message
                <log message="[splitter] Shipping order ${header.orderId} to region ${header.region}"/>
A recipient list can be used to dynamically determine the next steps for a message.  In this case, we dynamically generate the file: endpoint uri using the two headers we defined earlier.  We will also send the message to the direct:filter endpoint to see if the order needs attention from our strategic account management team.


OSGI Blueprint File – eip.xml

This route starts with the direct:filter endpoint we used in the <recipientList> in our splitter route. It uses a Filter EIP to filter out the order messages that contain more than 100 animals in a single order.  For all messages that meet the XPath filter expression,  an extra message will appear in the logs.
        <route id="filterRoute">
            <from uri="direct:filter" />
                <xpath>sum(//order:quantity/text()) > 100</xpath>
                <log message="[filter]   Order ${header.orderId} is an order for more than 100 animals" />

OSGI Blueprint File – eip.xml

What is a OSGi Bundle?

The Open Services Gateway Initiative (OSGi) defines an architecture for developing and deploying modular applications and libraries.   OSGi offers the following advantages:

  • You can install, uninstall, start, and stop different modules of your application dynamically without restarting the container.
  • Your application can have more than one version of a particular module running at the same time.
  • OSGi provides very good infrastructure for developing service-oriented applications, as well as embedded, mobile, and rich internet apps.

In OSGi, software is distributed in the form of a bundle. A bundle consists of Java classes and other resources that deliver functions to device owners, as well as providing services and packages to other bundles.



Wiretap - System Management EIP

Wire Tap, from the EIP patterns, allows you to route messages to a separate location while they are being forwarded to the ultimate destination

<route id="mainRoute">
  <from uri="file:work/eip/input" />
  <log message="[main]    Processing ${file:name}" />
  <wireTap uri="direct:wiretap" />
  <to uri="direct:splitter" />
  <log message="[main]    Done processing ${file:name}" />

<route id="wiretapRoute">
  <from uri="direct:wiretap" />
  <log message="[wiretap]  Archiving ${file:name}" />
  <to uri="file:work/eip/archive" />

Splitter - Message Routing EIP

The Splitter, from the EIP patterns, allows you split a message into a number of pieces and process them individually

         <route id="splitterRoute">
            <from uri="direct:splitter"/>
                <setHeader headerName="orderId">
                <setHeader headerName="region">
                    <method bean="MyRegionSupport" method="getRegion" />
                <log message="[splitter] Shipping order ${header.orderId} to region ${header.region}"/>

Recipient List - Message Routing EIP

The Recipient List, from the EIP patterns, allows you to route messages to a number of dynamically specified recipients.


Message Filter - Message Routing EIP

The Message Filter, from the EIP patterns, allows you to filter messages.

        <route id="filterRoute">
            <from uri="direct:filter" />
                <xpath>sum(//order:quantity/text()) > 100</xpath>
                <log message="[filter]   Order ${header.orderId} is an order for more than 100 animals" />


Demonstration Steps

Step 1 – Install and Configure product used.  
View the README in 'installs' directory. 
Download the JBoss Fuse product from the Red Hat Customer Support Portal or JBoss.org 
Add to the installs directory.  
Update the zip filename in init.sh in the FUSE_BIN variable.

Step 2 - Run 'init.sh'
From the command prompt run the init script, ./init.sh, from the command line
View output for build success
sample posted to init.sh.output under the support folder 
View the eip-6.1.0.redhat-379.jar in the maven repository

Step 3 - Install and/or Setup JBDS for project import
Download JBDS
Create workspace /home/kpeeples/workspaces/fuse-eip-quickstart

Step 4 - Add the JBoss Fuse server
admin=redhat,admin update users.properties in /etc first
Run the new server wizard 
Select Red Hat JBoss Fuse 6.x Server
Select installed product under target folder
Enter admin/redhat from above


Demonstration Steps

Step 5 - Start JBoss Fuse server and the shell should display
[kpeeples@localhost bin]$ ./fuse Please wait while JBoss Fuse is loading... 100% [=================================================================]
JBoss Fuse(6.1.0.redhat-379)

Hit '' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '' or 'osgi:shutdown' to shutdown JBoss Fuse.

Step 6 - Import the existing maven project to review the files

Step 7 - Install the OSGi Bundle

Run osgi:install -s mvn:org.jboss.quickstarts.fuse/eip/6.1.0.redhat-379
Response should be the Bundle ID

Step 8 - View the OSGi list to make sure the Bundle has been created and active
Run osgi:list - l[ 254] [Active     ] [Created     ] [       ] [   60] JBoss Fuse :: Examples :: Enterprise Integration Patterns (6.1.0.redhat-379)


Demonstration Steps

Step 9 -  As soon as the Camel route has been started, you will see a directory `work/eip/input` in your JBoss Fuse installation.

Step 10 - Copy the file you find in this example's `src/test/data` directory to the newly created `work/eip/input` directory.

Step 11 -  Wait a few moment and you will find multiple files organized by geographical region under `work/eip/output':

** `2012_0003.xml` and `2012_0005.xml` in `work/eip/output/AMER`
** `2012_0020.xml` in `work/eip/output/APAC`
** `2012_0001.xml`, `2012_0002.xml` and `2012_0004.xml` in `work/eip/output/EMEA`

Step 12 -  Use `log:display` on the ESB shell to check out the business logging.

        [main]    Processing orders.xml
        [wiretap]  Archiving orders.xml
        [splitter] Shipping order 2012_0001 to region EMEA
        [splitter] Shipping order 2012_0002 to region EMEA
        [filter]   Order 2012_0002 is an order for more than 100 animals

Log Display

18:35:50,229 | INFO  | //work/eip/input | mainRoute                        | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [main]    Processing orders.xml
18:35:50,235 | INFO  | ead #2 - WireTap | wiretapRoute                     | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [wiretap]  Archiving orders.xml
18:35:50,268 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0001 to region EMEA
18:35:50,325 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0002 to region EMEA
18:35:50,369 | INFO  | //work/eip/input | filterRoute                      | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [filter]   Order 2012_0002 is an order for more than 100 animals
18:35:50,373 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0003 to region AMER
18:35:50,412 | INFO  | //work/eip/input | filterRoute                      | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [filter]   Order 2012_0003 is an order for more than 100 animals
18:35:50,415 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0004 to region EMEA
18:35:50,456 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0005 to region AMER
18:35:50,497 | INFO  | //work/eip/input | splitterRoute                    | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [splitter] Shipping order 2012_0020 to region APAC
18:35:50,539 | INFO  | //work/eip/input | mainRoute                        | 130 - org.apache.camel.camel-core - 2.10.0.redhat-60024 | [main]    Done processing orders.xml

EIP in Action - OpenShift

[to be updated with OpenShift]

EIP in Action - Docker

[to be updated with Docker]

Camel on EAP

[to be added]