Modified: websites/production/camel/content/load-balancer.html
==============================================================================
--- websites/production/camel/content/load-balancer.html (original)
+++ websites/production/camel/content/load-balancer.html Fri Aug 25 08:22:01 
2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Load Balancer
@@ -86,218 +75,107 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h3 id="LoadBalancer-LoadBalancer">Load 
Balancer</h3><p>The Load Balancer Pattern allows you to delegate to one of a 
number of endpoints using a variety of different load balancing 
policies.</p><h3 id="LoadBalancer-Built-inloadbalancingpolicies">Built-in load 
balancing policies</h3><p>Camel provides the following policies 
out-of-the-box:</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Policy</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.html";>Round
 Robin</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The 
exchanges are selected from in a round robin fashion. This is a well known and 
classic policy, which
  spreads the load evenly.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/RandomLoadBalancer.html";>Random</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>A random endpoint is selected 
for each exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.html";>Sticky</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Sticky load balancing using an 
Expression to calculate a correlation key to perform the sticky load balancing; 
rather like jsessionid in the web or JMSXGroupID in JMS.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" href="http://camel.apache.org/maven
 
/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.html">Topic</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Topic which sends to all 
destinations (rather like JMS Topics)</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.html";>Failover</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>In case of failures the 
exchange will be tried on the next endpoint.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Weighted Round-Robin</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> The 
weighted load balancing policy allows you to specify a processing load 
distribution ratio for each server with respect to the others. In addition to 
the weight, endpoint selection is then further refined using <
 strong>round-robin</strong> distribution based on weight.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Weighted Random</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> The 
weighted load balancing policy allows you to specify a processing load 
distribution ratio for each server with respect to others.In addition to the 
weight, endpoint selection is then further refined using 
<strong>random</strong> distribution based on weight.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Custom</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> From Camel 2.8 
onwards the preferred way of using a custom <a shape="rect" 
href="load-balancer.html">Load Balancer</a> is to use this policy, instead of 
using the @deprecated <code>ref</code> attribute.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">Circuit Breaker</td><td 
colspan="1" rowspan="1" class="confluenceTd"><
 p><strong>Camel 2.14:</strong> Implements the&#160;Circuit Breaker pattern as 
described in "Release it!" book.</p></td></tr></tbody></table></div><div 
class="confluence-information-macro confluence-information-macro-tip"><p 
class="title">Load balancing HTTP endpoints</p><span class="aui-icon 
aui-icon-small aui-iconfont-approve 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>If you are proxying and load 
balancing HTTP, then see <a shape="rect" 
href="how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html">this 
page</a> for more details.</p></div></div><h3 
id="LoadBalancer-RoundRobin">Round Robin</h3><p>The round robin load balancer 
is not meant to work with failover, for that you should use the dedicated 
<strong>failover</strong> load balancer. The round robin load balancer will 
only change to next endpoint per message.</p><p>The round robin load balancer 
is stateful as it keeps state of which endpoint to use next time.</p><p><str
 ong>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;direct:start&quot;).loadBalance().
-roundRobin().to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
-]]></script>
-</div></div><strong>Using the Spring configuration</strong><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 id=&quot;camel&quot; 
xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
+<div class="wiki-content maincontent"><h3 id="LoadBalancer-LoadBalancer">Load 
Balancer</h3><p>The Load Balancer Pattern allows you to delegate to one of a 
number of endpoints using a variety of different load balancing 
policies.</p><h3 id="LoadBalancer-Built-inloadbalancingpolicies">Built-in load 
balancing policies</h3><p>Camel provides the following policies 
out-of-the-box:</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Policy</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/RoundRobinLoadBalancer.html";>Round
 Robin</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The 
exchanges are selected from in a round robin fashion. This is a well known and 
classic policy, which
  spreads the load evenly.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/RandomLoadBalancer.html";>Random</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>A random endpoint is selected 
for each exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/StickyLoadBalancer.html";>Sticky</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Sticky load balancing using an 
Expression to calculate a correlation key to perform the sticky load balancing; 
rather like jsessionid in the web or JMSXGroupID in JMS.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" 
class="external-link" href="http://camel.apache.org/maven
 
/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/TopicLoadBalancer.html">Topic</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Topic which sends to all 
destinations (rather like JMS Topics)</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.html";>Failover</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>In case of failures the 
exchange will be tried on the next endpoint.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Weighted Round-Robin</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> The 
weighted load balancing policy allows you to specify a processing load 
distribution ratio for each server with respect to the others. In addition to 
the weight, endpoint selection is then further refined using <
 strong>round-robin</strong> distribution based on weight.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Weighted Random</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> The 
weighted load balancing policy allows you to specify a processing load 
distribution ratio for each server with respect to others.In addition to the 
weight, endpoint selection is then further refined using 
<strong>random</strong> distribution based on weight.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Custom</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> From Camel 2.8 
onwards the preferred way of using a custom <a shape="rect" 
href="load-balancer.html">Load Balancer</a> is to use this policy, instead of 
using the @deprecated <code>ref</code> attribute.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">Circuit Breaker</td><td 
colspan="1" rowspan="1" class="confluenceTd"><
 p><strong>Camel 2.14:</strong> Implements the&#160;Circuit Breaker pattern as 
described in "Release it!" book.</p></td></tr></tbody></table></div><parameter 
ac:name="title">Load balancing HTTP endpoints</parameter><rich-text-body><p>If 
you are proxying and load balancing HTTP, then see <a shape="rect" 
href="how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html">this 
page</a> for more details.</p></rich-text-body><h3 
id="LoadBalancer-RoundRobin">Round Robin</h3><p>The round robin load balancer 
is not meant to work with failover, for that you should use the dedicated 
<strong>failover</strong> load balancer. The round robin load balancer will 
only change to next endpoint per message.</p><p>The round robin load balancer 
is stateful as it keeps state of which endpoint to use next 
time.</p><p><strong>Using the <a shape="rect" 
href="fluent-builders.html">Fluent 
Builders</a></strong><plain-text-body>{snippet:id=example|lang=java|url=camel/trunk/camel-core/src/test/java/org/apach
 
e/camel/processor/RoundRobinLoadBalanceTest.java}</plain-text-body><strong>Using
 the Spring configuration</strong></p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;camelContext id="camel" 
xmlns="http://camel.apache.org/schema/spring"&gt;
   &lt;route&gt;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
+    &lt;from uri="direct:start"/&gt;
     &lt;loadBalance&gt;        
         &lt;roundRobin/&gt;
-        &lt;to uri=&quot;mock:x&quot;/&gt;        
-        &lt;to uri=&quot;mock:y&quot;/&gt;       
-        &lt;to uri=&quot;mock:z&quot;/&gt;                 
+        &lt;to uri="mock:x"/&gt;        
+        &lt;to uri="mock:y"/&gt;       
+        &lt;to uri="mock:z"/&gt;                 
     &lt;/loadBalance&gt;
   &lt;/route&gt;
 &lt;/camelContext&gt;
-]]></script>
-</div></div><p>The above example loads balance requests from 
<strong>direct:start</strong> to one of the available <strong>mock 
endpoint</strong> instances, in this case using a round robin policy.<br 
clear="none"> For further examples of this pattern look at <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoundRobinLoadBalanceTest.java?view=markup";>this
 junit test case</a></p><h3 id="LoadBalancer-Failover">Failover</h3><p>The 
<code>failover</code> load balancer is capable of trying the next processor in 
case an <a shape="rect" href="exchange.html">Exchange</a> failed with an 
<code>exception</code> during processing.<br clear="none"> You can constrain 
the <code>failover</code> to activate only when one exception of a list you 
specify occurs. If you do not specify a list any exception will cause fail over 
to occur. This balancer uses the same strategy for matching exceptions as the 
<a shape="rect
 " href="exception-clause.html">Exception Clause</a> does for the 
<strong>onException</strong>.</p><div class="confluence-information-macro 
confluence-information-macro-information"><p class="title">Enable stream 
caching if using streams</p><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>If you use streaming then you 
should enable <a shape="rect" href="stream-caching.html">Stream caching</a> 
when using the failover load balancer. This is needed so the stream can be 
re-read after failing over to the next processor.</p></div></div><p>Failover 
offers the following options:</p><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>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>D
 escription</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>inheritErrorHandler</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>true</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether or not the <a 
shape="rect" href="error-handler.html">Error Handler</a> configured on the 
route should be used. Disable this if you want failover to transfer immediately 
to the next endpoint. On the other hand, if you have this option enabled, then 
Camel will first let the <a shape="rect" href="error-handler.html">Error 
Handler</a> try to process the message. The <a shape="rect" 
href="error-handler.html">Error Handler</a> may have been configured to 
redeliver and use delays between attempts. If you have enabled a number of 
redeliveries then Camel will try to redeliver to the <strong>same</strong> 
endpoint, and only fail over to the next endpoint, when the <a sh
 ape="rect" href="error-handler.html">Error Handler</a> is 
exhausted.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>maximumFailoverAttempts</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>-1</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.3:</strong> A value to indicate after X 
failover attempts we should exhaust (give up). Use -1 to indicate never give up 
and continuously try to failover. Use 0 to never failover. And use e.g. 3 to 
failover at most 3 times before giving up. This option can be used whether or 
not roundRobin is enabled or not.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>roundRobin</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether or not the <c
 ode>failover</code> load balancer should operate in round robin mode or not. 
If not, then it will <strong>always</strong> start from the first endpoint when 
a new message is to be processed. In other words it restart from the top for 
every message. If round robin is enabled, then it keeps state and will continue 
with the next endpoint in a round robin fashion. When using round robin it will 
not <em>stick</em> to last known good endpoint, it will always pick the next 
endpoint to use. <span>You can also enable sticky mode together with round 
robin, if so then it will pick the last known good endpoint </span><span>to use 
when starting the load balancing (instead of using the next when 
starting).</span></p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">sticky</td><td colspan="1" rowspan="1" 
class="confluenceTd">boolean</td><td colspan="1" rowspan="1" 
class="confluenceTd">false</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.16:</strong> Whether or no
 t the failover load balancer should operate in sticky mode or not. If not, 
then it will always start from the first endpoint when a new message is to be 
processed. In other words it restart from the top for every message. If sticky 
is enabled, then it keeps state and will continue with the last known good 
endpoint. You can also enable sticky mode together with round robin, if so then 
it will pick the last known good endpoint to use when starting the load 
balancing (instead of using the next when 
starting).</td></tr></tbody></table></div><p><strong>Camel 2.2 or older 
behavior</strong><br clear="none"> The current implementation of failover load 
balancer uses simple logic which <strong>always</strong> tries the first 
endpoint, and in case of an exception being thrown it tries the next in the 
list, and so forth. It has no state, and the next message will thus 
<strong>always</strong> start with the first endpoint.</p><p><strong>Camel 2.3 
onwards behavior</strong><br clear="none"> The <c
 ode>failover</code> load balancer now supports round robin mode, which allows 
you to failover in a round robin fashion. See the <code>roundRobin</code> 
option.</p><div class="confluence-information-macro 
confluence-information-macro-note"><p class="title">Redelivery must be 
enabled</p><span class="aui-icon aui-icon-small aui-iconfont-warning 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>In Camel 2.2 or older the failover 
load balancer requires you have enabled Camel <a shape="rect" 
href="error-handler.html">Error Handler</a> to use redelivery. In Camel 2.3 
onwards this is not required as such, as you can mix and match. See the 
<code>inheritErrorHandler</code> option.</p></div></div><p>Here is a sample to 
failover only if a <code>IOException</code> related exception was 
thrown:</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;)
-    // here we will load balance if IOException was thrown
-    // any other kind of exception will result in the Exchange as failed
-    // to failover over any kind of exception we can just omit the exception
-    // in the failOver DSL
-    .loadBalance().failover(IOException.class)
-        .to(&quot;direct:x&quot;, &quot;direct:y&quot;, &quot;direct:z&quot;);
-]]></script>
-</div></div>You can specify multiple exceptions to failover as the option is 
varargs, for instance:<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[// enable redelivery so failover can react
+</plain-text-body><p>The above example loads balance requests from 
<strong>direct:start</strong> to one of the available <strong>mock 
endpoint</strong> instances, in this case using a round robin policy.<br 
clear="none"> For further examples of this pattern look at <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoundRobinLoadBalanceTest.java?view=markup";>this
 junit test case</a></p><h3 id="LoadBalancer-Failover">Failover</h3><p>The 
<code>failover</code> load balancer is capable of trying the next processor in 
case an <a shape="rect" href="exchange.html">Exchange</a> failed with an 
<code>exception</code> during processing.<br clear="none"> You can constrain 
the <code>failover</code> to activate only when one exception of a list you 
specify occurs. If you do not specify a list any exception will cause fail over 
to occur. This balancer uses the same strategy for matching exceptions as the 
<a shape
 ="rect" href="exception-clause.html">Exception Clause</a> does for the 
<strong>onException</strong>.</p><parameter ac:name="title">Enable stream 
caching if using streams</parameter><rich-text-body><p>If you use streaming 
then you should enable <a shape="rect" href="stream-caching.html">Stream 
caching</a> when using the failover load balancer. This is needed so the stream 
can be re-read after failing over to the next 
processor.</p></rich-text-body><p>Failover offers the following 
options:</p><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>Type</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>inheritErrorHandler</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>boolean</p></td><td co
 lspan="1" rowspan="1" class="confluenceTd"><p>true</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether or not 
the <a shape="rect" href="error-handler.html">Error Handler</a> configured on 
the route should be used. Disable this if you want failover to transfer 
immediately to the next endpoint. On the other hand, if you have this option 
enabled, then Camel will first let the <a shape="rect" 
href="error-handler.html">Error Handler</a> try to process the message. The <a 
shape="rect" href="error-handler.html">Error Handler</a> may have been 
configured to redeliver and use delays between attempts. If you have enabled a 
number of redeliveries then Camel will try to redeliver to the 
<strong>same</strong> endpoint, and only fail over to the next endpoint, when 
the <a shape="rect" href="error-handler.html">Error Handler</a> is 
exhausted.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>maximumFailoverAttempts</p></td><td colspan=
 "1" rowspan="1" class="confluenceTd"><p>int</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>-1</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.3:</strong> A value to indicate after X 
failover attempts we should exhaust (give up). Use -1 to indicate never give up 
and continuously try to failover. Use 0 to never failover. And use e.g. 3 to 
failover at most 3 times before giving up. This option can be used whether or 
not roundRobin is enabled or not.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>roundRobin</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.3:</strong> Whether or not the 
<code>failover</code> load balancer should operate in round robin mode or not. 
If not, then it will <strong>always</strong> start from the first endpoint when 
a new message is to be pr
 ocessed. In other words it restart from the top for every message. If round 
robin is enabled, then it keeps state and will continue with the next endpoint 
in a round robin fashion. When using round robin it will not <em>stick</em> to 
last known good endpoint, it will always pick the next endpoint to use. 
<span>You can also enable sticky mode together with round robin, if so then it 
will pick the last known good endpoint </span><span>to use when starting the 
load balancing (instead of using the next when 
starting).</span></p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">sticky</td><td colspan="1" rowspan="1" 
class="confluenceTd">boolean</td><td colspan="1" rowspan="1" 
class="confluenceTd">false</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.16:</strong> Whether or not the failover 
load balancer should operate in sticky mode or not. If not, then it will always 
start from the first endpoint when a new message is to be processed. In other 
words it 
 restart from the top for every message. If sticky is enabled, then it keeps 
state and will continue with the last known good endpoint. You can also enable 
sticky mode together with round robin, if so then it will pick the last known 
good endpoint to use when starting the load balancing (instead of using the 
next when starting).</td></tr></tbody></table></div><p><strong>Camel 2.2 or 
older behavior</strong><br clear="none"> The current implementation of failover 
load balancer uses simple logic which <strong>always</strong> tries the first 
endpoint, and in case of an exception being thrown it tries the next in the 
list, and so forth. It has no state, and the next message will thus 
<strong>always</strong> start with the first endpoint.</p><p><strong>Camel 2.3 
onwards behavior</strong><br clear="none"> The <code>failover</code> load 
balancer now supports round robin mode, which allows you to failover in a round 
robin fashion. See the <code>roundRobin</code> option.</p><parameter ac:name=
 "title">Redelivery must be enabled</parameter><rich-text-body><p>In Camel 2.2 
or older the failover load balancer requires you have enabled Camel <a 
shape="rect" href="error-handler.html">Error Handler</a> to use redelivery. In 
Camel 2.3 onwards this is not required as such, as you can mix and match. See 
the <code>inheritErrorHandler</code> option.</p></rich-text-body><p>Here is a 
sample to failover only if a <code>IOException</code> related exception was 
thrown:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailOverNotCatchedExceptionTest.java}</plain-text-body>You
 can specify multiple exceptions to failover as the option is varargs, for 
instance:</p><parameter ac:name="">java</parameter><plain-text-body>// enable 
redelivery so failover can react
 errorHandler(defaultErrorHandler().maximumRedeliveries(5));
 
-from(&quot;direct:foo&quot;).
+from("direct:foo").
     loadBalance().failover(IOException.class, MyOtherException.class)
-        .to(&quot;direct:a&quot;, &quot;direct:b&quot;);
-]]></script>
-</div></div><h4 id="LoadBalancer-UsingfailoverinSpringDSL">Using failover in 
Spring DSL</h4><p>Failover can also be used from Spring DSL and you configure 
it as:</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 
errorHandlerRef=&quot;myErrorHandler&quot;&gt;
-      &lt;from uri=&quot;direct:foo&quot;/&gt;
+        .to("direct:a", "direct:b");
+</plain-text-body><h4 id="LoadBalancer-UsingfailoverinSpringDSL">Using 
failover in Spring DSL</h4><p>Failover can also be used from Spring DSL and you 
configure it as:</p><parameter ac:name="">xml</parameter><plain-text-body>   
&lt;route errorHandlerRef="myErrorHandler"&gt;
+      &lt;from uri="direct:foo"/&gt;
       &lt;loadBalance&gt;
           &lt;failover&gt;
               &lt;exception&gt;java.io.IOException&lt;/exception&gt;
               &lt;exception&gt;com.mycompany.MyOtherException&lt;/exception&gt;
           &lt;/failover&gt;
-          &lt;to uri=&quot;direct:a&quot;/&gt;
-          &lt;to uri=&quot;direct:b&quot;/&gt;
+          &lt;to uri="direct:a"/&gt;
+          &lt;to uri="direct:b"/&gt;
       &lt;/loadBalance&gt;
     &lt;/route&gt;
-]]></script>
-</div></div><h4 id="LoadBalancer-Usingfailoverinroundrobinmode">Using failover 
in round robin mode</h4><p>An example using 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;)
-    // Use failover load balancer in stateful round robin mode
-    // which mean it will failover immediately in case of an exception
-    // as it does NOT inherit error handler. It will also keep retrying as
-    // its configured to newer exhaust.
-    .loadBalance().failover(-1, false, true).
-        to(&quot;direct:bad&quot;, &quot;direct:bad2&quot;, 
&quot;direct:good&quot;, &quot;direct:good2&quot;);
-]]></script>
-</div></div>And the same example using Spring XML:<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;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
-    &lt;loadBalance&gt;
-        &lt;!-- failover using stateful round robin,
-             which will keep retrying forever those 4 endpoints until success.
-             You can set the maximumFailoverAttempt to break out after X 
attempts --&gt;
-        &lt;failover roundRobin=&quot;true&quot;/&gt;
-        &lt;to uri=&quot;direct:bad&quot;/&gt;
-        &lt;to uri=&quot;direct:bad2&quot;/&gt;
-        &lt;to uri=&quot;direct:good&quot;/&gt;
-        &lt;to uri=&quot;direct:good2&quot;/&gt;
-    &lt;/loadBalance&gt;
-&lt;/route&gt;
-]]></script>
-</div></div><div class="confluence-information-macro 
confluence-information-macro-tip"><p class="title">Disabled 
inheritErrorHandler</p><span class="aui-icon aui-icon-small 
aui-iconfont-approve confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>You can configure 
<code>inheritErrorHandler=false</code> if you want to failover to the next 
endpoint as fast as possible. By disabling the <a shape="rect" 
href="error-handler.html">Error Handler</a> you ensure it does not 
<em>intervene</em> which allows the <code>failover</code> load balancer to 
handle failover asap. By also enabling <code>roundRobin</code> mode, then it 
will keep retrying until it success. You can then configure the 
<code>maximumFailoverAttempts</code> option to a high value to let it 
eventually exhaust (give up) and fail.</p></div></div><h3 
id="LoadBalancer-WeightedRound-RobinandRandomLoadBalancing">Weighted 
Round-Robin and Random Load Balancing</h3><p><strong>Available as of Camel 
 2.5</strong></p><p>In many enterprise environments where server nodes of 
unequal processing power &amp; performance characteristics are utilized to host 
services and processing endpoints, it is frequently necessary to distribute 
processing load based on their individual server capabilities so that some 
endpoints are not unfairly burdened with requests. Obviously simple round-robin 
or random load balancing do not alleviate problems of this nature. A Weighted 
Round-Robin and/or Weighted Random load balancer can be used to address this 
problem.</p><p>The weighted load balancing policy allows you to specify a 
processing load distribution ratio for each server with respect to others. You 
can specify this as a positive processing weight for each server. A larger 
number indicates that the server can handle a larger load. The weight is 
utilized to determine the payload distribution ratio to different processing 
endpoints with respect to others.</p><div class="confluence-information-macro co
 nfluence-information-macro-tip"><p class="title">Disabled 
inheritErrorHandler</p><span class="aui-icon aui-icon-small 
aui-iconfont-approve confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>As of Camel 2.6, the Weighted Load 
balancer usage has been further simplified, there is no need to send in 
distributionRatio as a List&lt;Integer&gt;. It can be simply sent as a 
delimited String of integer weights separated by a delimiter of 
choice.</p></div></div><p>The parameters that can be used are</p><p><strong>In 
Camel 2.5</strong></p><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>Type</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>roundRobin</p></td><td c
 olspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The default value for round-robin is false. In the 
absence of this setting or parameter the load balancing algorithm used is 
random.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>distributionRatio</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>List&lt;Integer&gt;</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The distributionRatio is a list consisting on integer 
weights passed in as a parameter. The distributionRatio must match the number 
of endpoints and/or processors specified in the load balancer list. In Camel 
2.5 if endpoints do not match ratios, then a best effort distribution is 
attempted.</p></td></tr></tbody></table></div><p><strong>Available In Camel 
2.6</strong></p><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>Type</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>roundRobin</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The default value for round-robin is false. In the 
absence of this setting or parameter the load balancing algorithm used is 
random.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>distributionRatio</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>String</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><
 p>The distributionRatio is a delimited String consisting on integer weights 
separated by delimiters for example "2,3,5". The distributionRatio must match 
the number of endpoints and/or processors specified in the load balancer 
list.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>distributionRatioDelimiter</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>String</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>,</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The distributionRatioDelimiter is the delimiter used to 
specify the distributionRatio. If this attribute is not specified a default 
delimiter "," is expected as the delimiter used for specifying the 
distributionRatio.</p></td></tr></tbody></table></div><h4 
id="LoadBalancer-UsingWeightedround-robin&amp;randomloadbalancing">Using 
Weighted round-robin &amp; random load balancing</h4><p><strong>In Camel 
2.5</strong></p><p>An example using 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[ArrayList&lt;integer&gt; distributionRatio = 
new ArrayList&lt;integer&gt;();
+</plain-text-body><h4 id="LoadBalancer-Usingfailoverinroundrobinmode">Using 
failover in round robin mode</h4><p>An example using Java 
DSL:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/FailoverRoundRobinTest.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/FailoverRoundRobinTest.xml}</plain-text-body></p><parameter
 ac:name="title">Disabled inheritErrorHandler</parameter><rich-text-body><p>You 
can configure <code>inheritErrorHandler=false</code> if you want to failover to 
the next endpoint as fast as possible. By disabling the <a shape="rect" 
href="error-handler.html">Error Handler</a> you ensure it does not 
<em>intervene</em> which allows the <code>failover</code> load balancer to 
handle failover asap. By also enabling <code>roundRobin</code> mode, then it 
will keep retrying un
 til it success. You can then configure the 
<code>maximumFailoverAttempts</code> option to a high value to let it 
eventually exhaust (give up) and fail.</p></rich-text-body><h3 
id="LoadBalancer-WeightedRound-RobinandRandomLoadBalancing">Weighted 
Round-Robin and Random Load Balancing</h3><p><strong>Available as of Camel 
2.5</strong></p><p>In many enterprise environments where server nodes of 
unequal processing power &amp; performance characteristics are utilized to host 
services and processing endpoints, it is frequently necessary to distribute 
processing load based on their individual server capabilities so that some 
endpoints are not unfairly burdened with requests. Obviously simple round-robin 
or random load balancing do not alleviate problems of this nature. A Weighted 
Round-Robin and/or Weighted Random load balancer can be used to address this 
problem.</p><p>The weighted load balancing policy allows you to specify a 
processing load distribution ratio for each server with respect 
 to others. You can specify this as a positive processing weight for each 
server. A larger number indicates that the server can handle a larger load. The 
weight is utilized to determine the payload distribution ratio to different 
processing endpoints with respect to others.</p><parameter 
ac:name="title">Disabled inheritErrorHandler</parameter><rich-text-body><p>As 
of Camel 2.6, the Weighted Load balancer usage has been further simplified, 
there is no need to send in distributionRatio as a List&lt;Integer&gt;. It can 
be simply sent as a delimited String of integer weights separated by a 
delimiter of choice.</p></rich-text-body><p>The parameters that can be used 
are</p><p><strong>In Camel 2.5</strong></p><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>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rows
 pan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p>roundRobin</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The default value for round-robin is false. In the 
absence of this setting or parameter the load balancing algorithm used is 
random.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>distributionRatio</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>List&lt;Integer&gt;</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The distributionRatio is a list consisting on integer 
weights passed in as a parameter. The distributionRatio must match the number 
of endpoints and/or processors specified in the load balancer list. In Camel 
2.5 if endpoints do not match ratios, then a 
 best effort distribution is 
attempted.</p></td></tr></tbody></table></div><p><strong>Available In Camel 
2.6</strong></p><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>Type</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>roundRobin</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The default value for round-robin is false. In the 
absence of this setting or parameter the load balancing algorithm used is 
random.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>distributionRatio</p></td><td colspan="1" rowspan="1" 
class="confluence
 Td"><p>String</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>none</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The distributionRatio is a delimited String consisting 
on integer weights separated by delimiters for example "2,3,5". The 
distributionRatio must match the number of endpoints and/or processors 
specified in the load balancer list.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p>distributionRatioDelimiter</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>String</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>,</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The distributionRatioDelimiter is the delimiter used to 
specify the distributionRatio. If this attribute is not specified a default 
delimiter "," is expected as the delimiter used for specifying the 
distributionRatio.</p></td></tr></tbody></table></div><h4 
id="LoadBalancer-UsingWeightedround-robin&amp;randomloadbalancing">Using 
Weighted rou
 nd-robin &amp; random load balancing</h4><p><strong>In Camel 
2.5</strong></p><p>An example using Java DSL:</p><parameter 
ac:name="">java</parameter><plain-text-body>ArrayList&lt;integer&gt; 
distributionRatio = new ArrayList&lt;integer&gt;();
 distributionRatio.add(4);
 distributionRatio.add(2);
 distributionRatio.add(1);
 
 // round-robin
-from(&quot;direct:start&quot;)
+from("direct:start")
     .loadBalance().weighted(true, distributionRatio)
-    .to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
+    .to("mock:x", "mock:y", "mock:z");
 
 //random
-from(&quot;direct:start&quot;)
+from("direct:start")
     .loadBalance().weighted(false, distributionRatio)
-    .to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
-]]></script>
-</div></div><p>And the same example using Spring XML:</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;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
+    .to("mock:x", "mock:y", "mock:z");
+</plain-text-body><p>And the same example using Spring XML:</p><parameter 
ac:name="">xml</parameter><plain-text-body>    &lt;route&gt;
+      &lt;from uri="direct:start"/&gt;
       &lt;loadBalance&gt;
-        &lt;weighted roundRobin=&quot;false&quot; distributionRatio=&quot;4 2 
1&quot;/&gt;
-          &lt;to uri=&quot;mock:x&quot;/&gt;
-          &lt;to uri=&quot;mock:y&quot;/&gt;
-          &lt;to uri=&quot;mock:z&quot;/&gt;
+        &lt;weighted roundRobin="false" distributionRatio="4 2 1"/&gt;
+          &lt;to uri="mock:x"/&gt;
+          &lt;to uri="mock:y"/&gt;
+          &lt;to uri="mock:z"/&gt;
       &lt;/loadBalance&gt;
     &lt;/route&gt;
-]]></script>
-</div></div><p><strong>Available In Camel 2.6</strong></p><p>An example using 
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[// round-robin
-from(&quot;direct:start&quot;)
-    .loadBalance().weighted(true, &quot;4:2:1&quot; 
distributionRatioDelimiter=&quot;:&quot;)
-    .to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
+</plain-text-body><p><strong>Available In Camel 2.6</strong></p><p>An example 
using Java DSL:</p><parameter ac:name="">java</parameter><plain-text-body>// 
round-robin
+from("direct:start")
+    .loadBalance().weighted(true, "4:2:1" distributionRatioDelimiter=":")
+    .to("mock:x", "mock:y", "mock:z");
 
 //random
-from(&quot;direct:start&quot;)
-    .loadBalance().weighted(false, &quot;4,2,1&quot;)
-    .to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
-]]></script>
-</div></div><p>And the same example using Spring XML:</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;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
+from("direct:start")
+    .loadBalance().weighted(false, "4,2,1")
+    .to("mock:x", "mock:y", "mock:z");
+</plain-text-body><p>And the same example using Spring XML:</p><parameter 
ac:name="">xml</parameter><plain-text-body>    &lt;route&gt;
+      &lt;from uri="direct:start"/&gt;
       &lt;loadBalance&gt;
-        &lt;weighted roundRobin=&quot;false&quot; 
distributionRatio=&quot;4-2-1&quot; distributionRatioDelimiter=&quot;-&quot; 
/&gt;
-          &lt;to uri=&quot;mock:x&quot;/&gt;
-          &lt;to uri=&quot;mock:y&quot;/&gt;
-          &lt;to uri=&quot;mock:z&quot;/&gt;
+        &lt;weighted roundRobin="false" distributionRatio="4-2-1" 
distributionRatioDelimiter="-" /&gt;
+          &lt;to uri="mock:x"/&gt;
+          &lt;to uri="mock:y"/&gt;
+          &lt;to uri="mock:z"/&gt;
       &lt;/loadBalance&gt;
     &lt;/route&gt;
-]]></script>
-</div></div><h3 id="LoadBalancer-CustomLoadBalancer">Custom Load 
Balancer</h3><p>You can use a custom load balancer (eg your own implementation) 
also.</p><p>An example using 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;)
-    // using our custom load balancer
-    .loadBalance(new MyLoadBalancer())
-    .to(&quot;mock:x&quot;, &quot;mock:y&quot;, &quot;mock:z&quot;);
-]]></script>
-</div></div>And the same example using XML DSL:<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;!-- this is the implementation of our custom load balancer --&gt;
-&lt;bean id=&quot;myBalancer&quot; 
class=&quot;org.apache.camel.processor.CustomLoadBalanceTest$MyLoadBalancer&quot;/&gt;
-
-&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
-  &lt;route&gt;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
-    &lt;loadBalance&gt;
-      &lt;!-- refer to my custom load balancer --&gt;
-      &lt;custom ref=&quot;myBalancer&quot;/&gt;
-      &lt;!-- these are the endpoints to balancer --&gt;
-      &lt;to uri=&quot;mock:x&quot;/&gt;
-      &lt;to uri=&quot;mock:y&quot;/&gt;
-      &lt;to uri=&quot;mock:z&quot;/&gt;
-    &lt;/loadBalance&gt;
-  &lt;/route&gt;
-&lt;/camelContext&gt;
-]]></script>
-</div></div>Notice in the XML DSL above we use &lt;custom&gt; which is only 
available in <strong>Camel 2.8</strong> onwards. In older releases you would 
have to do as follows instead:<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;loadBalance 
ref=&quot;myBalancer&quot;&gt;
+</plain-text-body><h3 id="LoadBalancer-CustomLoadBalancer">Custom Load 
Balancer</h3><p>You can use a custom load balancer (eg your own implementation) 
also.</p><p>An example using Java 
DSL:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/CustomLoadBalanceTest.java}</plain-text-body>And
 the same example using XML 
DSL:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringCustomRefLoadBalanceTest.xml}</plain-text-body>Notice
 in the XML DSL above we use &lt;custom&gt; which is only available in 
<strong>Camel 2.8</strong> onwards. In older releases you would have to do as 
follows instead:</p><parameter ac:name="">xml</parameter><plain-text-body>      
&lt;loadBalance ref="myBalancer"&gt;
         &lt;!-- these are the endpoints to balancer --&gt;
-        &lt;to uri=&quot;mock:x&quot;/&gt;
-        &lt;to uri=&quot;mock:y&quot;/&gt;
-        &lt;to uri=&quot;mock:z&quot;/&gt;
+        &lt;to uri="mock:x"/&gt;
+        &lt;to uri="mock:y"/&gt;
+        &lt;to uri="mock:z"/&gt;
       &lt;/loadBalance&gt;
-]]></script>
-</div></div><p>To implement a custom load balancer you can extend some support 
classes such as <code>LoadBalancerSupport</code> and 
<code>SimpleLoadBalancerSupport</code>. The former supports the asynchronous 
routing engine, and the latter does not. Here is an example:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Custom load balancer 
implementation</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-public static class MyLoadBalancer extends LoadBalancerSupport {
-
-    public boolean process(Exchange exchange, AsyncCallback callback) {
-        String body = exchange.getIn().getBody(String.class);
-        try {
-            if (&quot;x&quot;.equals(body)) {
-                getProcessors().get(0).process(exchange);
-            } else if (&quot;y&quot;.equals(body)) {
-                getProcessors().get(1).process(exchange);
-            } else {
-                getProcessors().get(2).process(exchange);
-            }
-        } catch (Throwable e) {
-            exchange.setException(e);
-        }
-        callback.done(true);
-        return true;
-    }
-}
-]]></script>
-</div></div><h3 id="LoadBalancer-CircuitBreaker">Circuit Breaker</h3><p>The 
Circuit Breaker load balancer is a stateful pattern that monitors all calls for 
certain exceptions. Initially the Circuit Breaker is in closed state and passes 
all messages. If there are failures and the threshold is reached, it moves to 
open state and rejects all calls until halfOpenAfter timeout is reached. After 
this timeout is reached, if there is a new call, it will pass and if the result 
is success the Circuit Breaker will move to closed state, or to open state if 
there was an error.</p><p>When the circuit breaker is closed, it will throw a 
<code>java.util.concurrent.RejectedExecutionException</code>. This can then be 
caught to provide an alternate path for processing exchanges.</p><p>An example 
using 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;)
+</plain-text-body><p>To implement a custom load balancer you can extend some 
support classes such as <code>LoadBalancerSupport</code> and 
<code>SimpleLoadBalancerSupport</code>. The former supports the asynchronous 
routing engine, and the latter does not. Here is an 
example:<plain-text-body>{snippet:id=e2|title=Custom load balancer 
implementation|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/CustomLoadBalanceTest.java}</plain-text-body></p><h3
 id="LoadBalancer-CircuitBreaker">Circuit Breaker</h3><p>The Circuit Breaker 
load balancer is a stateful pattern that monitors all calls for certain 
exceptions. Initially the Circuit Breaker is in closed state and passes all 
messages. If there are failures and the threshold is reached, it moves to open 
state and rejects all calls until halfOpenAfter timeout is reached. After this 
timeout is reached, if there is a new call, it will pass and if the result is 
success the Circuit Breaker will move to closed state, or
  to open state if there was an error.</p><p>When the circuit breaker is 
closed, it will throw a 
<code>java.util.concurrent.RejectedExecutionException</code>. This can then be 
caught to provide an alternate path for processing exchanges.</p><p>An example 
using Java DSL:</p><parameter 
ac:name="">java</parameter><plain-text-body>from("direct:start")
     .onException(RejectedExecutionException.class)
         .handled(true)
-        .to(&quot;mock:serviceUnavailable&quot;)
+        .to("mock:serviceUnavailable")
     .end()
-    .loadBalance()
+   &#160;.loadBalance()
         .circuitBreaker(2, 1000L, MyCustomException.class)
-        .to(&quot;mock:service&quot;)
+        .to("mock:service")
     .end();
-]]></script>
-</div></div><p>And the same example using Spring XML:</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 id=&quot;camel&quot; 
xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
+</plain-text-body><p>And the same example using Spring XML:</p><parameter 
ac:name="language">xml</parameter><plain-text-body>&lt;camelContext id="camel" 
xmlns="http://camel.apache.org/schema/spring"&gt;
        &lt;route&gt;
-        &lt;from uri=&quot;direct:start&quot;/&gt;
+        &lt;from uri="direct:start"/&gt;
         &lt;onException&gt;
             
&lt;exception&gt;java.util.concurrent.RejectedExecutionException&lt;/exception&gt;
             
&lt;handled&gt;&lt;constant&gt;true&lt;/constant&gt;&lt;/handled&gt;
-            &lt;to uri=&quot;mock:serviceUnavailable&quot;/&gt;
+            &lt;to uri="mock:serviceUnavailable"/&gt;
         &lt;/onException&gt;
-        &lt;loadBalance&gt;
-            &lt;circuitBreaker threshold=&quot;2&quot; 
halfOpenAfter=&quot;1000&quot;&gt;
+       &#160;&lt;loadBalance&gt;
+            &lt;circuitBreaker threshold="2" halfOpenAfter="1000"&gt;
                 &lt;exception&gt;MyCustomException&lt;/exception&gt;
             &lt;/circuitBreaker&gt;
-            &lt;to uri=&quot;mock:service&quot;/&gt;
+            &lt;to uri="mock:service"/&gt;
         &lt;/loadBalance&gt;
     &lt;/route&gt;
 &lt;/camelContext&gt;
-]]></script>
-</div></div><p></p><h4 id="LoadBalancer-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>
+</plain-text-body><p><parameter ac:name=""><a shape="rect" 
href="using-this-pattern.html">Using This Pattern</a></parameter></p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/loop.html
==============================================================================
--- websites/production/camel/content/loop.html (original)
+++ websites/production/camel/content/loop.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Loop
@@ -86,102 +75,24 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="Loop-Loop">Loop</h2><p>The Loop 
allows for processing a message a number of times, possibly in a different way 
for each iteration. Useful mostly during testing.</p><div 
class="confluence-information-macro 
confluence-information-macro-information"><p class="title">Default 
mode</p><span class="aui-icon aui-icon-small aui-iconfont-info 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>Notice by default the loop uses 
the same exchange throughout the looping. So the result from the previous 
iteration will be used for the next (eg <a shape="rect" 
href="pipes-and-filters.html">Pipes and Filters</a>). From <strong>Camel 
2.8</strong> onwards you can enable copy mode instead. See the options table 
for more details.</p></div></div><h3 id="Loop-Options">Options</h3><div 
class="confluenceTableSmall">&#160;</div>
-
-
-<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>copy</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> 
Whether or not copy mode is used. If <code>false</code> then the same Exchange 
will be used for each iteration. So the result from the previous iteration will 
be <em>visible</em> for the next iteration. Instead you can enable copy mode, 
and then each iteration <em>restarts</em> with a fresh copy of the input <a 
shape="rect" href="exchange.html">Exchange</a>.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd">doWhile</td><td colspan="1" 
rowspan="1" class="
 confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.17:</strong> Enables the while loop that 
loops until the predicate evaluates to false or 
null.</td></tr></tbody></table></div><h3 id="Loop-Exchangeproperties">Exchange 
properties</h3><p>For each iteration two properties are set on the 
<code>Exchange</code>. Processors can rely on these properties to process the 
<a shape="rect" href="message.html">Message</a> in different ways.</p><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Property</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>CamelLoopSize</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Total number of loops. This is not 
available if running the loop in while loop mode.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelLoop
 Index</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Index 
of the current iteration (0 based)</p></td></tr></tbody></table></div><h4 
id="Loop-Examples">Examples</h4><p>The following example shows how to take a 
request from the <strong>direct:x</strong> endpoint, then send the message 
repetitively to <strong>mock:result</strong>. The number of times the message 
is sent is either passed as an argument to <code>loop()</code>, or determined 
at runtime by evaluating an expression. The expression <strong>must</strong> 
evaluate to an <code>int</code>, otherwise a <code>RuntimeCamelException</code> 
is thrown.</p><p><strong>Using the <a shape="rect" 
href="fluent-builders.html">Fluent Builders</a></strong></p><p>Pass loop count 
as an argument</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:a&quot;).loop(8).to(&quot;mock:result&quot;);
-]]></script>
-</div></div>Use expression to determine loop count<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:b&quot;).loop(header(&quot;loop&quot;)).to(&quot;mock:result&quot;);
-]]></script>
-</div></div>Use expression to determine loop count<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:c&quot;).loop().xpath(&quot;/hello/@times&quot;).to(&quot;mock:result&quot;);
-]]></script>
-</div></div><strong>Using the <a shape="rect" 
href="spring-xml-extensions.html">Spring XML Extensions</a></strong><p>Pass 
loop count as an argument</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;
-  &lt;from uri=&quot;direct:a&quot;/&gt;
-  &lt;loop&gt;
-    &lt;constant&gt;8&lt;/constant&gt;
-    &lt;to uri=&quot;mock:result&quot;/&gt;
-  &lt;/loop&gt;
-&lt;/route&gt;
-]]></script>
-</div></div>Use expression to determine loop count<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;
-  &lt;from uri=&quot;direct:b&quot;/&gt;
-  &lt;loop&gt;
-    &lt;header&gt;loop&lt;/header&gt;
-    &lt;to uri=&quot;mock:result&quot;/&gt;
-  &lt;/loop&gt;
-&lt;/route&gt;
-]]></script>
-</div></div>For further examples of this pattern in use you could look at one 
of the <a shape="rect" class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopTest.java?view=markup";>junit
 test case</a><h4 id="Loop-Usingcopymode">Using copy 
mode</h4><p><strong>Available as of Camel 2.8</strong></p><p>Now suppose we 
send a message to "direct:start" endpoint containing the letter A.<br 
clear="none"> The output of processing this route will be that, each 
"mock:loop" endpoint will receive "AB" as message.</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;)
-    // instruct loop to use copy mode, which mean it will use a copy of the 
input exchange
-    // for each loop iteration, instead of keep using the same exchange all 
over
-    .loop(3).copy()
-        .transform(body().append(&quot;B&quot;))
-        .to(&quot;mock:loop&quot;)
-    .end()
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>However if we do <strong>not</strong> enable copy mode then 
"mock:loop" will receive "AB", "ABB", "ABBB", etc. messages.<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;)
-    // by default loop will keep using the same exchange so on the 2nd and 3rd 
iteration its
-    // the same exchange that was previous used that are being looped all over
-    .loop(3)
-        .transform(body().append(&quot;B&quot;))
-        .to(&quot;mock:loop&quot;)
+<div class="wiki-content maincontent"><h2 id="Loop-Loop">Loop</h2><p>The Loop 
allows for processing a message a number of times, possibly in a different way 
for each iteration. Useful mostly during testing.</p><parameter 
ac:name="title">Default mode</parameter><rich-text-body><p>Notice by default 
the loop uses the same exchange throughout the looping. So the result from the 
previous iteration will be used for the next (eg <a shape="rect" 
href="pipes-and-filters.html">Pipes and Filters</a>). From <strong>Camel 
2.8</strong> onwards you can enable copy mode instead. See the options table 
for more details.</p></rich-text-body><h3 
id="Loop-Options">Options</h3><parameter 
ac:name="class">confluenceTableSmall</parameter><rich-text-body>&#160;</rich-text-body><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" cl
 ass="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>copy</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.8:</strong> Whether or not copy mode is 
used. If <code>false</code> then the same Exchange will be used for each 
iteration. So the result from the previous iteration will be <em>visible</em> 
for the next iteration. Instead you can enable copy mode, and then each 
iteration <em>restarts</em> with a fresh copy of the input <a shape="rect" 
href="exchange.html">Exchange</a>.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd">doWhile</td><td colspan="1" rowspan="1" 
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.17:</strong> Enables the while loop that 
loops until the predicate evaluates to false or 
null.</td></tr></tbody></table></div><h3 id="Loop-Exchan
 geproperties">Exchange properties</h3><p>For each iteration two properties are 
set on the <code>Exchange</code>. Processors can rely on these properties to 
process the <a shape="rect" href="message.html">Message</a> in different 
ways.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th 
colspan="1" rowspan="1" class="confluenceTh"><p>Property</p></th><th 
colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>CamelLoopSize</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Total number of loops. This is 
not available if running the loop in while loop mode.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>CamelLoopIndex</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Index of the current iteration (0 
based)</p></td></tr></tbody></table></div><h4 
id="Loop-Examples">Examples</h4><p>The following example shows how to take a 
reque
 st from the <strong>direct:x</strong> endpoint, then send the message 
repetitively to <strong>mock:result</strong>. The number of times the message 
is sent is either passed as an argument to <code>loop()</code>, or determined 
at runtime by evaluating an expression. The expression <strong>must</strong> 
evaluate to an <code>int</code>, otherwise a <code>RuntimeCamelException</code> 
is thrown.</p><p><strong>Using the <a shape="rect" 
href="fluent-builders.html">Fluent Builders</a></strong></p><p>Pass loop count 
as an 
argument<plain-text-body>{snippet:id=ex1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopTest.java}</plain-text-body>Use
 expression to determine loop 
count<plain-text-body>{snippet:id=ex2|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopTest.java}</plain-text-body>Use
 expression to determine loop 
count<plain-text-body>{snippet:id=ex3|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/process
 or/LoopTest.java}</plain-text-body><strong>Using the <a shape="rect" 
href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><p>Pass 
loop count as an 
argument<plain-text-body>{snippet:id=ex1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/loop.xml}</plain-text-body>Use
 expression to determine loop 
count<plain-text-body>{snippet:id=ex2|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/loop.xml}</plain-text-body>For
 further examples of this pattern in use you could look at one of the <a 
shape="rect" class="external-link" 
href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopTest.java?view=markup";>junit
 test case</a></p><h4 id="Loop-Usingcopymode">Using copy 
mode</h4><p><strong>Available as of Camel 2.8</strong></p><p>Now suppose we 
send a message to "direct:start" endpoint containing the letter A.<br 
clear="none"> Th
 e output of processing this route will be that, each "mock:loop" endpoint will 
receive "AB" as 
message.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopCopyTest.java}</plain-text-body>However
 if we do <strong>not</strong> enable copy mode then "mock:loop" will receive 
"AB", "ABB", "ABBB", etc. 
messages.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/LoopNoCopyTest.java}</plain-text-body>The
 equivalent example in XML DSL in copy mode is as 
follows:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringLoopCopyTest.xml}</plain-text-body></p><h4
 id="Loop-Usingwhilemode">Using while mode</h4><p><strong>Available as of Camel 
2.17</strong></p><p>The loop can act like a while loop that loops until the 
expression evaluates to false or null.</p><p>For example the route below loops 
wh
 ile the length of the message body is 5 or less characters. Notice that the 
DSL 
uses&#160;<strong>loopDoWhile</strong>.</p><plain-text-body>from("direct:start")
+    .loopDoWhile(simple("${body.length} &lt;= 5"))
+        .to("mock:loop")
+        .transform(body().append("A"))
     .end()
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>The equivalent example in XML DSL in copy mode is as follows:<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;
-  &lt;from uri=&quot;direct:start&quot;/&gt;
-  &lt;!-- enable copy mode for loop eip --&gt;
-  &lt;loop copy=&quot;true&quot;&gt;
-    &lt;constant&gt;3&lt;/constant&gt;
-    &lt;transform&gt;
-      &lt;simple&gt;${body}B&lt;/simple&gt;
-    &lt;/transform&gt;
-    &lt;to uri=&quot;mock:loop&quot;/&gt;
-  &lt;/loop&gt;
-  &lt;to uri=&quot;mock:result&quot;/&gt;
-&lt;/route&gt;
-]]></script>
-</div></div><h4 id="Loop-Usingwhilemode">Using while 
mode</h4><p><strong>Available as of Camel 2.17</strong></p><p>The loop can act 
like a while loop that loops until the expression evaluates to false or 
null.</p><p>For example the route below loops while the length of the message 
body is 5 or less characters. Notice that the DSL 
uses&#160;<strong>loopDoWhile</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;)
-    .loopDoWhile(simple(&quot;${body.length} &lt;= 5&quot;))
-        .to(&quot;mock:loop&quot;)
-        .transform(body().append(&quot;A&quot;))
-    .end()
-    .to(&quot;mock:result&quot;);]]></script>
-</div></div><p>And the same example in XML:</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;
-      &lt;from uri=&quot;direct:start&quot;/&gt;
-      &lt;loop doWhile=&quot;true&quot;&gt;
+    .to("mock:result");</plain-text-body><p>And the same example in 
XML:</p><parameter ac:name="">xml</parameter><plain-text-body>    &lt;route&gt;
+      &lt;from uri="direct:start"/&gt;
+      &lt;loop doWhile="true"&gt;
         &lt;simple&gt;${body.length} &amp;lt;= 5&lt;/simple&gt;
-        &lt;to uri=&quot;mock:loop&quot;/&gt;
+        &lt;to uri="mock:loop"/&gt;
         &lt;transform&gt;
           &lt;simple&gt;A${body}&lt;/simple&gt;
         &lt;/transform&gt;
       &lt;/loop&gt;
-      &lt;to uri=&quot;mock:result&quot;/&gt;
+      &lt;to uri="mock:result"/&gt;
     &lt;/route&gt;
 
-]]></script>
-</div></div><p>Notice in XML that the while loop is turned on using the 
<strong>doWhile</strong> attribute.</p><p>&#160;</p><p></p><h4 
id="Loop-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>
+</plain-text-body><p>Notice in XML that the while loop is turned on using the 
<strong>doWhile</strong> attribute.</p><p>&#160;</p><p><parameter ac:name=""><a 
shape="rect" href="using-this-pattern.html">Using This 
Pattern</a></parameter></p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/normalizer.html
==============================================================================
--- websites/production/camel/content/normalizer.html (original)
+++ websites/production/camel/content/normalizer.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' 
rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' 
rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' 
type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' 
type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: Normalizer
@@ -97,73 +86,24 @@
 <p>This example shows a Message Normalizer that converts two types of XML 
messages into a common format. Messages in this common format are then 
filtered.</p>
 
 <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[
-// we need to normalize two types of incoming messages
-from(&quot;direct:start&quot;)
-    .choice()
-        
.when().xpath(&quot;/employee&quot;).to(&quot;bean:normalizer?method=employeeToPerson&quot;)
-        
.when().xpath(&quot;/customer&quot;).to(&quot;bean:normalizer?method=customerToPerson&quot;)
-    .end()
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=example|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/NormalizerTest.java}</plain-text-body>
 
 <p>In this case we're using a Java bean as the normalizer. The class looks 
like this</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[
-public class MyNormalizer {
-    public void employeeToPerson(Exchange exchange, 
@XPath(&quot;/employee/name/text()&quot;) String name) {
-        exchange.getOut().setBody(createPerson(name));            
-    }
-
-    public void customerToPerson(Exchange exchange, 
@XPath(&quot;/customer/@name&quot;) String name) {
-        exchange.getOut().setBody(createPerson(name));
-    }        
-    
-    private String createPerson(String name) {
-        return &quot;&lt;person name=\&quot;&quot; + name + 
&quot;\&quot;/&gt;&quot;;
-    }
-}    
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=example|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MyNormalizer.java}</plain-text-body>
 
 <p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring 
XML Extensions</a></strong></p>
 
 <p>The same example in the Spring DSL</p>
 
-<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-&lt;camelContext xmlns=&quot;http://camel.apache.org/schema/spring&quot;&gt;
-  &lt;route&gt;
-    &lt;from uri=&quot;direct:start&quot;/&gt;
-    &lt;choice&gt;
-      &lt;when&gt;
-        &lt;xpath&gt;/employee&lt;/xpath&gt;
-        &lt;to uri=&quot;bean:normalizer?method=employeeToPerson&quot;/&gt;
-      &lt;/when&gt;
-      &lt;when&gt;
-        &lt;xpath&gt;/customer&lt;/xpath&gt;
-        &lt;to uri=&quot;bean:normalizer?method=customerToPerson&quot;/&gt;
-      &lt;/when&gt;
-    &lt;/choice&gt;
-    &lt;to uri=&quot;mock:result&quot;/&gt;
-  &lt;/route&gt; 
-&lt;/camelContext&gt;
-
-&lt;bean id=&quot;normalizer&quot; 
class=&quot;org.apache.camel.processor.MyNormalizer&quot;/&gt;
-]]></script>
-</div></div>
+<plain-text-body>{snippet:id=example|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/normalizer.xml}</plain-text-body>
 
 <h4 id="Normalizer-SeeAlso">See Also</h4>
 
 <ul><li><a shape="rect" href="message-router.html">Message 
Router</a></li><li><a shape="rect" href="content-based-router.html">Content 
Based Router</a></li><li><a shape="rect" href="message-translator.html">Message 
Translator</a></li></ul>
 
 
-<h4 id="Normalizer-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>
+<parameter ac:name=""><a shape="rect" href="using-this-pattern.html">Using 
This Pattern</a></parameter></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to