| <div class="wiki-content maincontent"><h2>Enterprise Integration Patterns</h2> |
| |
| <p>Version 5.0 onwards of Apache ActiveMQ comes complete with full support for the <a shape="rect" href="http://www.enterpriseintegrationpatterns.com/toc.html">Enterprise Integration Patterns</a> (from the excellent book by <a shape="rect" href="http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?%5Fencoding=UTF8&search-type=ss&index=books&field-author=Gregor%20Hohpe">Gregor Hohpe</a> and <a shape="rect" href="http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?%5Fencoding=UTF8&search-type=ss&index=books&field-author=Bobby%20Woolf">Bobby Woolf</a>) via the <a shape="rect" href="http://activemq.apache.org/camel/">Apache Camel library</a>. </p> |
| |
| <p>You can easily add any of the supported <a shape="rect" href="http://activemq.apache.org/camel/enterprise-integration-patterns.html">Enterprise Integration Patterns</a> into ActiveMQ (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 <a shape="rect" href="http://activemq.apache.org/camel/">Camel library</a> directly into your application, such as via <a shape="rect" href="http://activemq.apache.org/camel/spring.html">Spring</a> as well..</p> |
| |
| <p>This also means you can cleanly integrate all of the <a shape="rect" href="http://activemq.apache.org/camel/components.html">Camel Components</a> into ActiveMQ so you can easily integrate with <a shape="rect" href="http://activemq.apache.org/camel/cxf.html">CXF</a>, <a shape="rect" href="http://activemq.apache.org/camel/file.html">Files</a>, <a shape="rect" href="http://activemq.apache.org/camel/jbi.html">JBI</a>, <a shape="rect" href="http://activemq.apache.org/camel/jpa.html">JPA</a>, <a shape="rect" href="http://activemq.apache.org/camel/mail.html">Mail</a>, <a shape="rect" href="http://activemq.apache.org/camel/mina.html">MINA</a>, <a shape="rect" href="http://activemq.apache.org/camel/quartz.html">Quartz</a>, <a shape="rect" href="http://activemq.apache.org/camel/xmpp.html">XMPP</a> and <a shape="rect" href="http://activemq.apache.org/camel/components.html">many other protocols and transports!</a></p> |
| |
| |
| <h3>Using EIP in the ActiveMQ Broker</h3> |
| |
| <p>The broker's <strong>activemq.xml</strong> file comes already configured to support Camel; you just need to customize the routing rules.</p> |
| |
| <h4>Writing EIP rules using Java code</h4> |
| |
| <p>To use <a shape="rect" href="http://activemq.apache.org/camel/dsl.html">Java code to write EIP routing rules</a>, 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 <strong>packages</strong> attribute points to the package name (or a parent package name) to look for.</p> |
| |
| <p>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...</p> |
| |
| <structured-macro ac:macro-id="08391332-f1a6-460a-bfe5-58a3b1d4cc39" ac:name="code" ac:schema-version="1"><plain-text-body> |
| <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> |
| <package>org.acme.cheese</package> |
| </camelContext> |
| </plain-text-body></structured-macro> |
| |
| <h4>Writing EIP rules using XML</h4> |
| |
| <p>To use XML its even easier, as you can just embed whatever routing rules inside the <camelContext> element using Camel's <a shape="rect" href="http://activemq.apache.org/camel/xml-configuration.html">Spring XML format</a>. Note that the XML is way more verbose than the <a shape="rect" href="http://activemq.apache.org/camel/dsl.html">Java DSL</a> but it is a bit simpler to deploy. e.g. for a trivial route...</p> |
| |
| <structured-macro ac:macro-id="a14e2d08-d3c4-484d-8b0c-71443cb4ef06" ac:name="code" ac:schema-version="1"><plain-text-body> |
| <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> |
| <route> |
| <from uri="activemq:com.acme.MyQueue"/> |
| <to uri="activemq:com.acme.SomeOtherQueue"/> |
| </route> |
| </camelContext> |
| </plain-text-body></structured-macro> |
| |
| <h3>Using EIP in the JMS client</h3> |
| |
| <p>You can use <a shape="rect" href="http://activemq.apache.org/camel/">Camel</a> <a shape="rect" href="http://activemq.apache.org/camel/endpoint.html">Endpoints</a> directly from your JMS client one of the following JMS destinations, depending on what JMS API you want it to use</p> |
| |
| <ul><li><a shape="rect" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/camel/CamelDestination.html">CamelDestination</a></li><li><a shape="rect" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/camel/CamelQueue.html">CamelQueue</a></li><li><a shape="rect" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/camel/CamelTopic.html">CamelTopic</a></li></ul> |
| |
| |
| <p>You can then use this destination like any other JMS destination when sending or receiving messages! This means you can use any of the <a shape="rect" href="http://activemq.apache.org/camel/components.html">large number of Camel components</a> from your JMS code, by just changing the Destination object!</p> |
| |
| <h3>See Also</h3> |
| |
| <ul><li><a shape="rect" href="http://activemq.apache.org/camel/enterprise-integration-patterns.html">Enterprise Integration Patterns</a></li><li><a shape="rect" href="http://activemq.apache.org/camel/components.html">Camel Components</a></li><li><a shape="rect" href="http://activemq.apache.org/camel/xml-reference.html">Camel XML Reference</a></li></ul> |
| </div> |
| |