You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2017/08/31 23:20:56 UTC

svn commit: r1017534 [4/5] - in /websites/production/camel/content: aggregator.html aggregator2.html book-in-one-page.html book-pattern-appendix.html cache/main.pageCache

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 Aug 31 23:20:55 2017
@@ -93,11 +93,11 @@
 
 <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><span class="confluence-embedded-file-wrapper"><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"></span></p><p><strong style="font-size: 16.0px;line-height: 1.5625;"><br clear="none
 "></strong></p><p><strong style="font-size: 16.0px;line-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="brush: text; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[jms:queue:foo]]></script>
+<script class="brush: text; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[jms:queue:foo]]></script>
 </div></div><p>&#160;</p><p>This message channel can be then used within the <a shape="rect" href="jms.html">JMS</a>&#160;component</p><p><strong style="line-height: 1.4285715;">Using the&#160;<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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[to(&quot;jms:queue:foo&quot;)]]></script>
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[to(&quot;jms:queue:foo&quot;)]]></script>
 </div></div><p><strong><br clear="none"></strong></p><p><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;to uri=&quot;jms:queue:foo&quot;/&gt;]]></script>
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;to uri=&quot;jms:queue:foo&quot;/&gt;]]></script>
 </div></div><p>&#160;</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>
@@ -113,7 +113,7 @@
 
 <p><strong>Requestor Code</strong></p>
 <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 //InOnly
 getContext().createProducerTemplate().sendBody(&quot;direct:startInOnly&quot;, &quot;Hello World&quot;);
 
@@ -125,7 +125,7 @@ String result = (String) getContext().cr
 
 <p><strong>Route 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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:startInOnly&quot;).inOnly(&quot;bean:process&quot;);
 
 from(&quot;direct:startInOut&quot;).inOut(&quot;bean:process&quot;);
@@ -135,7 +135,7 @@ from(&quot;direct:startInOut&quot;).inOu
 <p><strong>Route 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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 &lt;route&gt;
   &lt;from uri=&quot;direct:startInOnly&quot;/&gt;
   &lt;inOnly uri=&quot;bean:process&quot;/&gt;
@@ -190,7 +190,7 @@ from(&quot;direct:startInOut&quot;).inOu
 
 <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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 RouteBuilder builder = new RouteBuilder() {
     public void configure() {
         errorHandler(deadLetterChannel(&quot;mock:error&quot;));
@@ -210,7 +210,7 @@ RouteBuilder builder = new RouteBuilder(
 
 <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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 &lt;camelContext errorHandlerRef=&quot;errorHandler&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
     &lt;route&gt;
         &lt;from uri=&quot;direct:a&quot;/&gt;
@@ -296,44 +296,44 @@ from("activemq:My.Queue").
 <parameter ac:name=""><a shape="rect" href="using-this-pattern.html">Using This Pattern</a></parameter>
 <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><span class="confluence-embedded-file-wrapper"><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"></span></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">URI
 s</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><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&#160;<a shape="rect" href="fluent-bui
 lders.html">Fluent Builders</a></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;file://local/router/messages/foo&quot;)
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;file://local/router/messages/foo&quot;)
 	.to(&quot;jms:queue:foo&quot;);]]></script>
 </div></div><p>&#160;</p><p><strong><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
 	&lt;from uri=&quot;file://local/router/messages/foo&quot;/&gt;
 	&lt;to uri=&quot;jms:queue:foo&quot;/&gt;
 &lt;/route&gt;]]></script>
 </div></div><p>&#160;</p><h3 id="BookPatternAppendix-DynamicTo">Dynamic To</h3><p><strong>Available as of Camel 2.16</strong></p><p>There is a new &lt;toD&gt; that allows to send a message to a dynamic computed&#160;<a shape="rect" href="endpoint.html">Endpoint</a> using one or more&#160;<a shape="rect" href="expression.html">Expression</a> that are concat together. By default the&#160;<a shape="rect" href="simple.html">Simple</a> language is used to compute the&#160;endpoint. For example to send a message to a endpoint defined by a header you can do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
   &lt;from uri=&quot;direct:start&quot;/&gt;
   &lt;toD uri=&quot;${header.foo}&quot;/&gt;
 &lt;/route&gt;]]></script>
 </div></div><p>And in Java DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
   .toD(&quot;${header.foo}&quot;);]]></script>
 </div></div><p>&#160;</p><p>You can also prefix the uri with a value because by default the uri is evaluated using the&#160;<a shape="rect" href="simple.html">Simple</a> language</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
   &lt;from uri=&quot;direct:start&quot;/&gt;
   &lt;toD uri=&quot;mock:${header.foo}&quot;/&gt;
 &lt;/route&gt;]]></script>
 </div></div><p>And in Java DSL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
   .toD(&quot;mock:${header.foo}&quot;);]]></script>
 </div></div><p>In the example above we compute an endpoint that has prefix "mock:" and then the header foo is appended. So for example if the header foo has value order, then the endpoint is computed as "mock:order".</p><p>You can also use other languages than <a shape="rect" href="simple.html">Simple</a>&#160;such as&#160;<a shape="rect" href="xpath.html">XPath</a>&#160;- this requires to prefix with language: as shown below (simple language is the default language). If you do not specify language: then the endpoint is a component name. And in some cases there is both a component and language with the same name such as xquery.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
   &lt;from uri=&quot;direct:start&quot;/&gt;
   &lt;toD uri=&quot;language:xpath:/order/@uri&quot;/&gt;
 &lt;/route&gt;]]></script>
 </div></div><p>This is done by specifying the name of the language followed by a colon.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
   .toD(&quot;language:xpath:/order/@uri&quot;);]]></script>
 </div></div><p>You can also concat multiple&#160;<a shape="rect" href="language.html">Language</a>(s) together using the plus sign&#160;<code>+</code> such as shown below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
   &lt;from uri=&quot;direct:start&quot;/&gt;
   &lt;toD uri=&quot;jms:${header.base}+language:xpath:/order/@id&quot;/&gt;
 &lt;/route&gt;]]></script>
 </div></div><p>In the example above the uri is a combination of&#160;<a shape="rect" href="simple.html">Simple</a>&#160;language and&#160;<a shape="rect" href="xpath.html">XPath</a>&#160;where the first part is simple (simple is default language). And then the plus sign separate to another language, where we specify the language name followed by a colon</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
   .toD(&quot;jms:${header.base}+language:xpath:/order/@id&quot;);]]></script>
 </div></div><p>You can concat as many languages as you want, just separate them with the plus sign</p><p>The Dynamic To has a few options you can configure</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Name</th><th colspan="1" rowspan="1" class="confluenceTh">Default Value</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">uri</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Mandatory:</strong> The uri to use. See above</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">pattern</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">To set a specific <a shape="rect" href="exchange-pattern.html">Exchange Pattern</a> to use when sending to the endpoint. The original MEP is restored afterwards.</td></tr
 ><tr><td colspan="1" rowspan="1" class="confluenceTd">cacheSize</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd"><span style="color: rgb(0,0,0);">Allows to configure the cache size for the&#160;</span><code>ProducerCache</code><span style="color: rgb(0,0,0);">&#160;which caches producers for reuse. Will by default use the default cache size which is 1000. Setting the value to -1 allows to turn off the cache all together.</span></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">ignoreInvalidEndpoint</td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><span style="color: rgb(0,0,0);">Whether to ignore an endpoint URI that could not be resolved. If disabled, Camel will throw an exception identifying the invalid endpoint URI.</span></td></tr></tbody></table></div><p>&#160;</p><p>For more details see</p><ul><li><a shape="rect" href="recipien
 t-list.html">Recipient List</a></li><li><a shape="rect" href="message.html">Message</a></li><li><a shape="rect" href="wire-tap.html">Wire Tap</a><br clear="none"><br clear="none"></li></ul><p></p><h4 id="BookPatternAppendix-UsingThisPattern.3">Using This Pattern</h4>
 
@@ -341,10 +341,10 @@ from("activemq:My.Queue").
 
 <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><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/PointToPointSolu
 tion.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/PointToPointSolution.gif"></span></p><p>The following example demonstrates point to point messaging using the&#160;<a shape="rect" href="jms.html">JMS</a>&#160;component&#160;</p><p><strong>Using the&#160;<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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
 	.to(&quot;jms:queue:foo&quot;);]]></script>
 </div></div><p>&#160;</p><p><strong><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
 	&lt;from uri=&quot;direct:start&quot;/&gt;
 	&lt;to uri=&quot;jms:queue:foo&quot;/&gt;
 &lt;/route&gt;]]></script>
@@ -366,7 +366,7 @@ from("activemq:My.Queue").
 
 <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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 RouteBuilder builder = new RouteBuilder() {
     public void configure() {
         errorHandler(deadLetterChannel(&quot;mock:error&quot;));
@@ -380,7 +380,7 @@ RouteBuilder builder = new RouteBuilder(
 
 <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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 &lt;camelContext errorHandlerRef=&quot;errorHandler&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
     &lt;route&gt;
         &lt;from uri=&quot;direct:a&quot;/&gt;
@@ -437,10 +437,10 @@ errorHandler(deadLetterChannel("jms:queu
 &lt;errorHandler id="dlc" type="DeadLetterChannel" deadLetterUri="jms:dead" onPrepareFailureRef="myPrepare"/&gt;</plain-text-body><p>&#160;</p><p>The&#160;<strong><code>onPrepare</code></strong> is also available using the default error handler.</p><h3 id="BookPatternAppendix-WhichRouteFailed">Which Route Failed</h3><p><strong>Available as of Camel 2.10.4/2.11</strong></p><p>When Camel error handler handles an error such as <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> or using <a shape="rect" href="exception-clause.html">Exception Clause</a> with <strong><code>handled=true</code></strong>, then Camel will decorate the <a shape="rect" href="exchange.html">Exchange</a> with the route id where the error occurred.</p><p>Example:</p><parameter ac:name="language">java</parameter><plain-text-body>String failedRouteId = exchange.getProperty(Exchange.FAILURE_ROUTE_ID, String.class);
 </plain-text-body><p>The <strong><code>Exchange.FAILURE_ROUTE_ID</code></strong> have the constant value <strong><code>CamelFailureRouteId</code></strong>. This allows for example you to fetch this information in your dead letter queue and use that for error reporting.</p><h3 id="BookPatternAppendix-ControlifRedeliveryisAllowedDuringStopping/Shutdown">Control if Redelivery is Allowed During Stopping/Shutdown</h3><p><strong>Available as of Camel 2.11</strong></p><p>Before <strong>Camel 2.10</strong>, Camel would perform redelivery while stopping a route, or shutting down Camel. This has improved a bit in <strong>Camel 2.10</strong>: Camel will no longer perform redelivery attempts when shutting down aggressively, e.g., during <a shape="rect" href="graceful-shutdown.html">Graceful Shutdown</a> and timeout hit.</p><p>From <strong>Camel 2.11</strong>: there is a new option <strong><code>allowRedeliveryWhileStopping</code></strong> which you can use to control if redelivery is allowed or
  not; notice that any in progress redelivery will still be executed. This option can only disallow any redelivery to be executed <em><strong>after</strong></em> the stopping of a route/shutdown of Camel has been triggered. If a redelivery is disallowed then a <strong><code>RejectedExcutionException</code></strong> is set on the <a shape="rect" href="exchange.html">Exchange</a> and the processing of the <a shape="rect" href="exchange.html">Exchange</a> stops. This means any consumer will see the <a shape="rect" href="exchange.html">Exchange</a> as failed due the <strong><code>RejectedExcutionException</code></strong>. The default value is <strong><code>true</code></strong> for backward compatibility.</p><p>For example, the following snippet shows how to do this with Java DSL and XML DSL:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RedeliveryErrorHandlerNoRedeliveryOnShutdownTest.java}</plain-text-body>And the sample sam
 ple with XML DSL<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRedeliveryErrorHandlerNoRedeliveryOnShutdownTest.xml}</plain-text-body></p><h3 id="BookPatternAppendix-Samples">Samples</h3><p>The following example shows how to configure the Dead Letter Channel configuration using the <a shape="rect" href="dsl.html">DSL</a><plain-text-body>{snippet:id=e3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java}</plain-text-body>You can also configure the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/RedeliveryPolicy.html">RedeliveryPolicy</a> as this example shows<plain-text-body>{snippet:id=e4|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ErrorHandlerTest.java}</plain-text-body></p><h3 id="BookPatternAppendix-HowCanIModifytheExchangeBeforeRede
 livery?">How Can I Modify the Exchange Before Redelivery?</h3><p>We support directly in <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> to set a <a shape="rect" href="processor.html">Processor</a> that is executed <strong>before</strong> each redelivery attempt. When <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> is doing redeliver its possible to configure a <a shape="rect" href="processor.html">Processor</a> that is executed just <strong>before</strong> every redelivery attempt. This can be used for the situations where you need to alter the message before its redelivered. Here we configure the <a shape="rect" href="dead-letter-channel.html">Dead Letter Channel</a> to use our processor <strong><code>MyRedeliveryProcessor</code></strong> to be executed before each redelivery.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelOnRedeliveryTest.java}</plain-text
 -body>And this is the processor <strong><code>MyRedeliveryProcessor</code></strong> where we alter the message.<plain-text-body>{snippet:id=e2|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelOnRedeliveryTest.java}</plain-text-body></p><h3 id="BookPatternAppendix-HowCanILogWhatCausedtheDeadLetterChanneltobeInvoked?">How Can I Log What Caused the Dead Letter Channel to be Invoked?</h3><p>You often need to know what went wrong that caused the Dead Letter Channel to be used and it does not offer logging for this purpose. So the Dead Letter Channel's endpoint can be set to a endpoint of our own (such as&#160;<strong><code>direct:deadLetterChannel</code></strong>). We write a route to accept this Exchange and log the Exception, then forward on to where we want the failed Exchange moved to (which might be a DLQ queue for instance). See also&#160;<a shape="rect" class="external-link" href="http://stackoverflow.com/questions/13711462/logging-cam
 el-exceptions-and-sending-to-the-dead-letter-channel" rel="nofollow">http://stackoverflow.com/questions/13711462/logging-camel-exceptions-and-sending-to-the-dead-letter-channel</a></p><p><parameter ac:name=""><a shape="rect" href="using-this-pattern.html">Using This Pattern</a></parameter></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><span class="confluence-embedded-file-wrapper"><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"></span></p><h4 id="BookPatternAppendix-Example.1">Example</h4><p>The following example demonstrates illustrates the use of&#160;<a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/GuaranteedMessaging.html" rel="nofollow">Guaranteed Delivery</a>&#160;within the&#160;<a shape="rect" href="jms.html">JMS</a>&#160;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&#160;<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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
 	.to(&quot;jms:queue:foo&quot;);]]></script>
 </div></div><p>&#160;</p><p><strong><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
 	&lt;from uri=&quot;direct:start&quot;/&gt;
 	&lt;to uri=&quot;jms:queue:foo&quot;/&gt;
 &lt;/route&gt;]]></script>
@@ -448,11 +448,11 @@ errorHandler(deadLetterChannel("jms:queu
 
 <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><span class="confluence-embedded-file-wrapper"><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"></span></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>&#160;</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&#160;<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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
 	.pollEnrich(&quot;file:inbox?fileName=data.txt&quot;)
 	.to(&quot;jms:queue:foo&quot;);]]></script>
 </div></div><p>&#160;</p><p><strong><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
 	&lt;from uri=&quot;direct:start&quot;/&gt;
 	&lt;pollEnrich uri=&quot;file:inbox?fileName=data.txt&quot;/&gt;
 	&lt;to uri=&quot;jms:queue:foo&quot;/&gt;
@@ -463,25 +463,25 @@ errorHandler(deadLetterChannel("jms:queu
 
 <h3 id="BookPatternAppendix-MessageConstruction">Message Construction</h3>
 <h2 id="BookPatternAppendix-EventMessage">Event Message</h2><p>Camel supports the <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/EventMessage.html" rel="nofollow">Event Message</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> by supporting the <a shape="rect" href="exchange-pattern.html">Exchange Pattern</a> on a <a shape="rect" href="message.html">Message</a> which can be set to <strong>InOnly</strong> to indicate a oneway event message. Camel <a shape="rect" href="components.html">Components</a> then implement this pattern using the underlying transport or protocols.</p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/EventMessageSolution.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/EventMessageSolution.gif"></span></p><p>The default behaviour of many <a
  shape="rect" href="components.html">Components</a> is InOnly such as for <a shape="rect" href="jms.html">JMS</a>, <a shape="rect" href="file2.html">File</a> or <a shape="rect" href="seda.html">SEDA</a></p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Related</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>See the related <a shape="rect" href="request-reply.html">Request Reply</a> message.</p></div></div><h3 id="BookPatternAppendix-ExplicitlyspecifyingInOnly">Explicitly specifying InOnly</h3><p>If you are using a component which defaults to InOut you can override the <a shape="rect" href="exchange-pattern.html">Exchange Pattern</a> for an endpoint using the pattern property.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[foo:bar?exchangePattern=InOnly
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[foo:bar?exchangePattern=InOnly
 ]]></script>
 </div></div><p>From 2.0 onwards on Camel you can specify the <a shape="rect" href="exchange-pattern.html">Exchange Pattern</a> using the DSL.</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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;mq:someQueue&quot;).
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;mq:someQueue&quot;).
   setExchangePattern(ExchangePattern.InOnly).
   bean(Foo.class);
 ]]></script>
 </div></div><p>or you can invoke an endpoint with an explicit pattern</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;mq:someQueue&quot;).
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;mq:someQueue&quot;).
   inOnly(&quot;mq:anotherQueue&quot;);
 ]]></script>
 </div></div><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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
     &lt;from uri=&quot;mq:someQueue&quot;/&gt;
     &lt;inOnly uri=&quot;bean:foo&quot;/&gt;
 &lt;/route&gt;
 ]]></script>
 </div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
     &lt;from uri=&quot;mq:someQueue&quot;/&gt;
     &lt;inOnly uri=&quot;mq:anotherQueue&quot;/&gt;
 &lt;/route&gt;
@@ -510,7 +510,7 @@ errorHandler(deadLetterChannel("jms:queu
 <p>You can explicitly force an endpoint to be in Request Reply mode by setting the exchange pattern on the URI. e.g.</p>
 
 <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 jms:MyQueue?exchangePattern=InOut
 ]]></script>
 </div></div>
@@ -518,7 +518,7 @@ jms:MyQueue?exchangePattern=InOut
 <p>You can specify the exchange pattern in DSL rule or Spring configuration.</p>
 
 <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 // Send to an endpoint using InOut
 from(&quot;direct:testInOut&quot;).inOut(&quot;mock:result&quot;);
 
@@ -545,7 +545,7 @@ from(&quot;direct:testSetExchangePattern
 </div></div>
 
 <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 &lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
   &lt;!-- Send the exchange as InOnly --&gt;
   &lt;route&gt;
@@ -599,11 +599,11 @@ from(&quot;direct:testSetExchangePattern
 
 <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><span class="confluence-embedded-file-wrapper"><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"></span></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 demonstrates using the Camel JMSMessageID as the Correlation Identifier within a request/reply pattern in the&#160;<a shape="rect" href="jms.html">JMS</a>&#160;component</p><p><strong>Using the&#160;<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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
 	.to(ExchangePattern.InOut,&quot;jms:queue:foo?useMessageIDAsCorrelationID=true&quot;)
 	.to(&quot;mock:result&quot;);]]></script>
 </div></div><p>&#160;</p><p><strong><strong>Using the&#160;<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="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
 	&lt;from uri=&quot;direct:start&quot;/&gt;
 	&lt;to uri=&quot;jms:queue:foo?useMessageIDAsCorrelationID=true&quot; pattern=&quot;InOut&quot;/&gt;
 	&lt;to uri=&quot;mock:result&quot;/&gt;
@@ -619,7 +619,7 @@ from(&quot;direct:testSetExchangePattern
 
 <p><strong>Requestor Code</strong></p>
 <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 getMockEndpoint(&quot;mock:bar&quot;).expectedBodiesReceived(&quot;Bye World&quot;);
 template.sendBodyAndHeader(&quot;direct:start&quot;, &quot;World&quot;, &quot;JMSReplyTo&quot;, &quot;queue:bar&quot;);
 ]]></script>
@@ -627,7 +627,7 @@ template.sendBodyAndHeader(&quot;direct:
 
 <p><strong>Route 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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;).to(&quot;activemq:queue:foo?preserveMessageQos=true&quot;);
 from(&quot;activemq:queue:foo&quot;).transform(body().prepend(&quot;Bye &quot;));
 from(&quot;activemq:queue:bar?disableReplyTo=true&quot;).to(&quot;mock:bar&quot;);
@@ -637,7 +637,7 @@ from(&quot;activemq:queue:bar?disableRep
 <p><strong>Route 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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<script class="brush: bash; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[
 &lt;route&gt;
   &lt;from uri=&quot;direct:start&quot;/&gt;
   &lt;to uri=&quot;activemq:queue:foo?preserveMessageQos=true&quot;/&gt;
@@ -665,7 +665,7 @@ from(&quot;activemq:queue:bar?disableRep
 
 <h2 id="BookPatternAppendix-MessageRouting">Message Routing</h2>
 <h3 id="BookPatternAppendix-ContentBasedRouter">Content Based Router</h3><p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html" rel="nofollow">Content Based Router</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to route messages to the correct destination based on the contents of the message exchanges.</p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/ContentBasedRouter.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/ContentBasedRouter.gif"></span></p><p>The following example shows how to route a request from an input <strong>seda:a</strong> endpoint to either <strong>seda:b</strong>, <strong>seda:c</strong> or <strong>seda:d</strong> depending on the evaluation of various <a shape="rect" href="predicate.html">Predicate<
 /a> expressions</p><p><strong>Using the <a shape="rect" href="fluent-builders.html">Fluent Builders</a></strong></p><p>&#160;</p><p><strong><br clear="none"></strong></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
     public void configure() {
         errorHandler(deadLetterChannel(&quot;mock:error&quot;));
  
@@ -680,7 +680,7 @@ from(&quot;activemq:queue:bar?disableRep
     }
 };]]></script>
 </div></div><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>See <a shape="rect" href="why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html">Why can I not use when or otherwise in a Java Camel route</a> if you have problems with the Java DSL, accepting using <code>when</code> or <code>otherwise</code>.</p></div></div><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><div class="line number1 index0 alt2"><p>&#160;</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;camelContext errorHandlerRef=&quot;errorHandler&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
+<script class="brush: xml; gutter: false; theme: Confluence" type="syntaxhighlighter"><![CDATA[&lt;camelContext errorHandlerRef=&quot;errorHandler&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
     &lt;route&gt;
         &lt;from uri=&quot;direct:a&quot;/&gt;
         &lt;choice&gt;
@@ -925,190 +925,8 @@ Response to caller: Response[(id=1,item=
             &lt;/split&gt;
         &lt;/route&gt;
 </plain-text-body><h3 id="BookPatternAppendix-UsingonPreparetoexecutecustomlogicwhenpreparingmessages.1">Using onPrepare to execute custom logic when preparing messages</h3><p><strong>Available as of Camel 2.8</strong></p><p>See details at <a shape="rect" href="multicast.html">Multicast</a></p><h3 id="BookPatternAppendix-Sharingunitofwork">Sharing unit of work</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <a shape="rect" href="splitter.html">Splitter</a> will by default not share unit of work between the parent exchange and each splitted exchange. This means each sub exchange has its own individual unit of work.</p><p>For example you may have an use case, where you want to split a big message. And you want to regard that process as an atomic isolated operation that either is a success or failure. In case of a failure you want that big message to be moved into a <a shape="rect" href="dead-letter-channel.html">dead letter queue</a>. To support this use case, you would ha
 ve to share the unit of work on the <a shape="rect" href="splitter.html">Splitter</a>.</p><p>Here is an example in Java DSL<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitSubUnitOfWorkTest.java}</plain-text-body>Now in this example what would happen is that in case there is a problem processing each sub message, the error handler will kick in (yes error handling still applies for the sub messages). <strong>But</strong> what doesn't happen is that if a sub message fails all redelivery attempts (its exhausted), then its <strong>not</strong> moved into that dead letter queue. The reason is that we have shared the unit of work, so the sub message will report the error on the shared unit of work. When the <a shape="rect" href="splitter.html">Splitter</a> is done, it checks the state of the shared unit of work and checks if any errors occurred. And if an error occurred it will set the exception on the <a shape="rect" href=
 "exchange.html">Exchange</a> and mark it for rollback. The error handler will yet again kick in, as the <a shape="rect" href="exchange.html">Exchange</a> has been marked as rollback and it had an exception as well. No redelivery attempts is performed (as it was marked for rollback) and the <a shape="rect" href="exchange.html">Exchange</a> will be moved into the <a shape="rect" href="dead-letter-channel.html">dead letter queue</a>.</p><p>Using this from XML DSL is just as easy as you just have to set the shareUnitOfWork attribute to true:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringSplitSubUnitOfWorkTest.xml}</plain-text-body></p><parameter ac:name="title">Implementation of shared unit of work</parameter><rich-text-body><p>So in reality the unit of work is not shared as a single object instance. Instead <code>SubUnitOfWork</code> is attached to their parent, and issues callback to the paren
 t about their status (commit or rollback). This may be refactored in Camel 3.0 where larger API changes can be done.</p></rich-text-body><p><parameter ac:name=""><a shape="rect" href="using-this-pattern.html">Using This Pattern</a></parameter></p>
-<h3 id="BookPatternAppendix-Aggregator">Aggregator</h3><p><strong>This applies for Camel version 2.3 or newer. If you use an older version then use this <a shape="rect" href="aggregator.html">Aggregator</a> link instead.</strong></p><p>The <a shape="rect" class="external-link" href="http://www.enterpriseintegrationpatterns.com/Aggregator.html" rel="nofollow">Aggregator</a> from the <a shape="rect" href="enterprise-integration-patterns.html">EIP patterns</a> allows you to combine a number of messages together into a single message.</p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.enterpriseintegrationpatterns.com/img/Aggregator.gif" data-image-src="http://www.enterpriseintegrationpatterns.com/img/Aggregator.gif"></span></p><p>A correlation <a shape="rect" href="expression.html">Expression</a> is used to determine the messages which should be aggregated together. If you want to aggregate all messag
 es into a single message, just use a constant expression. An AggregationStrategy is used to combine all the message exchanges for a single correlation key into a single message exchange.</p><h3 id="BookPatternAppendix-Aggregatoroptions">Aggregator options</h3><p>The aggregator supports the following options:</p><parameter ac:name="class">confluenceTableSmall</parameter><rich-text-body><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>correlationExpression</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Mandatory <a shape="rect" href="expression.html">Expression</a> which evaluates the correlation key to use for aggregation. Th
 e <a shape="rect" href="exchange.html">Exchange</a> which has the same correlation key is aggregated together. If the correlation key could not be evaluated an Exception is thrown. You can disable this by using the <code>ignoreBadCorrelationKeys</code> option.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>aggregationStrategy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Mandatory <code>AggregationStrategy</code> which is used to <em>merge</em> the incoming <a shape="rect" href="exchange.html">Exchange</a> with the existing already merged exchanges. At first call the <code>oldExchange</code> parameter is <code>null</code>. On subsequent invocations the <code>oldExchange</code> contains the merged exchanges and <code>newExchange</code> is of course the new incoming Exchange. From <strong>Camel 2.9.2</strong> onwards the strategy can also be a <code>TimeoutAwareAggregationStrategy</c
 ode> implementation, supporting the timeout callback, see further below for more details. From <strong>Camel 2.16</strong> onwards the strategy can also be a <code>PreCompletionAwareAggregationStrategy</code> implementation which then runs the completion check in pre-completion mode. See further below for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>strategyRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A reference to lookup the <code>AggregationStrategy</code> in the <a shape="rect" href="registry.html">Registry</a>. From <strong>Camel 2.12</strong> onwards you can also use a POJO as the <code>AggregationStrategy</code>, see further below for details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>strategyMethodName</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</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 further below for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>strategyMethodAllowNull</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 for the very first aggregation. If this option is <code>true</code> then <code>null</code> values is used as the <code>oldExchange</code> (at the very first aggregation), when using POJOs as the <code>AggregationStrategy</code>. See further below for more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>completionSize</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluence
 Td"><p>Number of messages aggregated before the aggregation is complete. This option can be set as either a fixed value or using an <a shape="rect" href="expression.html">Expression</a> which allows you to evaluate a size dynamically - will use <code>Integer</code> as result. If both are set Camel will fallback to use the fixed value if the <a shape="rect" href="expression.html">Expression</a> result was <code>null</code> or <code>0</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>completionTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Time in millis that an aggregated exchange should be inactive before its complete. This option can be set as either a fixed value or using an <a shape="rect" href="expression.html">Expression</a> which allows you to evaluate a timeout dynamically - will use <code>Long</code> as result. If both are set Camel will fallback to use the fixe
 d value if the <a shape="rect" href="expression.html">Expression</a> result was <code>null</code> or <code>0</code>. You cannot use this option together with completionInterval, only one of the two can be used.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>completionInterval</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A repeating period in millis by which the aggregator will complete all current aggregated exchanges. Camel has a background task which is triggered every period. You cannot use this option together with completionTimeout, only one of them can be used.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>completionPredicate</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A <a shape="rect" href="predicate.html">Predicate</a> to indicate when an aggregated exchange is comple
 te. Starting in <strong>Camel 2.15</strong>, if this is not specified and the AggregationStrategy object implements Predicate, the aggregationStrategy object will be used as the completionPredicate.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>completionFromBatchConsumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This option is if the exchanges are coming from a <a shape="rect" href="batch-consumer.html">Batch Consumer</a>. Then when enabled the <a shape="rect" href="aggregator2.html">Aggregator2</a> will use the batch size determined by the <a shape="rect" href="batch-consumer.html">Batch Consumer</a> in the message header <code>CamelBatchSize</code>. See more details at <a shape="rect" href="batch-consumer.html">Batch Consumer</a>. This can be used to aggregate all files consumed from a <a shape="rect" href="file2.html">File</a> endpoint in that given poll.</p></
 td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>forceCompletionOnStop</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.9</strong> Indicates to complete all current aggregated exchanges when the context is stopped</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">completeAllOnStop</td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong>&#160;Indicates to wait to complete all current and partial (pending) aggregated exchanges when the context is stopped. This also means that we will wait for all pending exchanges which are stored in the&#160;aggregation repository&#160;to complete so the repository is empty before we can stop. &#160;You may want to enable this when using the memory based aggregation repository that is memory based only,&#160;and do not s
 tore data on disk. When this option is enabled, then the aggregator is waiting to complete&#160;all those exchanges before its stopped, when stopping CamelContext or the route using it.</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>eagerCheckCompletion</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not to eager check for completion when a new incoming <a shape="rect" href="exchange.html">Exchange</a> has been received. This option influences the behavior of the <code>completionPredicate</code> option as the <a shape="rect" href="exchange.html">Exchange</a> being passed in changes accordingly. When <code>false</code> the <a shape="rect" href="exchange.html">Exchange</a> passed in the <a shape="rect" href="predicate.html">Predicate</a> is the <em>aggregated</em> Exchange which means any information you may store on the aggregated Exchange from the <code>Aggregation
 Strategy</code> is available for the <a shape="rect" href="predicate.html">Predicate</a>. When <code>true</code> the <a shape="rect" href="exchange.html">Exchange</a> passed in the <a shape="rect" href="predicate.html">Predicate</a> is the <em>incoming</em> <a shape="rect" href="exchange.html">Exchange</a>, which means you can access data from the incoming Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>groupExchanges</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 group all aggregated Exchanges into a single combined <code>org.apache.camel.impl.GroupedExchange</code> holder class that holds all the aggregated Exchanges. And as a result only one Exchange is being sent out from the aggregator. Can be used to combine many incoming Exchanges into a single output Exchange without coding a custom <code>AggregationStrategy</code> yourself. <s
 trong>Important:</strong> This option does <strong>not</strong> support persistent repository with the aggregator. See further below for an example and more details.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>ignoreInvalidCorrelationKeys</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not to ignore correlation keys which could not be evaluated to a value. By default Camel will throw an Exception, but you can enable this option and ignore the situation instead.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>closeCorrelationKeyOnCompletion</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not too <em>late</em> Exchanges should be accepted or not. You can enable this to indicate that if a correlation key has already been completed, then any new exchang
 es with the same correlation key be denied. Camel will then throw a <code>closedCorrelationKeyException</code> exception. When using this option you pass in a <code>integer</code> which is a number for a LRUCache which keeps that last X number of closed correlation keys. You can pass in 0 or a negative value to indicate a unbounded cache. By passing in a number you are ensured that cache won't grow too big if you use a log of different correlation keys.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>discardOnCompletionTimeout</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.5:</strong> Whether or not exchanges which complete due to a timeout should be discarded. If enabled then when a timeout occurs the aggregated message will <strong>not</strong> be sent out but dropped (discarded).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>aggre
 gationRepository</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Allows you to plugin you own implementation of <code>org.apache.camel.spi.AggregationRepository</code> which keeps track of the current inflight aggregated exchanges. Camel uses by default a memory based implementation.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>aggregationRepositoryRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Reference to lookup a <code>aggregationRepository</code> in the <a shape="rect" href="registry.html">Registry</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>parallelProcessing</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When aggregated are completed they are being send out of the aggregato
 r. This option indicates whether or not Camel should use a thread pool with multiple threads for concurrency. If no custom thread pool has been specified then Camel creates a default pool with 10 concurrent threads.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>executorService</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If using <code>parallelProcessing</code> you can specify a custom thread pool to be used. In fact also if you are not using <code>parallelProcessing</code> this custom thread pool is used to send out aggregated exchanges as well.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>executorServiceRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Reference to lookup a <code>executorService</code> in the <a shape="rect" href="registry.html">Registry</a></p></td></tr><tr
 ><td colspan="1" rowspan="1" class="confluenceTd"><p>timeoutCheckerExecutorService</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> If using either of the <code>completionTimeout</code>, <code>completionTimeoutExpression</code>, or <code>completionInterval</code> options a background thread is created to check for the completion for every aggregator. Set this option to provide a custom thread pool to be used rather than creating a new thread for every aggregator.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>timeoutCheckerExecutorServiceRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> Reference to lookup a <code>timeoutCheckerExecutorService</code> in the <a shape="rect" href="registry.html">Registry</a></p></td></tr><tr><td colspan="1" rowspan="1"
  class="confluenceTd"><p>optimisticLocking</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.11:</strong> Turns on using optimistic locking, which requires the <code>aggregationRepository</code> being used, is supporting this by implementing the <code>org.apache.camel.spi.OptimisticLockingAggregationRepository</code> interface.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>optimisticLockRetryPolicy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong> Allows to configure retry settings when using optimistic locking.</p></td></tr></tbody></table></div></rich-text-body><h3 id="BookPatternAppendix-ExchangeProperties">Exchange Properties</h3><p>The following properties are set on each aggregated Exchange:</p><parameter ac:name="class">confluenceTableSmall</pa
 rameter><rich-text-body><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAggregatedSize</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The total number of Exchanges aggregated into this combined Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAggregatedCompletedBy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>String</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicator how the aggregation was completed as a value of either: <code>predicate</code>, <code>size</code>, <code>strategy</code>, <code>consumer</code>, <code>timeout</code>, <c
 ode>forceCompletion</code> or <code>interval</code>.</p></td></tr></tbody></table></div></rich-text-body><h3 id="BookPatternAppendix-AboutAggregationStrategy">About AggregationStrategy</h3><p>The <code>AggregationStrategy</code> is used for aggregating the old (lookup by its correlation id) and the new exchanges together into a single exchange. Possible implementations include performing some kind of combining or delta processing, such as adding line items together into an invoice or just using the newest exchange and removing old exchanges such as for state tracking or market data prices; where old values are of little use.</p><p>Notice the aggregation strategy is a mandatory option and must be provided to the aggregator.</p><p>Here are a few example AggregationStrategy implementations that should help you create your own custom strategy.</p><plain-text-body>//simply combines Exchange String body values using '+' as a delimiter
-class StringAggregationStrategy implements AggregationStrategy {
-
-    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
-        if (oldExchange == null) {
-            return newExchange;
-        }
-
-        String oldBody = oldExchange.getIn().getBody(String.class);
-        String newBody = newExchange.getIn().getBody(String.class);
-        oldExchange.getIn().setBody(oldBody + "+" + newBody);
-        return oldExchange;
-    }
-}
-
-//simply combines Exchange body values into an ArrayList&lt;Object&gt;
-class ArrayListAggregationStrategy implements AggregationStrategy {
-
-    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
-		Object newBody = newExchange.getIn().getBody();
-		ArrayList&lt;Object&gt; list = null;
-        if (oldExchange == null) {
-			list = new ArrayList&lt;Object&gt;();
-			list.add(newBody);
-			newExchange.getIn().setBody(list);
-			return newExchange;
-        } else {
-	        list = oldExchange.getIn().getBody(ArrayList.class);
-			list.add(newBody);
-			return oldExchange;
-		}
-    }
-}
-</plain-text-body><h3 id="BookPatternAppendix-Aboutcompletion">About completion</h3><p>When aggregation <a shape="rect" href="exchange.html">Exchange</a>s at some point you need to indicate that the aggregated exchanges is complete, so they can be send out of the aggregator. Camel allows you to indicate completion in various ways as follows:</p><ul class="alternate"><li>completionTimeout - Is an inactivity timeout in which is triggered if no new exchanges have been aggregated for that particular correlation key within the period.</li><li>completionInterval - Once every X period all the current aggregated exchanges are completed.</li><li>completionSize - Is a number indicating that after X aggregated exchanges it's complete.</li><li>completionPredicate - Runs a <a shape="rect" href="predicate.html">Predicate</a> when a new exchange is aggregated to determine if we are complete or not. Staring in&#160;<strong>Camel 2.15</strong>, the configured aggregationStrategy can implement the Pr
 edicate interface and will be used as the completionPredicate if no completionPredicate is configured. From&#160;<strong>Camel 2.16</strong>, the configured aggregationStrategy can implement&#160;<code>PreCompletionAwareAggregationStrategy</code> and will be used as the completionPredicate in pre-complete check mode. See further below for more details.</li><li>completionFromBatchConsumer - Special option for <a shape="rect" href="batch-consumer.html">Batch Consumer</a> which allows you to complete when all the messages from the batch has been aggregated.</li><li>forceCompletionOnStop - <strong>Camel 2.9</strong> Indicates to complete all current aggregated exchanges when the context is stopped</li><li>Using a&#160;<code>AggregateController</code> -&#160;<strong>Camel 2.16</strong> which allows to use an external source to complete groups or all groups. This can be done using Java or JMX API.</li></ul><p>Notice that all the completion ways are per correlation key. And you can combine
  them in any way you like. It's basically the first which triggers that wins. So you can use a completion size together with a completion timeout. Only completionTimeout and completionInterval cannot be used at the same time.</p><p>Notice the completion is a mandatory option and must be provided to the aggregator. If not provided Camel will thrown an Exception on startup.</p><parameter ac:name="title">Callbacks</parameter><rich-text-body><p>See the <code>TimeoutAwareAggregationStrategy</code> and <code>CompletionAwareAggregationStrategy</code> extensions to <code>AggregationStrategy</code> that has callbacks when the aggregated Exchange was completed and if a timeout occurred.</p></rich-text-body><h3 id="BookPatternAppendix-Pre-completionmode">Pre-completion mode</h3><p><strong>available as of Camel 2.16</strong></p><p>There can be use-cases where you want the incoming <a shape="rect" href="exchange.html">Exchange</a>&#160;to determine if the correlation group should pre-complete, a
 nd then the incoming <a shape="rect" href="exchange.html">Exchange</a>&#160;is starting a new group from scratch. To determine this the&#160;<code>AggregationStrategy</code> can implement&#160;<code>PreCompletionAwareAggregationStrategy</code> which has a&#160;<code>preComplete</code> method:</p><plain-text-body>    /**
-     * Determines if the aggregation should complete the current group, and start a new group, or the aggregation
-     * should continue using the current group.
-     *
-     * @param oldExchange the oldest exchange (is &lt;tt&gt;null&lt;/tt&gt; on first aggregation as we only have the new exchange)
-     * @param newExchange the newest exchange (can be &lt;tt&gt;null&lt;/tt&gt; if there was no data possible to acquire)
-     * @return &lt;tt&gt;true&lt;/tt&gt; to complete current group and start a new group, or &lt;tt&gt;false&lt;/tt&gt; to keep using current
-     */
-    boolean preComplete(Exchange oldExchange, Exchange newExchange);</plain-text-body><p>If the preComplete method returns true, then the existing groups is completed (without aggregating the incoming exchange (newExchange). And then the newExchange is used to start the correlation group from scratch so the group would contain only that new incoming exchange. This is known as pre-completion mode. And when the aggregation is in pre-completion mode, then only the following completions are in use</p><ul style="list-style-type: square;"><li>aggregationStrategy must implement&#160;<code>PreCompletionAwareAggregationStrategy</code>&#160;xxx</li><li>completionTimeout or completionInterval can also be used as fallback completions</li><li>any other completion are not used (such as by size, from batch consumer etc)</li><li>eagerCheckCompletion is implied as true, but the option has no effect</li></ul><h3 id="BookPatternAppendix-PersistentAggregationRepository">Persistent AggregationRepository
 </h3><p>The aggregator provides a pluggable repository which you can implement your own <code>org.apache.camel.spi.AggregationRepository</code>.<br clear="none"> If you need persistent repository then you can use either Camel <a shape="rect" href="hawtdb.html">HawtDB</a>, <a shape="rect" href="leveldb.html">LevelDB</a>, or <a shape="rect" href="sql-component.html">SQL Component</a> components.</p><h3 id="BookPatternAppendix-Examples.1">Examples</h3><p>See some examples from the old <a shape="rect" href="aggregator.html">Aggregator</a> which is somewhat similar to this new aggregator.</p><parameter ac:name="title">Setting options in Spring XML</parameter><rich-text-body><p>Many of the options are configurable as attributes on the <code>&lt;aggregate&gt;</code> tag when using Spring XML.</p></rich-text-body><h4 id="BookPatternAppendix-UsingcompletionTimeout">Using completionTimeout</h4><p>In this example we want to aggregate all incoming messages and after 3 seconds of inactivity we w
 ant the aggregation to complete. This is done using the <code>completionTimeout</code> option as shown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateSimpleTimeoutTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimpleTimeoutTest.xml}</plain-text-body></p><h4 id="BookPatternAppendix-UsingTimeoutAwareAggregationStrategy">Using TimeoutAwareAggregationStrategy</h4><p><strong>Available as of Camel 2.9.2</strong></p><p>If your aggregation strategy implements <code>TimeoutAwareAggregationStrategy</code>, then Camel will invoke the <code>timeout</code> method when the timeout occurs. Notice that the values for index and total parameters will be -1, and the timeout parameter will be provided only if configured as a fixed value. You mus
 t <strong>not</strong> throw any exceptions from the <code>timeout</code> method.</p><h4 id="BookPatternAppendix-UsingCompletionAwareAggregationStrategy">Using CompletionAwareAggregationStrategy</h4><p><strong>Available as of Camel 2.9.3</strong></p><p>If your aggregation strategy implements <code>CompletionAwareAggregationStrategy</code>, then Camel will invoke the <code>onComplete</code> method when the aggregated Exchange is completed. This allows you to do any last minute custom logic such as to cleanup some resources, or additional work on the exchange as it's now completed.<br clear="none"> You must <strong>not</strong> throw any exceptions from the <code>onCompletion</code> method.</p><h4 id="BookPatternAppendix-UsingcompletionSize">Using completionSize</h4><p>In this example we want to aggregate all incoming messages and when we have 3 messages aggregated (in the same correlation group) we want the aggregation to complete. This is done using the <code>completionSize</code> o
 ption as shown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateSimpleSizeTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimpleSizeTest.xml}</plain-text-body></p><h4 id="BookPatternAppendix-UsingcompletionPredicate">Using completionPredicate</h4><p>In this example we want to aggregate all incoming messages and use a <a shape="rect" href="predicate.html">Predicate</a> to determine when we are complete. The <a shape="rect" href="predicate.html">Predicate</a> can be evaluated using either the aggregated exchange (default) or the incoming exchange. We will give an example for both situations. We start with the default situation as shown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/ca
 mel/processor/aggregator/AggregateSimplePredicateTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimplePredicateTest.xml}</plain-text-body>And the other situation where we use the <code>eagerCheckCompletion</code> option to tell Camel to use the incoming Exchange. Notice how we can just test in the completion predicate that the incoming message is the <em>END</em> message:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateSimplePredicateEagerTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateSimplePredicateEagerTest.xml}</plain-text-body></p><h4 id="BookPatte
 rnAppendix-UsingdynamiccompletionTimeout">Using dynamic completionTimeout</h4><p>In this example we want to aggregate all incoming messages and after a period of inactivity we want the aggregation to complete. The period should be computed at runtime based on the <code>timeout</code> header in the incoming messages. This is done using the <code>completionTimeout</code> option as shown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateExpressionTimeoutTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionTimeoutTest.xml}</plain-text-body><strong>Note:</strong> You can also add a fixed timeout value and Camel will fallback to use this value if the dynamic value was <code>null</code> or <code>0</code>.</p><h4 id="BookPatternAppe
 ndix-UsingdynamiccompletionSize">Using dynamic completionSize</h4><p>In this example we want to aggregate all incoming messages based on a dynamic size per correlation key. The size is computed at runtime based on the <code>mySize</code> header in the incoming messages. This is done using the <code>completionSize</code> option as shown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateExpressionSizeTest.java}</plain-text-body>And the same example using Spring XML:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/aggregator/SpringAggregateExpressionSizeTest.xml}</plain-text-body><strong>Note:</strong> You can also add a fixed size value and Camel will fallback to use this value if the dynamic value was <code>null</code> or <code>0</code>.</p><p><parameter ac:name=""><a shape="rect" href="using-this-pattern.html">Using This
  Pattern</a></parameter></p><h4 id="BookPatternAppendix-CompletingcurrentgroupdecidedfromtheAggregationStrategy">Completing current group decided from the AggregationStrategy</h4><p><strong>Available as of Camel 2.15</strong></p><p>The&#160;<code>AggregationStrategy</code> can now included a property on the returned&#160;<code>Exchange</code> that contains a boolean to indicate if the current group should be completed. This allows to overrule any existing completion predicates / sizes / timeouts etc, and complete the group.</p><p>For example the following logic (from an unit test) will complete the group if the message body size is larger than 5. This is done by setting the property&#160;<span style="line-height: 1.4285715;">Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP to true.</span></p><plain-text-body>    public final class MyCompletionStrategy implements AggregationStrategy {
-        @Override
-        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
-            if (oldExchange == null) {
-                return newExchange;
-            }
-            String body = oldExchange.getIn().getBody(String.class) + "+" 
-                + newExchange.getIn().getBody(String.class);
-            oldExchange.getIn().setBody(body);
-            if (body.length() &gt;= 5) {
-                oldExchange.setProperty(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP, true);
-            }
-            return oldExchange;
-        }
-    }</plain-text-body><p>&#160;</p><h4 id="BookPatternAppendix-ManuallyForcetheCompletionofAllAggregatedExchangesImmediately">Manually Force the Completion of All Aggregated Exchanges Immediately</h4><p><strong>Available as of Camel 2.9</strong><br clear="none"> You can manually trigger completion of all current aggregated exchanges by sending a message containing the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true. The message is considered a signal message only, the message headers/contents will not be processed otherwise.</p><p><strong>Available as of Camel 2.11</strong><br clear="none"> You can alternatively set the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE to true to trigger completion of all groups after processing the current message.</p><h4 id="BookPatternAppendix-UsingaList&lt;V&gt;inAggregationStrategy">Using a List&lt;V&gt; in AggregationStrategy</h4><p><strong>Available as of Camel 2.11</strong></p><p>If you want to aggregate some value from 
 the messages &lt;V&gt; into a List&lt;V&gt; then we have added a <code>org.apache.camel.processor.aggregate.AbstractListAggregationStrategy</code> abstract class in <strong>Camel 2.11</strong> that makes this easier. The completed Exchange that is sent out of the aggregator will contain the List&lt;V&gt; in the message body.</p><p>For example to aggregate a List&lt;Integer&gt; you can extend this class as shown below, and implement the <code>getValue</code> method:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/CustomListAggregationStrategyTest.java}</plain-text-body></p><h3 id="BookPatternAppendix-UsingAggregateController">Using AggregateController</h3><p><strong>Available as of Camel 2.16</strong></p><p>The&#160;<code>org.apache.camel.processor.aggregate.AggregateController</code> allows you to control the aggregate at runtime using Java or JMX API. This can be used to force completing groups of exchanges, or
  query its current runtime statistics.</p><p>The aggregator provides a default implementation if no custom have been configured, which can be accessed using&#160;<code>getAggregateController()</code>&#160;method. Though it may be easier to configure a controller in the route using aggregateController as shown below:</p><plain-text-body>private AggregateController controller = new DefaultAggregateController();
-&#160;
-from("direct:start")
-   .aggregate(header("id"), new MyAggregationStrategy()).completionSize(10).id("myAggregator")
-      .aggregateController(controller)
-      .to("mock:aggregated");</plain-text-body><p>Then there is API on AggregateController to force completion. For example to complete a group with key foo</p><plain-text-body>int groups = controller.forceCompletionOfGroup("foo");</plain-text-body><p>The number return would be the number of groups completed. In this case it would be 1 if the foo group existed and was completed. If foo does not exists then 0 is returned.</p><p>There is also an api to complete all groups</p><plain-text-body>int groups = controller.forceCompletionOfAllGroups();</plain-text-body><p>&#160;</p><p>To configure this from XML DSL</p><plain-text-body>&lt;bean id="myController" class="org.apache.camel.processor.aggregate.DefaultAggregateController"/&gt;
-&#160;

[... 573 lines stripped ...]