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 2015/07/12 15:20:18 UTC

svn commit: r957998 [3/3] - in /websites/production/camel/content: book-in-one-page.html book-pattern-appendix.html cache/main.pageCache camel-2160-release.html content-enricher.html

Modified: websites/production/camel/content/content-enricher.html
==============================================================================
--- websites/production/camel/content/content-enricher.html (original)
+++ websites/production/camel/content/content-enricher.html Sun Jul 12 13:20:18 2015
@@ -86,20 +86,20 @@
 	<tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h3 id="ContentEnricher-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="content-enricher.html">enrich</a> DSL element to enrich the message.</p><p><span class="confluence-embedded-file-wrapper"><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"></span></p><h4 id="ContentEnricher-ContentenrichmentusingaMessageTranslatororaProcessor">Content en
 richment 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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("activemq:My.Queue").
-  to("velocity:com/acme/MyResponse.vm").
-  to("activemq:Another.Queue");
-</pre>
+<div class="wiki-content maincontent"><h3 id="ContentEnricher-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="#ContentEnricher-enrich-dsl">enrich</a> DSL element to enrich the message.</p><p><span class="confluence-embedded-file-wrapper"><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"></span></p><h4 id="ContentEnricher-ContentenrichmentusingaMessageTranslatororaProcessor">Cont
 ent 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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;activemq:My.Queue&quot;).
+  to(&quot;velocity:com/acme/MyResponse.vm&quot;).
+  to(&quot;activemq:Another.Queue&quot;);
+]]></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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("activemq:My.Queue").
-  to("velocity:com/acme/MyResponse.vm");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;activemq:My.Queue&quot;).
+  to(&quot;velocity:com/acme/MyResponse.vm&quot;);
+]]></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">
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
 from(&quot;direct:start&quot;).setBody(body().append(&quot; World!&quot;)).to(&quot;mock:result&quot;);
 ]]></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>In this example we add our own <a shape="rect" href="processor.html">Processor</a> using explicit Java code<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;).process(new Processor() {
     public void process(Exchange exchange) {
@@ -108,30 +108,30 @@ from(&quot;direct:start&quot;).process(n
     }
 }).to(&quot;mock:result&quot;);
 ]]></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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("activemq:My.Queue").
-  beanRef("myBeanName", "myMethodName").
-  to("activemq:Another.Queue");
-</pre>
+</div></div>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<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;activemq:My.Queue&quot;).
+  beanRef(&quot;myBeanName&quot;, &quot;myMethodName&quot;).
+  to(&quot;activemq:Another.Queue&quot;);
+]]></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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;route&gt;
-  &lt;from uri="activemq:Input"/&gt;
-  &lt;bean ref="myBeanName" method="doTransform"/&gt;
-  &lt;to uri="activemq:Output"/&gt;
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;route&gt;
+  &lt;from uri=&quot;activemq:Input&quot;/&gt;
+  &lt;bean ref=&quot;myBeanName&quot; method=&quot;doTransform&quot;/&gt;
+  &lt;to uri=&quot;activemq:Output&quot;/&gt;
 &lt;/route&gt;
-</pre>
-</div></div><p><span class="confluence-anchor-link" id="ContentEnricher-enrich-dsl"></span></p><h3 id="ContentEnricher-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="confluence-information-macro co
 nfluence-information-macro-warning"><p class="title">Data from current Exchange not used</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><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">Re
 cipient List</a> which then would work as a <code>enrich</code> would do.</p><p>pollEnrich only accept one message as response. That means that if you target to enrich your original message with the enricher collecting messages from a seda, ... components using an aggregation strategy. Only one response message will be aggregated with the original message</p><p>&#160;</p></div></div><h3 id="ContentEnricher-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>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The endpoint uri for the external ser
 vice 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>&#160;</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>&#160;</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 outgoin
 g 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>&#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 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 aggrega
 te 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"><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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">AggregationStrategy aggregationStrategy = ...
+]]></script>
+</div></div><p><span class="confluence-anchor-link" id="ContentEnricher-enrich-dsl"></span></p><h3 id="ContentEnricher-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="confluence-information-macro co
 nfluence-information-macro-warning"><p class="title">Data from current Exchange not used</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><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">Re
 cipient List</a> which then would work as a <code>enrich</code> would do.</p><p>pollEnrich only accept one message as response. That means that if you target to enrich your original message with the enricher collecting messages from a seda, ... components using an aggregation strategy. Only one response message will be aggregated with the original message</p><p>&#160;</p></div></div><h3 id="ContentEnricher-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>&#160;</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The endpoint uri for the external ser
 vice 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>&#160;</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>&#160;</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 outgoin
 g 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>&#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 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 aggrega
 te 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"><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><
 tr><td colspan="1" rowspan="1" class="confluenceTd"><code>shareUnitOfWork</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong> <span style="color: rgb(0,0,0);">&#160;Shares the unit of work with the parent and the resource exchange. Enrich will by default not share unit of work between the parent exchange and the resource exchange. This means the resource exchange has its own individual unit of work. See <a shape="rect" href="splitter.html">Splitter</a> for more information and example.</span></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="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[AggregationStrategy aggregationStrategy = ...
 
-from("direct:start")
-.enrich("direct:resource", aggregationStrategy)
-.to("direct:result");
+from(&quot;direct:start&quot;)
+.enrich(&quot;direct:resource&quot;, aggregationStrategy)
+.to(&quot;direct:result&quot;);
 
-from("direct:resource")
+from(&quot;direct:resource&quot;)
 ...
-</pre>
+]]></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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class ExampleAggregationStrategy implements AggregationStrategy {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[public class ExampleAggregationStrategy implements AggregationStrategy {
 
     public Exchange aggregate(Exchange original, Exchange resource) {
         Object originalBody = original.getIn().getBody();
@@ -146,53 +146,53 @@ from("direct:resource")
     }
     
 }
-</pre>
+]]></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">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;camelContext id=&quot;camel&quot; xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
   &lt;route&gt;
-    &lt;from uri="direct:start"/&gt;
-    &lt;enrich uri="direct:resource" strategyRef="aggregationStrategy"/&gt;
-    &lt;to uri="direct:result"/&gt;
+    &lt;from uri=&quot;direct:start&quot;/&gt;
+    &lt;enrich uri=&quot;direct:resource&quot; strategyRef=&quot;aggregationStrategy&quot;/&gt;
+    &lt;to uri=&quot;direct:result&quot;/&gt;
   &lt;/route&gt;
   &lt;route&gt;
-    &lt;from uri="direct:resource"/&gt;
+    &lt;from uri=&quot;direct:resource&quot;/&gt;
     ...
   &lt;/route&gt;
 &lt;/camelContext&gt;
 
-&lt;bean id="aggregationStrategy" class="..." /&gt;
-</pre>
+&lt;bean id=&quot;aggregationStrategy&quot; class=&quot;...&quot; /&gt;
+]]></script>
 </div></div><h4 id="ContentEnricher-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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("direct:start")
-  .enrich("direct:resource")
-  .to("direct:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+  .enrich(&quot;direct:resource&quot;)
+  .to(&quot;direct:result&quot;);
+]]></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">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">  &lt;route&gt;
-    &lt;from uri="direct:start"/&gt;
-    &lt;enrich uri="direct:resource"/&gt;
-    &lt;to uri="direct:result"/&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[  &lt;route&gt;
+    &lt;from uri=&quot;direct:start&quot;/&gt;
+    &lt;enrich uri=&quot;direct:resource&quot;/&gt;
+    &lt;to uri=&quot;direct:result&quot;/&gt;
   &lt;/route&gt;
-</pre>
+]]></script>
 </div></div><h3 id="ContentEnricher-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="ContentEnricher-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>&#160;</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>&#160;</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>&#160;</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 ex
 ternal 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>&#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 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>fals
 e</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 aggregat
 e 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="confluence-information-macro confluence-information-macro-information"><p class="title">Good practice to use timeout value</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><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 ag
 gregation 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="confluence-information-macro confluence-information-macro-warning"><p class="title">Data from current Exchange not used</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><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="ContentEnricher-Example">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">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("direct:start")
-  .pollEnrich("file:inbox?fileName=data.txt")
-  .to("direct:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
+  .pollEnrich(&quot;file:inbox?fileName=data.txt&quot;)
+  .to(&quot;direct:result&quot;);
+]]></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">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">  &lt;route&gt;
-    &lt;from uri="direct:start"/&gt;
-    &lt;pollEnrich uri="file:inbox?fileName=data.txt"/&gt;
-    &lt;to uri="direct:result"/&gt;
+<script class="brush: xml; gutter: false; theme: Default" 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;direct:result&quot;/&gt;
   &lt;/route&gt;
-</pre>
+]]></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">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">  &lt;route&gt;
-    &lt;from uri="direct:start"/&gt;
-    &lt;pollEnrich uri="file:inbox?fileName=data.txt" timeout="5000"/&gt;
-    &lt;to uri="direct:result"/&gt;
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[  &lt;route&gt;
+    &lt;from uri=&quot;direct:start&quot;/&gt;
+    &lt;pollEnrich uri=&quot;file:inbox?fileName=data.txt&quot; timeout=&quot;5000&quot;/&gt;
+    &lt;to uri=&quot;direct:result&quot;/&gt;
   &lt;/route&gt;
-</pre>
+]]></script>
 </div></div><p></p><h4 id="ContentEnricher-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></div>
@@ -201,7 +201,7 @@ from("direct:resource")
           <div class="navigation">
             <div class="navigation_top">
                 <!-- NavigationBar -->
-<div class="navigation_bottom" id="navigation_bottom"><h3 id="Navigation-Overviewhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49132"><a shape="rect" href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a shape="rect" href="download.html">Download</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li><li><a shape="rect" href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentationhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49534"><a shape="rect" href="documentation.html">Documentation</a></h3><ul class="alternate"><li><a shape="rect" href="user-guide.html">User Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a shape="rect" href="books.html">Books</a></li><li><a shape="rect" href="tutorials.html">Tutorials</a></li><li><a shape="rect" href="examples.html">Examples</a></li><li><a shape="rect" href="cookbook.html">Cookbook</a></li>
 <li><a shape="rect" href="architecture.html">Architecture</a></li><li><a shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" href="components.html">Components</a></li><li><a shape="rect" href="data-format.html">Data Format</a></li><li><a shape="rect" href="languages.html">Languages</a></li><li><a shape="rect" href="security.html">Security</a></li><li><a shape="rect" href="security-advisories.html">Security Advisories</a></li></ul><h3 id="Navigation-Search">Search</h3><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
+<div class="navigation_bottom" id="navigation_bottom"><h3 id="Navigation-Overview"><a shape="rect" href="overview.html">Overview</a></h3><ul class="alternate"><li><a shape="rect" href="index.html">Home</a></li><li><a shape="rect" href="download.html">Download</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li><li><a shape="rect" href="faq.html">FAQ</a></li></ul><h3 id="Navigation-Documentation"><a shape="rect" href="documentation.html">Documentation</a></h3><ul class="alternate"><li><a shape="rect" href="user-guide.html">User Guide</a></li><li><a shape="rect" href="manual.html">Manual</a></li><li><a shape="rect" href="books.html">Books</a></li><li><a shape="rect" href="tutorials.html">Tutorials</a></li><li><a shape="rect" href="examples.html">Examples</a></li><li><a shape="rect" href="cookbook.html">Cookbook</a></li><li><a shape="rect" href="architecture.html">Architecture</a></li><li><a shape="rect" href="enterprise-integration-patterns.html">Enterprise
  Integration Patterns</a></li><li><a shape="rect" href="dsl.html">DSL</a></li><li><a shape="rect" href="components.html">Components</a></li><li><a shape="rect" href="data-format.html">Data Format</a></li><li><a shape="rect" href="languages.html">Languages</a></li><li><a shape="rect" href="security.html">Security</a></li><li><a shape="rect" href="security-advisories.html">Security Advisories</a></li></ul><h3 id="Navigation-Search">Search</h3><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
   <div>
     <input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
     <input type="hidden" name="ie" value="UTF-8">
@@ -209,7 +209,7 @@ from("direct:resource")
     <input type="submit" name="sa" value="Search">
   </div>
 </form>
-<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script><h3 id="Navigation-Communityhttps://cwiki.apache.org/confluence/pages/viewpage.action?pageId=49115"><a shape="rect" href="community.html">Community</a></h3><ul class="alternate"><li><a shape="rect" href="support.html">Support</a></li><li><a shape="rect" href="contributing.html">Contributing</a></li><li><a shape="rect" href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect" href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect" href="user-stories.html">User Stories</a></li><li><a shape="rect" href="news.html">News</a></li><li><a shape="rect" href="articles.html">Articles</a></li><li><a shape="rect" href="site.html">Site</a></li><li><a shape="rect" href="team.html">Team</a></li><li><a shape="rect" class="external-link" href="http://camel-extra.googlecode.com/" rel="nofollow">Camel Extra</a></li></ul><h3 id="Navigation-Developershttps://cwi
 ki.apache.org/confluence/pages/viewpage.action?pageId=49124"><a shape="rect" href="developers.html">Developers</a></h3><ul class="alternate"><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect" href="source.html">Source</a></li><li><a shape="rect" href="building.html">Building</a></li><li><a shape="rect" href="javadoc.html">JavaDoc</a></li><li><a shape="rect" href="irc-room.html">IRC Room</a></li></ul><h3 id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul class="alternate"><li><a shape="rect" class="external-link" href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/security/">Security</a></li></ul></div>
+<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en"></script><h3 id="Navigation-Community"><a shape="rect" href="community.html">Community</a></h3><ul class="alternate"><li><a shape="rect" href="support.html">Support</a></li><li><a shape="rect" href="contributing.html">Contributing</a></li><li><a shape="rect" href="discussion-forums.html">Discussion Forums</a></li><li><a shape="rect" href="mailing-lists.html">Mailing Lists</a></li><li><a shape="rect" href="user-stories.html">User Stories</a></li><li><a shape="rect" href="news.html">News</a></li><li><a shape="rect" href="articles.html">Articles</a></li><li><a shape="rect" href="site.html">Site</a></li><li><a shape="rect" href="team.html">Team</a></li><li><a shape="rect" class="external-link" href="http://camel-extra.googlecode.com/" rel="nofollow">Camel Extra</a></li></ul><h3 id="Navigation-Developers"><a shape="rect" href="developers.html">Developers</a></h3><ul class="alternate"
 ><li><a shape="rect" href="developers.html">Developer Guide</a></li><li><a shape="rect" href="source.html">Source</a></li><li><a shape="rect" href="building.html">Building</a></li><li><a shape="rect" href="javadoc.html">JavaDoc</a></li><li><a shape="rect" href="irc-room.html">IRC Room</a></li></ul><h3 id="Navigation-ApacheSoftwareFoundation">Apache Software Foundation</h3><ul class="alternate"><li><a shape="rect" class="external-link" href="http://www.apache.org/licenses/">License</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/foundation/thanks.html">Thanks</a></li><li><a shape="rect" class="external-link" href="http://www.apache.org/security/">Security</a></li></ul></div>
                 <!-- NavigationBar -->
             </div>
           </div>