Enterprise Integration Patterns
Features > Enterprise Integration Patterns
Enterprise Integration Patterns
Version 5.0 onwards of Apache ActiveMQ Classic comes complete with full support for the Enterprise Integration Patterns (from the excellent book by Gregor Hohpe and Bobby Woolf) via the Apache Camel library.
You can easily add any of the supported Enterprise Integration Patterns into ActiveMQ Classic (either on the JMS client or in the broker process) to support smart routing, transformation and a whole host of other powerful patterns. You can of course just embed Camel library directly into your application, such as via Spring as well..
This also means you can cleanly integrate all of the Camel Components into ActiveMQ Classic so you can easily integrate with CXF, Files, JBI, JPA, Mail, MINA, Quartz, XMPP and many other protocols and transports!
Using EIP in the ActiveMQ Classic Broker
The broker’s activemq.xml
file comes already configured to support Camel; you just need to customize the routing rules.
Writing EIP rules using Java code
To use Java code to write EIP routing rules, just put your classes on the classpath (such as in activemq/lib/myroutes/foo.jar). Then to get Camel to find your routes you need to edit the activemq.xml so that the packages attribute points to the package name (or a parent package name) to look for.
For example if all your routes are in the package org.acme.cheese
such as org.acme.cheese.whatnot.MyRouter
then you could edit the XML to be…
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<package>org.acme.cheese</package>
</camelContext>
Writing EIP rules using XML
To use XML its even easier, as you can just embed whatever routing rules inside the <camelContext>
element using Camel’s Spring XML format. Note that the XML is way more verbose than the Java DSL but it is a bit simpler to deploy. e.g. for a trivial route…
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:com.acme.MyQueue"/>
<to uri="activemq:com.acme.SomeOtherQueue"/>
</route>
</camelContext>
Using EIP in the JMS client
You can use Camel Endpoints directly from your JMS client one of the following JMS destinations, depending on what JMS API you want it to use
You can then use this destination like any other JMS destination when sending or receiving messages! This means you can use any of the large number of Camel components from your JMS code, by just changing the Destination object!