Modified: websites/production/camel/content/book-pattern-appendix.html ============================================================================== --- websites/production/camel/content/book-pattern-appendix.html (original) +++ websites/production/camel/content/book-pattern-appendix.html Thu Sep 11 10:19:20 2014 @@ -92,18 +92,13 @@ <p>There now follows a breakdown of the various <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/toc.html" rel="nofollow">Enterprise Integration Patterns</a> that Camel supports</p> <h2 id="BookPatternAppendix-MessagingSystems">Messaging Systems</h2> -<h3 id="BookPatternAppendix-MessageChannel">Message Channel</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/MessageChannel.html" rel="nofollow">Message Channel</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a>. The Message Channel is an internal implementation detail of the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface and all interactions with the Message Channel are via the Endpoint interfaces.</p> - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageChannelSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageChannelSolution.gif"></p> - -<p>For more details see</p> - -<ul><li><a shape="rect" href="message.html">Message</a></li><li><a shape="rect" href="message-endpoint.html">Message Endpoint</a></li></ul> - - -<h4 id="BookPatternAppendix-UsingThisPattern">Using This Pattern</h4> +<h3 id="BookPatternAppendix-MessageChannel">Message Channel</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/MessageChannel.html" rel="nofollow">Message Channel</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a>. The Message Channel is an internal implementation detail of the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface and all interactions with the Message Channel are via the Endpoint interfaces.</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageChannelSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageChannelSolution.gif"></p><p><strong style="font-size: 16.0px;line-height: 1.5625;"><br clear="none"></strong></p><p><strong style="font-size: 16.0px;lin e-height: 1.5625;">Example</strong></p><p>In JMS, Message Channels are represented by topics and queues such as the following</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: text; gutter: false" type="syntaxhighlighter"><![CDATA[jms:queue:foo]]></script> +</div></div><p> </p><p>This message channel can be then used within the <a shape="rect" href="jms.html">JMS</a> component</p><p><strong style="line-height: 1.4285715;">Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[to("jms:queue:foo")]]></script> +</div></div><p><strong><br clear="none"></strong></p><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<to uri="jms:queue:foo"/>]]></script> +</div></div><p> </p><p>For more details see</p><ul><li><a shape="rect" href="message.html">Message</a></li><li><a shape="rect" href="message-endpoint.html">Message Endpoint</a></li></ul><p></p><h4 id="BookPatternAppendix-UsingThisPattern">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-Message">Message</h3> @@ -383,34 +378,28 @@ from("activemq:My.Queue"). <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <ul class="alternate"><li><a shape="rect" href="content-enricher.html">Content Enricher</a></li><li><a shape="rect" href="using-getin-or-getout-methods-on-exchange.html">Using getIn or getOut methods on Exchange</a></li></ul> -<h3 id="BookPatternAppendix-MessageEndpoint">Message Endpoint</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/MessageEndpoint.html" rel="nofollow">Message Endpoint</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface. </p> - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageEndpointSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageEndpointSolution.gif"></p> - -<p>When using the <a shape="rect" href="dsl.html">DSL</a> to create <a shape="rect" href="routes.html">Routes</a> you typically refer to Message Endpoints by their <a shape="rect" href="uris.html">URIs</a> rather than directly using the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface. Its then a responsibility of the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContext.html">CamelContext</a> to create and activate the necessary Endpoint instances using the available <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Component.html">Component</a> implementations.</p> - -<p>For more details see</p> - -<ul><li><a shape="rect" href="message.html">Message</a></li></ul> - - -<h4 id="BookPatternAppendix-UsingThisPattern.5">Using This Pattern</h4> +<h3 id="BookPatternAppendix-MessageEndpoint">Message Endpoint</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/MessageEndpoint.html" rel="nofollow">Message Endpoint</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface.</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageEndpointSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageEndpointSolution.gif"></p><p>When using the <a shape="rect" href="dsl.html">DSL</a> to create <a shape="rect" href="routes.html">Routes</a> you typically refer to Message Endpoints by their <a shape="rect" href="uris.html">URIs</a> rather than directly using the <a shape="rect" c lass="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html">Endpoint</a> interface. Its then a responsibility of the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelContext.html">CamelContext</a> to create and activate the necessary Endpoint instances using the available <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Component.html">Component</a> implementations.</p><h4 id="BookPatternAppendix-Example">Example</h4><p>The following example route demonstrates the use of a <a shape="rect" href="https://cwiki.apache.org/confluence/display/SM/File">File</a> Consumer Endpoint and <a shape="rect" href="jms.html">JMS</a> Producer Endpoint</p><p><strong><br clear="none"></strong></p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class ="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("file://local/router/messages/foo") + .to("jms:queue:foo");]]></script> +</div></div><p> </p><p><strong><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<route> + <from uri="file://local/router/messages/foo"/> + <to uri="jms:queue:foo"/> +</route>]]></script> +</div></div><p> </p><p>For more details see</p><ul><li><a shape="rect" href="message.html">Message</a><br clear="none"><br clear="none"></li></ul><p></p><h4 id="BookPatternAppendix-UsingThisPattern.5">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h2 id="BookPatternAppendix-MessagingChannels">Messaging Channels</h2> -<h3 id="BookPatternAppendix-PointtoPointChannel">Point to Point Channel</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/PointToPointChannel.html" rel="nofollow">Point to Point Channel</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using the following components</p> - -<ul><li><a shape="rect" href="seda.html">Seda</a> for in-VM seda based messaging</li><li><a shape="rect" href="jms.html">JMS</a> for working with JMS Queues for high performance, clustering and load balancing</li><li><a shape="rect" href="jpa.html">JPA</a> for using a database as a simple message queue</li><li><a shape="rect" href="xmpp.html">XMPP</a> for point-to-point communication over XMPP (Jabber)</li><li>and others</li></ul> - - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/PointToPointSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/PointToPointSolution.gif"></p> - -<h4 id="BookPatternAppendix-UsingThisPattern.6">Using This Pattern</h4> +<h3 id="BookPatternAppendix-PointtoPointChannel">Point to Point Channel</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/PointToPointChannel.html" rel="nofollow">Point to Point Channel</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using the following components</p><ul><li><a shape="rect" href="seda.html">SEDA</a> for in-VM seda based messaging</li><li><a shape="rect" href="jms.html">JMS</a> for working with JMS Queues for high performance, clustering and load balancing</li><li><a shape="rect" href="jpa.html">JPA</a> for using a database as a simple message queue</li><li><a shape="rect" href="xmpp.html">XMPP</a> for point-to-point communication over XMPP (Jabber)</li><li>and others</li></ul><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/PointToPointSolution.gif" data-image-src="http://www.enterprise integrationpatterns.com/img/PointToPointSolution.gif"></p><p>The following example demonstrates point to point messaging using the <a shape="rect" href="jms.html">JMS</a> component </p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") + .to("jms:queue:foo");]]></script> +</div></div><p> </p><p><strong><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<route> + <from uri="direct:start"/> + <to uri="jms:queue:foo"/> +</route>]]></script> +</div></div><p> </p><p> </p><p></p><h4 id="BookPatternAppendix-UsingThisPattern.6">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-PublishSubscribeChannel">Publish Subscribe Channel</h3> @@ -804,31 +793,28 @@ public class MyRedeliverProcessor implem <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <ul class="alternate"><li><a shape="rect" href="error-handler.html">Error Handler</a></li><li><a shape="rect" href="exception-clause.html">Exception Clause</a></li></ul> -<h3 id="BookPatternAppendix-GuaranteedDelivery">Guaranteed Delivery</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html" rel="nofollow">Guaranteed Delivery</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using among others the following components:</p> - -<ul><li><a shape="rect" href="file2.html">File</a> for using file systems as a persistent store of messages</li><li><a shape="rect" href="jms.html">JMS</a> when using persistent delivery (the default) for working with JMS Queues and Topics for high performance, clustering and load balancing</li><li><a shape="rect" href="jpa.html">JPA</a> for using a database as a persistence layer, or use any of the many other database component such as <a shape="rect" href="sql.html">SQL</a>, <a shape="rect" href="jdbc.html">JDBC</a>, <a shape="rect" href="ibatis.html">iBatis</a>/<a shape="rect" href="mybatis.html">MyBatis</a>, <a shape="rect" href="hibernate.html">Hibernate</a></li><li><a shape="rect" href="hawtdb.html">HawtDB</a> for a lightweight key-value persistent store</li></ul> - - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif"></p> - -<h4 id="BookPatternAppendix-UsingThisPattern.9">Using This Pattern</h4> +<h3 id="BookPatternAppendix-GuaranteedDelivery">Guaranteed Delivery</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html" rel="nofollow">Guaranteed Delivery</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using among others the following components:</p><ul><li><a shape="rect" href="file2.html">File</a> for using file systems as a persistent store of messages</li><li><a shape="rect" href="jms.html">JMS</a> when using persistent delivery (the default) for working with JMS Queues and Topics for high performance, clustering and load balancing</li><li><a shape="rect" href="jpa.html">JPA</a> for using a database as a persistence layer, or use any of the many other database component such as <a shape="rect" href="sql.html">SQL</a>, <a shape="rect" href="jdbc.html">JDBC</a>, <a shape="rect" href="ibatis.html">iBATIS</a>/<a shape="rect" href="mybatis.html">MyBatis< /a>, <a shape="rect" href="hibernate.html">Hibernate</a></li><li><a shape="rect" href="hawtdb.html">HawtDB</a> for a lightweight key-value persistent store</li></ul><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/GuaranteedMessagingSolution.gif"></p><h4 id="BookPatternAppendix-Example.1">Example</h4><p>The following example demonstrates illustrates the use of <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html" rel="nofollow">Guaranteed Delivery</a> within the <a shape="rect" href="jms.html">JMS</a> component. By default, a message is not considered successfully delivered until the recipient has persisted the message locally guaranteeing its receipt in the event the destination becomes unavailable.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") + .to("jms:queue:foo");]]></script> +</div></div><p> </p><p><strong><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<route> + <from uri="direct:start"/> + <to uri="jms:queue:foo"/> +</route>]]></script> +</div></div><p></p><h4 id="BookPatternAppendix-UsingThisPattern.9">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> -<h3 id="BookPatternAppendix-MessageBus">Message Bus</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/PointToPointChannel.html" rel="nofollow">Message Bus</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a>. You could view Camel as a Message Bus itself as it allows producers and consumers to be decoupled.</p> - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageBusSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageBusSolution.gif"></p> - -<p>Folks often assume that a Message Bus is a JMS though so you may wish to refer to the <a shape="rect" href="jms.html">JMS</a> component for traditional MOM support.<br clear="none"> -Also worthy of note is the <a shape="rect" href="xmpp.html">XMPP</a> component for supporting messaging over XMPP (Jabber)</p> - -<p>Of course there are also ESB products such as <a shape="rect" class="external-link" href="http://servicemix.apache.org/home.html">Apache ServiceMix</a> which serve as full fledged message busses.<br clear="none"> -You can interact with <a shape="rect" class="external-link" href="http://servicemix.apache.org/home.html">Apache ServiceMix</a> from Camel in many ways, but in particular you can use the <a shape="rect" href="nmr.html">NMR</a> or <a shape="rect" href="jbi.html">JBI</a> component to access the ServiceMix message bus directly.</p> - -<h4 id="BookPatternAppendix-UsingThisPattern.10">Using This Pattern</h4> +<h3 id="BookPatternAppendix-MessageBus">Message Bus</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/PointToPointChannel.html" rel="nofollow">Message Bus</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a>. You could view Camel as a Message Bus itself as it allows producers and consumers to be decoupled.</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/MessageBusSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/MessageBusSolution.gif"></p><p>Folks often assume that a Message Bus is a JMS though so you may wish to refer to the <a shape="rect" href="jms.html">JMS</a> component for traditional MOM support.<br clear="none"> Also worthy of note is the <a shape="rect" href="xmpp.html">XMPP</a> component for supporting messaging over XMPP (Jabber)</p><p>Of course there are also ESB products such as <a shape="rect" class="external-link" href="http://servicemix.apache.org/home.html">Apache ServiceMix</a> which serve as full fledged message busses.<br clear="none"> You can interact with <a shape="rect" class="external-link" href="http://servicemix.apache.org/home.html">Apache ServiceMix</a> from Camel in many ways, but in particular you can use the <a shape="rect" href="nmr.html">NMR</a> or <a shape="rect" href="jbi.html">JBI</a> component to access the ServiceMix message bus directly.</p><p> </p><h4 id="BookPatternAppendix-Example.2">Example</h4><p>The following demonstrates how the Camel message bus can be used to communicate with consumers and producers</p><p><strong><br clear="none"></strong></p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") + .pollEnrich("file:inbox?fileName=data.txt") + .to("jms:queue:foo");]]></script> +</div></div><p> </p><p><strong><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<route> + <from uri="direct:start"/> + <pollEnrich uri="file:inbox?fileName=data.txt"/> + <to uri="jms:queue:foo"/> +</route>]]></script> +</div></div><p></p><h4 id="BookPatternAppendix-UsingThisPattern.10">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> @@ -983,21 +969,17 @@ from("direct:testSetExchangePattern <h4 id="BookPatternAppendix-UsingThisPattern.12">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> -<h3 id="BookPatternAppendix-CorrelationIdentifier">Correlation Identifier</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html" rel="nofollow">Correlation Identifier</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> by getting or setting a header on a <a shape="rect" href="message.html">Message</a>. </p> - -<p>When working with the <a shape="rect" href="activemq.html">ActiveMQ</a> or <a shape="rect" href="jms.html">JMS</a> components the correlation identifier header is called <strong>JMSCorrelationID</strong>. You can add your own correlation identifier to any message exchange to help correlate messages together to a single conversation (or business process).</p> - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/CorrelationIdentifierSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/CorrelationIdentifierSolution.gif"></p> - -<p>The use of a Correlation Identifier is key to working with the <a shape="rect" href="bam.html">Camel Business Activity Monitoring Framework</a> and can also be highly useful when testing with simulation or canned data such as with the <a shape="rect" href="mock.html">Mock testing framework</a></p> - -<p>Some <a shape="rect" href="eip.html">EIP</a> patterns will spin off a sub message, and in those cases, Camel will add a correlation id on the <a shape="rect" href="exchange.html">Exchange</a> as a property with they key <code>Exchange.CORRELATION_ID</code>, which links back to the source <a shape="rect" href="exchange.html">Exchange</a>. For example the <a shape="rect" href="splitter.html">Splitter</a>, <a shape="rect" href="multicast.html">Multicast</a>, <a shape="rect" href="recipient-list.html">Recipient List</a>, and <a shape="rect" href="wire-tap.html">Wire Tap</a> EIP does this.</p> - -<h4 id="BookPatternAppendix-SeeAlso">See Also</h4> - -<ul><li><a shape="rect" href="bam.html">BAM</a></li></ul> +<h3 id="BookPatternAppendix-CorrelationIdentifier">Correlation Identifier</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/CorrelationIdentifier.html" rel="nofollow">Correlation Identifier</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> by getting or setting a header on a <a shape="rect" href="message.html">Message</a>.</p><p>When working with the <a shape="rect" href="activemq.html">ActiveMQ</a> or <a shape="rect" href="jms.html">JMS</a> components the correlation identifier header is called <strong>JMSCorrelationID</strong>. You can add your own correlation identifier to any message exchange to help correlate messages together to a single conversation (or business process).</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/CorrelationIdentifierSolution.gif" data-image-src="http://www.enterpriseinte grationpatterns.com/img/CorrelationIdentifierSolution.gif"></p><p>The use of a Correlation Identifier is key to working with the <a shape="rect" href="bam.html">Camel Business Activity Monitoring Framework</a> and can also be highly useful when testing with simulation or canned data such as with the <a shape="rect" href="mock.html">Mock testing framework</a></p><p>Some <a shape="rect" href="eip.html">EIP</a> patterns will spin off a sub message, and in those cases, Camel will add a correlation id on the <a shape="rect" href="exchange.html">Exchange</a> as a property with they key <code>Exchange.CORRELATION_ID</code>, which links back to the source <a shape="rect" href="exchange.html">Exchange</a>. For example the <a shape="rect" href="splitter.html">Splitter</a>, <a shape="rect" href="multicast.html">Multicast</a>, <a shape="rect" href="recipient-list.html">Recipient List</a>, and <a shape="rect" href="wire-tap.html">Wire Tap</a> EIP does this.</p><p>The following example demonstrat es using the Camel JMSMessageID as the Correlation Identifier within a request/reply pattern in the <a shape="rect" href="jms.html">JMS</a> component</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") + .to(ExchangePattern.InOut,"jms:queue:foo?useMessageIDAsCorrelationID=true") + .to("mock:result");]]></script> +</div></div><p> </p><p><strong><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<route> + <from uri="direct:start"/> + <to uri="jms:queue:foo?useMessageIDAsCorrelationID=true" pattern="InOut"/> + <to uri="mock:result"/> +</route>]]></script> +</div></div><h4 id="BookPatternAppendix-SeeAlso">See Also</h4><ul><li><a shape="rect" href="bam.html">BAM</a></li></ul> <h2 id="BookPatternAppendix-ReturnAddress">Return Address</h2> <p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/ReturnAddress.html" rel="nofollow">Return Address</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> by using the <code>JMSReplyTo</code> header.</p> @@ -2945,7 +2927,7 @@ from("seda:quoteAggregator") <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-RoutingSlip">Routing Slip</h3><p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/RoutingTable.html" rel="nofollow">Routing Slip</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to route a message consecutively through a series of processing steps where the sequence of steps is not known at design time and can vary for each message.</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/RoutingTableSimple.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/RoutingTableSimple.gif"></p><h3 id="BookPatternAppendix-Options.3">Options</h3><div class="confluenceTableSmall"> <div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>uriDelimiter</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>,</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Delimiter used if the <a shape="rect" href="expression.html">Expression</a> returned multiple endpoints. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>ignoreInvalidEndpoints</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> If an endpoint uri could not be resolved, should it be ignored. Otherwise Camel will throw an exception stating the endpoint uri is not valid. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>cacheSize</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>1000</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.13.1/2.12.4:</strong> Allows to configure the cache size for the <code>ProducerCache</code> which caches producers for reuse in the routing slip. Will by default use the default cache size which is 1000. Setting the value to -1 allows to turn off the cache all together. </p></td></tr></tbody></table></div> -</div><h4 id="BookPatternAppendix-Example">Example</h4><p>The following route will take any messages sent to the <a shape="rect" class="external-link" href="http://activemq.apache.org">Apache ActiveMQ</a> queue <strong>SomeQueue</strong> and pass them into the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/RoutingTable.html" rel="nofollow">Routing Slip</a> pattern.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div><h4 id="BookPatternAppendix-Example.3">Example</h4><p>The following route will take any messages sent to the <a shape="rect" class="external-link" href="http://activemq.apache.org">Apache ActiveMQ</a> queue <strong>SomeQueue</strong> and pass them into the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/RoutingTable.html" rel="nofollow">Routing Slip</a> pattern.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("activemq:SomeQueue").routingSlip("aRoutingSlipHeader"); ]]></script> </div></div><p>Messages will be checked for the existance of the "aRoutingSlipHeader" header. The value of this header should be a comma-delimited list of endpoint <a shape="rect" href="uris.html">URIs</a> you wish the message to be routed to. The <a shape="rect" href="message.html">Message</a> will be routed in a <a shape="rect" href="pipes-and-filters.html">pipeline</a> fashion (i.e. one after the other).</p><p>From Camel 2.5 the <a shape="rect" href="routing-slip.html">Routing Slip</a> will set a property (<code>Exchange.SLIP_ENDPOINT</code>) on the <a shape="rect" href="exchange.html">Exchange</a> which contains the current endpoint as it advanced though the slip. This allows you to <em>know</em> how far we have processed in the slip.</p><p>The <a shape="rect" href="routing-slip.html">Routing Slip</a> will compute the slip <strong>beforehand</strong> which means, the slip is only computed once. If you need to compute the slip <em>on-the-fly</em> then use the <a shape="rect" href ="dynamic-router.html">Dynamic Router</a> pattern instead.</p><h4 id="BookPatternAppendix-Configurationoptions">Configuration options</h4><p>Here we set the header name and the URI delimiter to something different.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -3450,7 +3432,7 @@ public static class MyLoadBalancer exten <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-Multicast">Multicast</h3><p>The Multicast allows to route the same message to a number of endpoints and process them in a different way. The main difference between the Multicast and Splitter is that Splitter will split the message into several pieces but the Multicast will not modify the request message.</p><h3 id="BookPatternAppendix-Options.7">Options</h3><div class="confluenceTableSmall"> <div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>strategyRef</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to an <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> to be used to assemble the replies from the multicasts, into a single outgoing message from the <a shape="rect" href="multicast.html">Multicast</a>. By default Camel will use the last reply as the outgoing message. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>Agg regationStrategy</code>, see the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>strategyMethodName</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong> This option can be used to explicit declare the method name to use, when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>strategyMethodAllowNull</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong> If this option is <code>false</code> then the aggregate method is not used if there was no data to enrich. If this option is <code>true </code> then <code>null</code> values is used as the <code>oldExchange</code> (when no data to enrich), when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>parallelProcessing</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> If enabled then sending messages to the multicasts occurs concurrently. Note the caller thread will still wait until all messages has been fully processed, before it continues. Its only the sending and processing the replies from the multicasts which happens concurrently. </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>parallelAggregate</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.14:</strong> If enabled then the <code>aggregate</code> method on <code>AggregationStrategy</code> can be called concurrently. Notice that this would require the implementation of <code>AggregationStrategy</code> to be implemented as thread-safe. By default this is <code>false</code> meaning that Camel synchronizes the call to the <code>aggregate</code> method. Though in some use-cases this can be used to archive higher performance when the <code>AggregationStrategy</code> is implemented as thread-safe. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>executorServiceRef</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to a custom <a shape="rect" href="threading-model.html">Thread Pool</a> to be used for parallel processing. Notice if you set this option, then parallel processing is automatic implied, and you do not have to enable that option as well. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>stopOnException</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.2:</strong> Whether or not to stop continue processing immediately when an exception occurred. If disable, then Camel will send the message to all multicasts regardless if one of them failed. You can deal with exceptions in the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> class where you have full control how to handle that. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>streaming</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td ><td colspan="1" rowspan="1" class="confluenceTd"><p> If enabled then Camel >will process replies out-of-order, eg in the order they come back. If >disabled, Camel will process replies in the same order as multicasted. ></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> ><code>timeout</code> </p></td><td colspan="1" rowspan="1" >class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" >class="confluenceTd"><p> <strong>Camel 2.5:</strong> Sets a total timeout >specified in millis. If the <a shape="rect" >href="multicast.html">Multicast</a> hasn't been able to send and process all >replies within the given timeframe, then the timeout triggers and the <a >shape="rect" href="multicast.html">Multicast</a> breaks out and continues. >Notice if you provide a <a shape="rect" class="external-link" >href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/TimeoutAwareAggregationStrategy.html">TimeoutAwareAggregationStrategy</a> > then the <code>timeout</code> method is invoked before breaking out. If the timeout is reached with running tasks still remaining, certain tasks for which it is difficult for Camel to shut down in a graceful manner may continue to run. So use this option with a bit of care. We may be able to improve this functionality in future Camel releases. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>onPrepareRef</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.8:</strong> Refers to a custom <a shape="rect" href="processor.html">Processor</a> to prepare the copy of the <a shape="rect" href="exchange.html">Exchange</a> each multicast will receive. This allows you to do any custom logic, such as deep-cloning the message payload if that's needed etc. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>shareUnitOfWork</code> </p></td><td colspan ="1" rowspan="1" class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.8:</strong> Whether the unit of work should be shared. See the same option on <a shape="rect" href="splitter.html">Splitter</a> for more details. </p></td></tr></tbody></table></div> -</div><h4 id="BookPatternAppendix-Example.1">Example</h4><p>The following example shows how to take a request from the <strong>direct:a</strong> endpoint , then multicast these request to <strong>direct:x</strong>, <strong>direct:y</strong>, <strong>direct:z</strong>.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div><h4 id="BookPatternAppendix-Example.4">Example</h4><p>The following example shows how to take a request from the <strong>direct:a</strong> endpoint , then multicast these request to <strong>direct:x</strong>, <strong>direct:y</strong>, <strong>direct:z</strong>.</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ from("direct:a").multicast().to("direct:x", "direct:y", "direct:z"); ]]></script> @@ -3743,39 +3725,20 @@ from("direct:start") <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h2 id="BookPatternAppendix-MessageTransformation">Message Transformation</h2> -<h3 id="BookPatternAppendix-ContentEnricher">Content Enricher</h3> - -<p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/DataEnricher.html" rel="nofollow">Content Enricher</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using a <a shape="rect" href="message-translator.html">Message Translator</a>, an arbitrary <a shape="rect" href="processor.html">Processor</a> in the routing logic, or using the <a shape="rect" href="#BookPatternAppendix-enrich-dsl">enrich</a> DSL element to enrich the message.</p> - -<p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/DataEnricher.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/DataEnricher.gif"></p> - -<h4 id="BookPatternAppendix-ContentenrichmentusingaMessageTranslatororaProcessor">Content enrichment using a Message Translator or a Processor</h4> - -<p><strong>Using the</strong> <strong><a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<p>You can use <a shape="rect" href="templating.html">Templating</a> to consume a message from one destination, transform it with something like <a shape="rect" href="velocity.html">Velocity</a> or <a shape="rect" href="xquery.html">XQuery</a>, and then send it on to another destination. For example using InOnly (one way messaging)</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("activemq:My.Queue"). +<h3 id="BookPatternAppendix-ContentEnricher">Content Enricher</h3><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/DataEnricher.html" rel="nofollow">Content Enricher</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> using a <a shape="rect" href="message-translator.html">Message Translator</a>, an arbitrary <a shape="rect" href="processor.html">Processor</a> in the routing logic, or using the <a shape="rect" href="#BookPatternAppendix-enrich-dsl">enrich</a> DSL element to enrich the message.</p><p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/DataEnricher.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/DataEnricher.gif"></p><h4 id="BookPatternAppendix-ContentenrichmentusingaMessageTranslatororaProcessor">Content enrichment using a Message Translator or a Processor</h4><p><strong>Using th e</strong> <strong><a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><p>You can use <a shape="rect" href="templating.html">Templating</a> to consume a message from one destination, transform it with something like <a shape="rect" href="velocity.html">Velocity</a> or <a shape="rect" href="xquery.html">XQuery</a>, and then send it on to another destination. For example using InOnly (one way messaging)</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("activemq:My.Queue"). to("velocity:com/acme/MyResponse.vm"). to("activemq:Another.Queue"); ]]></script> -</div></div> -<p>If you want to use InOut (request-reply) semantics to process requests on the <strong>My.Queue</strong> queue on <a shape="rect" href="activemq.html">ActiveMQ</a> with a template generated response, then sending responses back to the JMSReplyTo Destination you could use this:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("activemq:My.Queue"). +</div></div><p>If you want to use InOut (request-reply) semantics to process requests on the <strong>My.Queue</strong> queue on <a shape="rect" href="activemq.html">ActiveMQ</a> with a template generated response, then sending responses back to the JMSReplyTo Destination you could use this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("activemq:My.Queue"). to("velocity:com/acme/MyResponse.vm"); ]]></script> -</div></div> -<p>Here is a simple example using the <a shape="rect" href="dsl.html">DSL</a> directly to transform the message body</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>Here is a simple example using the <a shape="rect" href="dsl.html">DSL</a> directly to transform the message body</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ from("direct:start").setBody(body().append(" World!")).to("mock:result"); ]]></script> -</div></div> -<p>In this example we add our own <a shape="rect" href="processor.html">Processor</a> using explicit Java code</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>In this example we add our own <a shape="rect" href="processor.html">Processor</a> using explicit Java code</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ from("direct:start").process(new Processor() { public void process(Exchange exchange) { @@ -3784,64 +3747,27 @@ from("direct:start").process(n } }).to("mock:result"); ]]></script> -</div></div> -<p>Finally we can use <a shape="rect" href="bean-integration.html">Bean Integration</a> to use any Java method on any bean to act as the transformer</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("activemq:My.Queue"). +</div></div><p>Finally we can use <a shape="rect" href="bean-integration.html">Bean Integration</a> to use any Java method on any bean to act as the transformer</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("activemq:My.Queue"). beanRef("myBeanName", "myMethodName"). to("activemq:Another.Queue"); ]]></script> -</div></div> -<p>For further examples of this pattern in use you could look at one of the JUnit tests</p> -<ul><li><a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java?view=markup">TransformTest</a></li><li><a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformViaDSLTest.java?view=markup">TransformViaDSLTest</a></li></ul> - - -<p><strong>Using Spring XML</strong></p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -<route> +</div></div><p>For further examples of this pattern in use you could look at one of the JUnit tests</p><ul><li><a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformTest.java?view=markup">TransformTest</a></li><li><a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TransformViaDSLTest.java?view=markup">TransformViaDSLTest</a></li></ul><p><strong>Using Spring XML</strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[<route> <from uri="activemq:Input"/> <bean ref="myBeanName" method="doTransform"/> <to uri="activemq:Output"/> </route> ]]></script> -</div></div> - -<p><span class="confluence-anchor-link" id="BookPatternAppendix-enrich-dsl"></span></p> -<h3 id="BookPatternAppendix-ContentenrichmentusingtheenrichDSLelement">Content enrichment using the <code>enrich</code> DSL element</h3> - -<p>Camel comes with two flavors of content enricher in the DSL</p> -<ul class="alternate"><li><code>enrich</code></li><li><code>pollEnrich</code></li></ul> - - -<p><code>enrich</code> uses a <code>Producer</code> to obtain the additional data. It is usually used for <a shape="rect" href="request-reply.html">Request Reply</a> messaging, for instance to invoke an external web service.<br clear="none"> -<code>pollEnrich</code> on the other hand uses a <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to obtain the additional data. It is usually used for <a shape="rect" href="event-message.html">Event Message</a> messaging, for instance to read a file or download a <a shape="rect" href="ftp2.html">FTP</a> file.</p> - - <div class="aui-message problem shadowed information-macro"> +</div></div><p><span class="confluence-anchor-link" id="BookPatternAppendix-enrich-dsl"></span></p><h3 id="BookPatternAppendix-ContentenrichmentusingtheenrichDSLelement">Content enrichment using the <code>enrich</code> DSL element</h3><p>Camel comes with two flavors of content enricher in the DSL</p><ul class="alternate"><li><code>enrich</code></li><li><code>pollEnrich</code></li></ul><p><code>enrich</code> uses a <code>Producer</code> to obtain the additional data. It is usually used for <a shape="rect" href="request-reply.html">Request Reply</a> messaging, for instance to invoke an external web service.<br clear="none"> <code>pollEnrich</code> on the other hand uses a <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to obtain the additional data. It is usually used for <a shape="rect" href="event-message.html">Event Message</a> messaging, for instance to read a file or download a <a shape="rect" href="ftp2.html">FTP</a> file.</p> <div class="aui-message problem shadowed information-macro"> <p class="title">Data from current Exchange not used</p> <span class="aui-icon icon-problem">Icon</span> <div class="message-content"> - -<p><code>pollEnrich</code> or <code>enrich</code> does <strong>not</strong> access any data from the current <a shape="rect" href="exchange.html">Exchange</a> which means when polling it cannot use any of the existing headers you may have set on the <a shape="rect" href="exchange.html">Exchange</a>. For example you cannot set a filename in the <code>Exchange.FILE_NAME</code> header and use <code>pollEnrich</code> to consume only that file. For that you <strong>must</strong> set the filename in the endpoint URI.</p> - -<p>Instead of using <code>enrich</code> you can use <a shape="rect" href="recipient-list.html">Recipient List</a> and have dynamic endpoints and define an <code>AggregationStrategy</code> on the <a shape="rect" href="recipient-list.html">Recipient List</a> which then would work as a <code>enrich</code> would do.</p> + <p><code>pollEnrich</code> or <code>enrich</code> does <strong>not</strong> access any data from the current <a shape="rect" href="exchange.html">Exchange</a> which means when polling it cannot use any of the existing headers you may have set on the <a shape="rect" href="exchange.html">Exchange</a>. For example you cannot set a filename in the <code>Exchange.FILE_NAME</code> header and use <code>pollEnrich</code> to consume only that file. For that you <strong>must</strong> set the filename in the endpoint URI.</p><p>Instead of using <code>enrich</code> you can use <a shape="rect" href="recipient-list.html">Recipient List</a> and have dynamic endpoints and define an <code>AggregationStrategy</code> on the <a shape="rect" href="recipient-list.html">Recipient List</a> which then would work as a <code>enrich</code> would do.</p> </div> </div> - - -<h3 id="BookPatternAppendix-EnrichOptions">Enrich Options</h3> - -<div class="confluenceTableSmall"> -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>uri</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The endpoint uri for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>ref</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to the endpoint for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>. </p></td></tr><tr><td colspan="1" rowspan="1" class ="confluenceTd"><p> <code>strategyRef</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to an <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>AggregationStrategy</code>, see the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>strategyMethodName</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong > This option can be used to explicit declare the method name to use, when > using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" > href="aggregator2.html">Aggregate</a> page for more details. > </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> > <code>strategyMethodAllowNull</code> </p></td><td colspan="1" rowspan="1" > class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" > rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong> If this > option is <code>false</code> then the aggregate method is not used if there > was no data to enrich. If this option is <code>true</code> then > <code>null</code> values is used as the <code>oldExchange</code> (when no > data to enrich), when using POJOs as the <code>AggregationStrategy</code>. > See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more > details. </p></td></tr></tbody></table></div> -</div> - - -<p><strong>Using the</strong> <strong><a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -AggregationStrategy aggregationStrategy = ... +<h3 id="BookPatternAppendix-EnrichOptions">Enrich Options</h3><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>uri</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The endpoint uri for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ref</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to the endpoint for the external service to enrich from. You must use either <code> uri</code> or <code>ref</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyRef</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to an <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>AggregationStrategy</code>, see the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyMethodName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> This option can be used to explicit declare the method name to use, when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyMethodAllowNull</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> If this option is <code>false</code> then the aggregate method is not used if there was no data to enrich. If this option is <code>true</code> then <code>null</code> values is used as the <code>oldExchange</code> (when no data to enrich), when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="c onfluenceTd"><code>aggregateOnException</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong> If this option is <code>false</code> then the aggregate method is <strong>not</strong> used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to <code>true</code> allows end users to control what to do if there was an exception in the <code>aggregate</code> method. For example to suppress the exception or set a custom message body etc.</td></tr></tbody></table></div></div><p><strong>Using the</strong> <strong><a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[AggregationStrategy aggregationStrategy = ... from("direct:start") .enrich("direct:resource", aggregationStrategy) @@ -3850,13 +3776,8 @@ from("direct:start") from("direct:resource") ... ]]></script> -</div></div> - -<p>The content enricher (<code>enrich</code>) retrieves additional data from a <em>resource endpoint</em> in order to enrich an incoming message (contained in the <em>original exchange</em>). An aggregation strategy is used to combine the original exchange and the <em>resource exchange</em>. The first parameter of the <code>AggregationStrategy.aggregate(Exchange, Exchange)</code> method corresponds to the the original exchange, the second parameter the resource exchange. The results from the resource endpoint are stored in the resource exchange's out-message. Here's an example template for implementing an aggregation strategy:</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -public class ExampleAggregationStrategy implements AggregationStrategy { +</div></div><p>The content enricher (<code>enrich</code>) retrieves additional data from a <em>resource endpoint</em> in order to enrich an incoming message (contained in the <em>original exchange</em>). An aggregation strategy is used to combine the original exchange and the <em>resource exchange</em>. The first parameter of the <code>AggregationStrategy.aggregate(Exchange, Exchange)</code> method corresponds to the the original exchange, the second parameter the resource exchange. The results from the resource endpoint are stored in the resource exchange's out-message. Here's an example template for implementing an aggregation strategy:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[public class ExampleAggregationStrategy implements AggregationStrategy { public Exchange aggregate(Exchange original, Exchange resource) { Object originalBody = original.getIn().getBody(); @@ -3872,17 +3793,8 @@ public class ExampleAggregationStrategy } ]]></script> -</div></div> - -<p>Using this template the original exchange can be of any pattern. The resource exchange created by the enricher is always an in-out exchange.</p> - -<p><strong>Using Spring XML</strong></p> - -<p>The same example in the Spring DSL</p> - -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> +</div></div><p>Using this template the original exchange can be of any pattern. The resource exchange created by the enricher is always an in-out exchange.</p><p><strong>Using Spring XML</strong></p><p>The same example in the Spring DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start"/> <enrich uri="direct:resource" strategyRef="aggregationStrategy"/> @@ -3896,106 +3808,52 @@ public class ExampleAggregationStrategy <bean id="aggregationStrategy" class="..." /> ]]></script> -</div></div> - -<h4 id="BookPatternAppendix-Aggregationstrategyisoptional">Aggregation strategy is optional</h4> -<p>The aggregation strategy is optional. If you do not provide it Camel will by default just use the body obtained from the resource.</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +</div></div><h4 id="BookPatternAppendix-Aggregationstrategyisoptional">Aggregation strategy is optional</h4><p>The aggregation strategy is optional. If you do not provide it Camel will by default just use the body obtained from the resource.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") .enrich("direct:resource") .to("direct:result"); ]]></script> -</div></div> -<p>In the route above the message sent to the <code>direct:result</code> endpoint will contain the output from the <code>direct:resource</code> as we do not use any custom aggregation.</p> - -<p>And for Spring DSL just omit the <code>strategyRef</code> attribute:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ - <route> +</div></div><p>In the route above the message sent to the <code>direct:result</code> endpoint will contain the output from the <code>direct:resource</code> as we do not use any custom aggregation.</p><p>And for Spring DSL just omit the <code>strategyRef</code> attribute:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <route> <from uri="direct:start"/> <enrich uri="direct:resource"/> <to uri="direct:result"/> </route> ]]></script> -</div></div> - -<h3 id="BookPatternAppendix-ContentenrichmentusingpollEnrich">Content enrichment using <code>pollEnrich</code></h3> -<p>The <code>pollEnrich</code> works just as the <code>enrich</code> however as it uses a <a shape="rect" href="polling-consumer.html">Polling Consumer</a> we have 3 methods when polling</p> -<ul class="alternate"><li>receive</li><li>receiveNoWait</li><li>receive(timeout)</li></ul> - - -<h3 id="BookPatternAppendix-PollEnrichOptions">PollEnrich Options</h3> - -<div class="confluenceTableSmall"> -<div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default Value </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>uri</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The endpoint uri for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>ref</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to the endpoint for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>. </p></td></tr><tr><td colspan="1" rowspan="1" class ="confluenceTd"><p> <code>strategyRef</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Refers to an <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply from the external service as outgoing message. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>AggregationStrategy</code>, see the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details. </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> <code>strategyMethodName</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong > This option can be used to explicit declare the method name to use, when > using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" > href="aggregator2.html">Aggregate</a> page for more details. > </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> > <code>strategyMethodAllowNull</code> </p></td><td colspan="1" rowspan="1" > class="confluenceTd"><p> <code>false</code> </p></td><td colspan="1" > rowspan="1" class="confluenceTd"><p> <strong>Camel 2.12:</strong> If this > option is <code>false</code> then the aggregate method is not used if there > was no data to enrich. If this option is <code>true</code> then > <code>null</code> values is used as the <code>oldExchange</code> (when no > data to enrich), when using POJOs as the <code>AggregationStrategy</code>. > See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more > details. </p></td></tr><tr><td colspan="1" rowspan="1" > class="confluenceTd"><p> <code>timeout</code> </p></td><td colspan="1" rowsp an="1" class="confluenceTd"><p> <code>-1</code> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Timeout in millis when polling from the external service. See below for important details about the timeout. </p></td></tr></tbody></table></div> -</div> - - <div class="aui-message hint shadowed information-macro"> +</div></div><h3 id="BookPatternAppendix-ContentenrichmentusingpollEnrich">Content enrichment using <code>pollEnrich</code></h3><p>The <code>pollEnrich</code> works just as the <code>enrich</code> however as it uses a <a shape="rect" href="polling-consumer.html">Polling Consumer</a> we have 3 methods when polling</p><ul class="alternate"><li>receive</li><li>receiveNoWait</li><li>receive(timeout)</li></ul><h3 id="BookPatternAppendix-PollEnrichOptions">PollEnrich Options</h3><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>uri</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The endpoint uri for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ref</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to the endpoint for the external service to enrich from. You must use either <code>uri</code> or <code>ref</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyRef</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to an <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html">AggregationStrategy</a> to be used to merge the reply from the external service, into a single outgoing message. By default Camel will use the reply fro m the external service as outgoing message. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>AggregationStrategy</code>, see the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyMethodName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> This option can be used to explicit declare the method name to use, when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>strategyMethodAllowNull</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> If this option is <c ode>false</code> then the aggregate method is not used if there was no data to enrich. If this option is <code>true</code> then <code>null</code> values is used as the <code>oldExchange</code> (when no data to enrich), when using POJOs as the <code>AggregationStrategy</code>. See the <a shape="rect" href="aggregator2.html">Aggregate</a> page for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>timeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Timeout in millis when polling from the external service. See below for important details about the timeout.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>aggregateOnException</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.14:</strong> If this option is <code>false</code> then the aggregate method is <strong>not</strong> used if there was an exception thrown while trying to retrieve the data to enrich from the resource. Setting this option to <code>true</code> allows end users to control what to do if there was an exception in the <code>aggregate</code> method. For example to suppress the exception or set a custom message body etc.</td></tr></tbody></table></div></div> <div class="aui-message hint shadowed information-macro"> <p class="title">Good practice to use timeout value</p> <span class="aui-icon icon-hint">Icon</span> <div class="message-content"> - -<p>By default Camel will use the <code>receive</code>. Which may block until there is a message available. It is therefore recommended to always provide a timeout value, to make this clear that we may wait for a message, until the timeout is hit.</p> + <p>By default Camel will use the <code>receive</code>. Which may block until there is a message available. It is therefore recommended to always provide a timeout value, to make this clear that we may wait for a message, until the timeout is hit.</p> </div> </div> - - -<p>If there is no data then the <code>newExchange</code> in the aggregation strategy is <code>null</code>. </p> - -<p>You can pass in a timeout value that determines which method to use</p> -<ul class="alternate"><li>if timeout is -1 or other negative number then <code>receive</code> is selected (<strong>Important:</strong> the <code>receive</code> method may block if there is no message)</li><li>if timeout is 0 then <code>receiveNoWait</code> is selected</li><li>otherwise <code>receive(timeout)</code> is selected</li></ul> - - -<p>The timeout values is in millis.</p> - - <div class="aui-message problem shadowed information-macro"> +<p>If there is no data then the <code>newExchange</code> in the aggregation strategy is <code>null</code>.</p><p>You can pass in a timeout value that determines which method to use</p><ul class="alternate"><li>if timeout is -1 or other negative number then <code>receive</code> is selected (<strong>Important:</strong> the <code>receive</code> method may block if there is no message)</li><li>if timeout is 0 then <code>receiveNoWait</code> is selected</li><li>otherwise <code>receive(timeout)</code> is selected</li></ul><p>The timeout values is in millis.</p> <div class="aui-message problem shadowed information-macro"> <p class="title">Data from current Exchange not used</p> <span class="aui-icon icon-problem">Icon</span> <div class="message-content"> - -<p><code>pollEnrich</code> does <strong>not</strong> access any data from the current <a shape="rect" href="exchange.html">Exchange</a> which means when polling it cannot use any of the existing headers you may have set on the <a shape="rect" href="exchange.html">Exchange</a>. For example you cannot set a filename in the <code>Exchange.FILE_NAME</code> header and use <code>pollEnrich</code> to consume only that file. For that you <strong>must</strong> set the filename in the endpoint URI.</p> + <p><code>pollEnrich</code> does <strong>not</strong> access any data from the current <a shape="rect" href="exchange.html">Exchange</a> which means when polling it cannot use any of the existing headers you may have set on the <a shape="rect" href="exchange.html">Exchange</a>. For example you cannot set a filename in the <code>Exchange.FILE_NAME</code> header and use <code>pollEnrich</code> to consume only that file. For that you <strong>must</strong> set the filename in the endpoint URI.</p> </div> </div> - - -<h4 id="BookPatternAppendix-Example.2">Example</h4> - -<p>In this example we enrich the message by loading the content from the file named inbox/data.txt. </p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[ -from("direct:start") +<h4 id="BookPatternAppendix-Example.5">Example</h4><p>In this example we enrich the message by loading the content from the file named inbox/data.txt.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("direct:start") .pollEnrich("file:inbox?fileName=data.txt") .to("direct:result"); ]]></script> -</div></div> - -<p>And in XML DSL you do:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ - <route> +</div></div><p>And in XML DSL you do:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <route> <from uri="direct:start"/> <pollEnrich uri="file:inbox?fileName=data.txt"/> <to uri="direct:result"/> </route> ]]></script> -</div></div> - -<p>If there is no file then the message is empty. We can use a timeout to either wait (potentially forever) until a file exists, or use a timeout to wait a certain period.</p> - -<p>For example to wait up to 5 seconds you can do:</p> -<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ - <route> +</div></div><p>If there is no file then the message is empty. We can use a timeout to either wait (potentially forever) until a file exists, or use a timeout to wait a certain period.</p><p>For example to wait up to 5 seconds you can do:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[ <route> <from uri="direct:start"/> <pollEnrich uri="file:inbox?fileName=data.txt" timeout="5000"/> <to uri="direct:result"/> </route> ]]></script> -</div></div> - - -<h4 id="BookPatternAppendix-UsingThisPattern.30">Using This Pattern</h4> +</div></div><p></p><h4 id="BookPatternAppendix-UsingThisPattern.30">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p> <h3 id="BookPatternAppendix-ContentFilter">Content Filter</h3> @@ -4070,7 +3928,7 @@ from("direct:start").process(n <p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/StoreInLibrary.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/StoreInLibrary.gif"></p> -<h4 id="BookPatternAppendix-Example.3">Example</h4> +<h4 id="BookPatternAppendix-Example.6">Example</h4> <p>In this example we want to replace a message body with a claim check, and restore the body at a later step.</p> @@ -4157,7 +4015,7 @@ public static final class DataEnricherBe <p><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/NormalizerDetail.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/NormalizerDetail.gif"></p> -<h4 id="BookPatternAppendix-Example.4">Example</h4> +<h4 id="BookPatternAppendix-Example.7">Example</h4> <p>This example shows a Message Normalizer that converts two types of XML messages into a common format. Messages in this common format are then filtered.</p> @@ -4338,20 +4196,15 @@ from("file://inbox").sort(body <h4 id="BookPatternAppendix-UsingThisPattern.35">Using This Pattern</h4> <p>If you would like to use this EIP Pattern then please read the <a shape="rect" href="getting-started.html">Getting Started</a>, you may also find the <a shape="rect" href="architecture.html">Architecture</a> useful particularly the description of <a shape="rect" href="endpoint.html">Endpoint</a> and <a shape="rect" href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" href="examples.html">Examples</a> first before trying this pattern out.</p>
[... 92 lines stripped ...]