Modified: websites/production/camel/content/polling-consumer.html
==============================================================================
--- websites/production/camel/content/polling-consumer.html (original)
+++ websites/production/camel/content/polling-consumer.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: Polling Consumer
@@ -86,136 +75,18 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h3 
id="PollingConsumer-PollingConsumer">Polling Consumer</h3><p>Camel supports 
implementing the <a shape="rect" class="external-link" 
href="http://www.enterpriseintegrationpatterns.com/PollingConsumer.html"; 
rel="nofollow">Polling Consumer</a> from the <a shape="rect" 
href="enterprise-integration-patterns.html">EIP patterns</a> using the <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html";>PollingConsumer</a>
 interface which can be created via the <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html#createPollingConsumer()">Endpoint.createPollingConsumer()</a>
 method.</p><p><span class="confluence-embedded-file-wrapper"><img 
class="confluence-embedded-image confluence-external-resource" 
src="http://www.enterpriseintegrationpatterns.com/img/PollingConsumerSolution.gif";
 data-image-src
 
="http://www.enterpriseintegrationpatterns.com/img/PollingConsumerSolution.gif";></span></p><p>In
 Java:</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[Endpoint endpoint = 
context.getEndpoint(&quot;activemq:my.queue&quot;);
+<div class="wiki-content maincontent"><h3 
id="PollingConsumer-PollingConsumer">Polling Consumer</h3><p>Camel supports 
implementing the <a shape="rect" class="external-link" 
href="http://www.enterpriseintegrationpatterns.com/PollingConsumer.html"; 
rel="nofollow">Polling Consumer</a> from the <a shape="rect" 
href="enterprise-integration-patterns.html">EIP patterns</a> using the <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html";>PollingConsumer</a>
 interface which can be created via the <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Endpoint.html#createPollingConsumer()">Endpoint.createPollingConsumer()</a>
 method.</p><p><span class="confluence-embedded-file-wrapper"><img 
class="confluence-embedded-image confluence-external-resource" 
src="http://www.enterpriseintegrationpatterns.com/img/PollingConsumerSolution.gif";
 data-image-src
 
="http://www.enterpriseintegrationpatterns.com/img/PollingConsumerSolution.gif";></span></p><p>In
 Java:</p><parameter 
ac:name="language">java</parameter><plain-text-body>Endpoint endpoint = 
context.getEndpoint("activemq:my.queue");
 PollingConsumer consumer = endpoint.createPollingConsumer();
 Exchange exchange = consumer.receive();
-]]></script>
-</div></div><p>The <strong><code>ConsumerTemplate</code></strong> (discussed 
below) is also available.</p><p>There are three main polling methods on <a 
shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html";>PollingConsumer</a></p><div
 class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Method name</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/PollingConsumer.html#receive()">receive()</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Waits until a message is 
available and then returns it; potentially blocking 
forever</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/PollingConsumer.html#receive(long)">receive(long)</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Attempts to receive a message 
exchange, waiting up to the given timeout and returning null if no message 
exchange could be received within the time available</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/PollingConsumer.html#receiveNoWait()">receiveNoWait()</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Attempts to receive a message 
exchange immediately without waiting and returning null if a message exchange 
is not available yet</p></td></tr></tbody></table></div><h3 
id="PollingConsumer-EventDrivenPollingConsumerOptions">EventDrivenPollingConsumer
 
Options</h3><p>The&#160;<strong><code>EventDrivePollingConsumer</code></strong> 
(the def
 ault implementation) supports the following options:</p><div 
class="confluenceTableSmall"><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>pollingConsumerQueueSize</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 
2.14/2.13.1/2.12.4:</strong> The queue size for the internal hand-off queue 
between the polling consumer, and producers sending data into the 
queue.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>pollingConsumerBlockWhenFull</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td 
colspan="1" rowspan="1" class="co
 nfluenceTd"><p><strong>Camel 2.14/2.13.1/2.12/4:</strong> Whether to block any 
producer if the internal queue is full.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><span><code>pollingConsumerBlockTimeout</code></span></td><td
 colspan="1" rowspan="1" class="confluenceTd">0</td><td colspan="1" rowspan="1" 
class="confluenceTd"><strong>Camel 2.16:</strong> To use a timeout (in 
milliseconds) when the producer is blocked if the internal queue is full. If 
the value is&#160;<strong><code>0</code></strong> or negative then no timeout 
is in use. If a timeout is triggered then 
a&#160;<strong><code>ExchangeTimedOutException</code></strong> is 
thrown.</td></tr></tbody></table></div></div>
-
-
-<p>Notice that some Camel&#160;<a shape="rect" 
href="components.html">Components</a>&#160;has their own implementation 
of&#160;<strong><code>PollingConsumer</code></strong> and therefore do not 
support the options above.</p><p>You can configure these options in 
endpoints&#160;<a shape="rect" href="uris.html">URIs</a>, such as shown 
below:</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[Endpoint endpoint = 
context.getEndpoint(&quot;file:inbox?pollingConsumerQueueSize=50&quot;);
+</plain-text-body><p>The <strong><code>ConsumerTemplate</code></strong> 
(discussed below) is also available.</p><p>There are three main polling methods 
on <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html";>PollingConsumer</a></p><div
 class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Method name</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/PollingConsumer.html#receive()">receive()</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Waits until a message is 
available and then returns it; potentially blocking 
forever</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
shape="rect" class="externa
 l-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html#receive(long)">receive(long)</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Attempts to receive a message 
exchange, waiting up to the given timeout and returning null if no message 
exchange could be received within the time available</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/PollingConsumer.html#receiveNoWait()">receiveNoWait()</a></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p>Attempts to receive a message 
exchange immediately without waiting and returning null if a message exchange 
is not available yet</p></td></tr></tbody></table></div><h3 
id="PollingConsumer-EventDrivenPollingConsumerOptions">EventDrivenPollingConsumer
 
Options</h3><p>The&#160;<strong><code>EventDrivePollingConsumer</code></strong> 
(t
 he default implementation) supports the following options:</p><parameter 
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>pollingConsumerQueueSize</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 
2.14/2.13.1/2.12.4:</strong> The queue size for the internal hand-off queue 
between the polling consumer, and producers sending data into the 
queue.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>pollingConsumerBlockWhenFull</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code
 ></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 
 >2.14/2.13.1/2.12/4:</strong> Whether to block any producer if the internal 
 >queue is full.</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><span><code>pollingConsumerBlockTimeout</code></span></td><td
 > colspan="1" rowspan="1" class="confluenceTd">0</td><td colspan="1" 
 >rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong> To use a 
 >timeout (in milliseconds) when the producer is blocked if the internal queue 
 >is full. If the value is&#160;<strong><code>0</code></strong> or negative 
 >then no timeout is in use. If a timeout is triggered then 
 >a&#160;<strong><code>ExchangeTimedOutException</code></strong> is 
 >thrown.</td></tr></tbody></table></div></rich-text-body><p>Notice that some 
 >Camel&#160;<a shape="rect" href="components.html">Components</a>&#160;has 
 >their own implementation 
 >of&#160;<strong><code>PollingConsumer</code></strong> and therefore do not 
 >support the options above.</p><p>You can
  configure these options in endpoints&#160;<a shape="rect" 
href="uris.html">URIs</a>, such as shown below:</p><parameter 
ac:name="language">java</parameter><plain-text-body>Endpoint endpoint = 
context.getEndpoint("file:inbox?pollingConsumerQueueSize=50");
 PollingConsumer consumer = endpoint.createPollingConsumer();
-Exchange exchange = consumer.receive(5000);]]></script>
-</div></div><h3 
id="PollingConsumer-ConsumerTemplate">ConsumerTemplate</h3><p>The 
<strong><code>ConsumerTemplate</code></strong> is a template much like 
Spring's&#160;<strong><code>JmsTemplate</code></strong> 
or&#160;<strong><code>JdbcTemplate</code></strong> supporting the <a 
shape="rect" href="polling-consumer.html">Polling Consumer</a> EIP. With the 
template you can consume <a shape="rect" href="exchange.html">Exchange</a>s 
from an <a shape="rect" href="endpoint.html">Endpoint</a>. The template 
supports the three operations listed above. However, it also includes 
convenient methods for returning the body, etc 
<strong><code>consumeBody</code></strong>.</p><p>Example:</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[Exchange exchange = 
consumerTemplate.receive(&quot;activemq:my.queue&quot;);
-]]></script>
-</div></div><p>Or to extract and get the body you can do:</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[Object body = 
consumerTemplate.receiveBody(&quot;activemq:my.queue&quot;);
-]]></script>
-</div></div><p>And you can provide the body type as a parameter and have it 
returned as the type:</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[String body = 
consumerTemplate.receiveBody(&quot;activemq:my.queue&quot;, String.class);
-]]></script>
-</div></div><p>You get hold of a 
<strong><code>ConsumerTemplate</code></strong> from the 
<strong><code>CamelContext</code></strong> with the 
<strong><code>createConsumerTemplate</code></strong> operation:</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[ConsumerTemplate consumer = 
context.createConsumerTemplate();
-]]></script>
-</div></div><h4 id="PollingConsumer-UsingConsumerTemplatewithSpringDSL">Using 
ConsumerTemplate with Spring DSL</h4><p>With the Spring DSL we can declare the 
consumer in the&#160;<strong><code>CamelContext</code></strong> with the 
<strong><code>consumerTemplate</code></strong> tag, just like the 
<strong><code>ProducerTemplate</code></strong>. The example below illustrates 
this:</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;!-- define a producer template --&gt;
-  &lt;template id=&quot;producer&quot;/&gt;
-  &lt;!-- define a consumer template --&gt;
-  &lt;consumerTemplate id=&quot;consumer&quot;/&gt;
-  &lt;!-- define endpoint --&gt;
-  &lt;endpoint id=&quot;result&quot; uri=&quot;mock:result&quot;/&gt;
-
-  &lt;route&gt;
-    &lt;from uri=&quot;seda:foo&quot;/&gt;
-    &lt;to uri=&quot;ref:result&quot;/&gt;
-  &lt;/route&gt;
-&lt;/camelContext&gt;
-]]></script>
-</div></div>Then we can get leverage Spring to inject the 
<strong><code>ConsumerTemplate</code></strong> in our java class. The code 
below is part of an unit test but it shows how the consumer and producer can 
work together.<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[
-@ContextConfiguration
-public class SpringConsumerTemplateTest extends SpringRunWithTestSupport {
-
-    @Autowired
-    private ProducerTemplate producer;
-
-    @Autowired
-    private ConsumerTemplate consumer;
-
-    @EndpointInject(ref = &quot;result&quot;)
-    private MockEndpoint mock;
-
-    @Test
-    public void testConsumeTemplate() throws Exception {
-        // we expect Hello World received in our mock endpoint
-        mock.expectedBodiesReceived(&quot;Hello World&quot;);
-
-        // we use the producer template to send a message to the seda:start 
endpoint
-        producer.sendBody(&quot;seda:start&quot;, &quot;Hello World&quot;);
-
-        // we consume the body from seda:start
-        String body = consumer.receiveBody(&quot;seda:start&quot;, 
String.class);
-        assertEquals(&quot;Hello World&quot;, body);
-
-        // and then we send the body again to seda:foo so it will be routed to 
the mock
-        // endpoint so our unit test can complete
-        producer.sendBody(&quot;seda:foo&quot;, body);
-
-        // assert mock received the body
-        mock.assertIsSatisfied();
-    }
-
-}
-]]></script>
-</div></div><h4 id="PollingConsumer-TimerBasedPollingConsumer">Timer Based 
Polling Consumer</h4><p>In this sample we use a <a shape="rect" 
href="timer.html">Timer</a> to schedule a route to be started every 5th second 
and invoke our bean&#160;<strong><code>MyCoolBean</code></strong> where we 
implement the business logic for the <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a>. Here we want to consume all 
messages from a JMS queue, process the message and send them to the next 
queue.</p><p>First we setup our route as:</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[
-MyCoolBean cool = new MyCoolBean();
-cool.setProducer(template);
-cool.setConsumer(consumer);
-
-from(&quot;timer://foo?period=5000&quot;).bean(cool, 
&quot;someBusinessLogic&quot;);
-
-from(&quot;activemq:queue.foo&quot;).to(&quot;mock:result&quot;);
-]]></script>
-</div></div>And then we have out logic in our bean:<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 static class MyCoolBean {
-
-    private int count;
-    private ConsumerTemplate consumer;
-    private ProducerTemplate producer;
-
-    public void setConsumer(ConsumerTemplate consumer) {
-        this.consumer = consumer;
-    }
-
-    public void setProducer(ProducerTemplate producer) {
-        this.producer = producer;
-    }
-
-    public void someBusinessLogic() {
-        // loop to empty queue
-        while (true) {
-            // receive the message from the queue, wait at most 3 sec
-            String msg = 
consumer.receiveBody(&quot;activemq:queue.inbox&quot;, 3000, String.class);
-            if (msg == null) {
-                // no more messages in queue
-                break;
-            }
-
-            // do something with body
-            msg = &quot;Hello &quot; + msg;
-
-            // send it to the next queue
-            producer.sendBodyAndHeader(&quot;activemq:queue.foo&quot;, msg, 
&quot;number&quot;, count++);
-        }
-    }
-}
-]]></script>
-</div></div><h3 id="PollingConsumer-ScheduledPollComponents">Scheduled Poll 
Components</h3><p>Quite a few inbound Camel endpoints use a scheduled poll 
pattern to receive messages and push them through the Camel processing routes. 
That is to say externally from the client the endpoint appears to use an <a 
shape="rect" href="event-driven-consumer.html">Event Driven Consumer</a> but 
internally a scheduled poll is used to monitor some kind of state or resource 
and then fire message exchanges.</p><p>Since this a such a common pattern, 
polling components can extend the <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a>
 base class which makes it simpler to implement this pattern. There is also the 
<a shape="rect" href="quartz.html">Quartz Component</a> which provides 
scheduled delivery of messages using the Quartz enterprise scheduler.</p><p>For 
more details see:</p
 ><ul><li><a shape="rect" class="external-link" 
 >href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/PollingConsumer.html";>PollingConsumer</a></li><li>Scheduled
 > Polling Components<ul><li><a shape="rect" class="external-link" 
 >href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a></li><li><a
 > shape="rect" href="scheduler.html">Scheduler</a></li><li><a shape="rect" 
 >href="atom.html">Atom</a></li><li><a shape="rect" 
 >href="beanstalk.html">Beanstalk</a></li><li><a shape="rect" 
 >href="file2.html">File</a></li><li><a shape="rect" 
 >href="ftp2.html">FTP</a></li><li><a shape="rect" 
 >href="hbase.html">hbase</a></li><li><a shape="rect" 
 >href="ibatis.html">iBATIS</a></li><li><a shape="rect" 
 >href="jpa.html">JPA</a></li><li><a shape="rect" 
 >href="mail.html">Mail</a></li><li><a shape="rect" 
 >href="mybatis.html">MyBatis</a></li><li><a shape="rect" 
 >href="quartz.html">Quartz</a></li><li><a shape="rect"
  href="snmp.html">SNMP</a></li><li><a shape="rect" 
href="aws-s3.html">AWS-S3</a></li><li><a shape="rect" 
href="aws-sqs.html">AWS-SQS</a></li></ul></li></ul><h3 
id="PollingConsumer-ScheduledPollConsumerOptions">ScheduledPollConsumer 
Options</h3><p>The&#160;<strong><code>ScheduledPollConsumer</code></strong> 
supports the following options:</p><div class="confluenceTableSmall"><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>backoffErrorThreshold</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> 
The number of subsequent error polls (failed due some error) that should happen 
before 
 the <strong><code>backoffMultipler</code></strong> should 
kick-in.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>backoffIdleThreshold</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> 
The number of subsequent idle polls that should happen before the 
<strong><code>backoffMultipler</code></strong> should 
kick-in.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>backoffMultiplier</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To let the 
scheduled polling consumer back-off if there has been a number of subsequent 
idles/errors in a row. The multiplier is then the number of polls that will be 
skipped before the next actual attempt is happening again. When this option is 
in use then <strong><cod
 e>backoffIdleThreshold</code></strong> and/or 
<strong><code>backoffErrorThreshold</code></strong> must also be 
configured.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>delay</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>500</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Milliseconds before the next poll.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>greedy</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.10.6/2.11.1:</strong> If greedy is enabled, then 
the&#160;<strong><code>ScheduledPollConsumer</code></strong> will run 
immediately again, if the previous run polled 1 or more 
messages.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>initialDelay</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td 
 colspan="1" rowspan="1" class="confluenceTd"><p>Milliseconds before the first 
poll starts.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>pollStrategy</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>A pluggable 
<strong><code>org.apache.camel.PollingConsumerPollingStrategy</code></strong> 
allowing you to provide your custom implementation to control error handling 
usually occurred during the <strong><code>poll</code></strong> operation 
<em><strong>before</strong></em> an <a shape="rect" 
href="exchange.html">Exchange</a> has been created and routed in Camel. In 
other words the error occurred while the polling was gathering information, for 
instance access to a file network failed so Camel cannot access it to scan for 
files.</p><p>The default implementation will log the caused exception at 
<strong><code>WARN</code></strong> level and ignore it.</p></td></tr><tr><td 
colspan="1" row
 span="1" class="confluenceTd"><p><code>runLoggingLevel</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>TRACE</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The 
consumer logs a start/complete log line when it polls. This option allows you 
to configure the logging level for that.</p></td></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>scheduledExecutorService</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> 
Allows for configuring a custom/shared thread pool to use for the consumer. By 
default each consumer has its own single threaded thread pool. This option 
allows you to share a thread pool among multiple 
consumers.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>scheduler</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code
 >null</code></p></td><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><strong>Camel 2.12:</strong> Allow to plugin a custom 
 ><strong><code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code></strong>
 > to use as the scheduler for firing when the polling consumer runs. The 
 >default implementation uses the 
 ><strong><code>ScheduledExecutorService</code></strong> and there is a <a 
 >shape="rect" href="quartz2.html">Quartz2</a>, and <a shape="rect" 
 >href="spring.html">Spring</a> based which supports CRON expressions. 
 ><strong>Notice:</strong> If using a custom scheduler then the options for 
 ><strong><code>initialDelay</code>, <code>useFixedDelay</code></strong>, 
 ><strong><code>timeUnit</code></strong> and 
 ><strong><code>scheduledExecutorService</code></strong> may not be in use. Use 
 >the text <strong><code>quartz2</code></strong> to refer to use the <a 
 >shape="rect" href="quartz2.html">Quartz2</a> scheduler; and use the text 
 ><code>spring</code> to use the <a shape="rect" href="spring.html">S
 pring</a> based; and use the text <strong><code>#myScheduler</code></strong> 
to refer to a custom scheduler by its id in the <a shape="rect" 
href="registry.html">Registry</a>.</p><p>See <a shape="rect" 
href="quartz2.html">Quartz2</a> page for an example.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>scheduler.xxx</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To configure 
additional properties when using a custom 
<strong><code>scheduler</code></strong> or any of the <a shape="rect" 
href="quartz2.html">Quartz2</a>, <a shape="rect" href="spring.html">Spring</a> 
based scheduler.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>sendEmptyMessageWhenIdle</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>Came
 l 2.9:</strong> If the polling consumer did not poll any files, you can enable 
this option to send an empty message (no body) instead.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>startScheduler</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Whether the scheduler should be auto 
started.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>timeUnit</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>TimeUnit.MILLISECONDS</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Time unit for 
<strong><code>initialDelay</code></strong> and 
<strong><code>delay</code></strong> options.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>useFixedDelay</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Contro
 ls if fixed delay or fixed rate is used. See <a shape="rect" 
class="external-link" 
href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html";
 rel="nofollow">ScheduledExecutorService</a> in JDK for details. In 
<strong>Camel 2.7.x</strong> or older the default value is 
<strong><code>false</code></strong>.</p><p>From <strong>Camel 2.8</strong>: the 
default value is 
<strong><code>true</code></strong>.</p></td></tr></tbody></table></div></div>
-
-
-<h3 
id="PollingConsumer-UsingbackofftoLettheSchedulerbeLessAggressive">Using&#160;<code>backoff</code>
 to Let the Scheduler be Less Aggressive</h3><p><strong>Available as of Camel 
2.12</strong></p><p>The scheduled <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a> is by default static by using 
the same poll frequency whether or not there is messages to pickup or 
not.</p><p>From <strong>Camel 2.12</strong>: you can configure the scheduled <a 
shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more 
dynamic by using <strong><code>backoff</code></strong>. This allows the 
scheduler to skip N number of polls when it becomes idle, or there has been X 
number of errors in a row. See more details in the table above for the 
<strong><code>backoffXXX</code></strong> options.</p><p>For example to let a 
FTP consumer back-off if its becoming idle for a while you can do:</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;ftp://myserver?username=foo&amp;passowrd=secret?delete=true&amp;delay=5s&amp;backoffMultiplier=6&amp;backoffIdleThreshold=5&quot;)
-  .to(&quot;bean:processFile&quot;);
-]]></script>
-</div></div><p>In this example, the FTP consumer will poll for new FTP files 
every 5th second. But if it has been idle for 5 attempts in a row, then it will 
back-off using a multiplier of 6, which means it will now poll every 5 x 6 = 
30th second instead. When the consumer eventually pickup a file, then the 
back-off will reset, and the consumer will go back and poll every 5th second 
again.</p><p>Camel will log at <strong><code>DEBUG</code></strong> level using 
<strong><code>org.apache.camel.impl.ScheduledPollConsumer</code></strong> when 
back-off is kicking-in.</p><h3 
id="PollingConsumer-AboutErrorHandlingandScheduledPollingConsumers">About Error 
Handling and Scheduled Polling Consumers</h3><p><a shape="rect" 
class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a>
 is scheduled based and its <strong><code>run</code></strong> method is invoked 
periodically based on schedule settings
 . But errors can also occur when a poll is being executed. For instance if 
Camel should poll a file network, and this network resource is not available 
then a <strong><code>java.io.IOException</code></strong> could occur. As this 
error happens <strong>before</strong> any <a shape="rect" 
href="exchange.html">Exchange</a> has been created and prepared for routing, 
then the regular <a shape="rect" href="error-handling-in-camel.html">Error 
handling in Camel</a> does not apply. So what does the consumer do then? Well 
the exception is propagated back to the <strong><code>run</code></strong> 
method where its handled. Camel will by default log the exception at 
<strong><code>WARN</code></strong> level and then ignore it. At next schedule 
the error could have been resolved and thus being able to poll the endpoint 
successfully.</p><h3 id="PollingConsumer-UsingaCustomScheduler">Using a Custom 
Scheduler</h3><p><strong>Available as of Camel 2.12:</strong></p><p>The SPI 
interface <strong><code>org
 .apache.camel.spi.ScheduledPollConsumerScheduler</code></strong> allows to 
implement a custom scheduler to control when the <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a> runs. The default 
implementation is based on the JDKs 
<strong><code>ScheduledExecutorService</code></strong> with a single thread in 
the thread pool. There is a CRON based implementation in the <a shape="rect" 
href="quartz2.html">Quartz2</a>, and <a shape="rect" 
href="spring.html">Spring</a> components.</p><p>For an example of developing 
and using a custom scheduler, see the unit test 
<strong><code>org.apache.camel.component.file.FileConsumerCustomSchedulerTest</code></strong>
 from the source code in <strong><code>camel-core</code></strong>.</p><h4 
id="PollingConsumer-ErrorHandlingWhenUsingPollingConsumerPollStrategy">Error 
Handling When 
Using&#160;<code>PollingConsumerPollStrategy</code></h4><p><strong><code>org.apache.camel.PollingConsumerPollStrategy</code></strong>
 is a pluggable strategy tha
 t you can configure on the 
<strong><code>ScheduledPollConsumer</code></strong>. The default implementation 
<strong><code>org.apache.camel.impl.DefaultPollingConsumerPollStrategy</code></strong>
 will log the caused exception at <strong><code>WARN</code></strong> level and 
then ignore this issue.</p><p>The strategy interface provides the following 
three methods:</p><ul 
class="alternate"><li><strong><code>begin</code></strong><br clear="none"><ul 
class="alternate"><li><code>void begin(Consumer consumer, Endpoint 
endpoint)</code></li></ul></li><li><strong><code>begin</code></strong>&#160;(<strong>Camel
 2.3</strong>)<ul class="alternate"><li><code>boolean begin(Consumer consumer, 
Endpoint 
endpoint)</code></li></ul></li><li><strong><code>commit</code></strong><br 
clear="none"><ul class="alternate"><li><code>void commit(Consumer consumer, 
Endpoint 
endpoint)</code></li></ul></li><li><strong><code>commit</code></strong>&#160;(<strong>Camel
 2.6</strong>)<ul class="alternate"><li><code>void co
 mmit(Consumer consumer, Endpoint endpoint, int 
polledMessages)</code></li></ul></li><li><strong><code>rollback</code></strong><br
 clear="none"><ul class="alternate"><li><code>boolean rollback(Consumer 
consumer, Endpoint endpoint, int retryCounter, Exception e) throws 
Exception</code></li></ul></li></ul><p>In <strong>Camel 2.3</strong>: the begin 
method returns a&#160;<strong><code>boolean</code></strong> which indicates 
whether or not to skipping polling. So you can implement your custom logic and 
return <strong><code>false</code></strong> if you do not want to poll this 
time.</p><p>In <strong>Camel 2.6</strong>: the commit method has an additional 
parameter containing the number of message that was actually polled. For 
example if there was no messages polled, the value would be zero, and you can 
react accordingly.</p><p>The most interesting is the 
<strong><code>rollback</code></strong> as it allows you do handle the caused 
exception and decide what to do.</p><p>For instance if we w
 ant to provide a retry feature to a scheduled consumer we can implement the 
<strong><code>PollingConsumerPollStrategy</code></strong> method and put the 
retry logic in the <strong><code>rollback</code></strong> method. Lets just 
retry up till three times:</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 boolean rollback(Consumer consumer, 
Endpoint endpoint, int retryCounter, Exception e) throws Exception {
+Exchange exchange = consumer.receive(5000);</plain-text-body><h3 
id="PollingConsumer-ConsumerTemplate">ConsumerTemplate</h3><p>The 
<strong><code>ConsumerTemplate</code></strong> is a template much like 
Spring's&#160;<strong><code>JmsTemplate</code></strong> 
or&#160;<strong><code>JdbcTemplate</code></strong> supporting the <a 
shape="rect" href="polling-consumer.html">Polling Consumer</a> EIP. With the 
template you can consume <a shape="rect" href="exchange.html">Exchange</a>s 
from an <a shape="rect" href="endpoint.html">Endpoint</a>. The template 
supports the three operations listed above. However, it also includes 
convenient methods for returning the body, etc 
<strong><code>consumeBody</code></strong>.</p><p>Example:</p><plain-text-body>Exchange
 exchange = consumerTemplate.receive("activemq:my.queue");
+</plain-text-body><p>Or to extract and get the body you can 
do:</p><plain-text-body>Object body = 
consumerTemplate.receiveBody("activemq:my.queue");
+</plain-text-body><p>And you can provide the body type as a parameter and have 
it returned as the type:</p><plain-text-body>String body = 
consumerTemplate.receiveBody("activemq:my.queue", String.class);
+</plain-text-body><p>You get hold of a 
<strong><code>ConsumerTemplate</code></strong> from the 
<strong><code>CamelContext</code></strong> with the 
<strong><code>createConsumerTemplate</code></strong> 
operation:</p><plain-text-body>ConsumerTemplate consumer = 
context.createConsumerTemplate();
+</plain-text-body><h4 
id="PollingConsumer-UsingConsumerTemplatewithSpringDSL">Using ConsumerTemplate 
with Spring DSL</h4><p>With the Spring DSL we can declare the consumer in 
the&#160;<strong><code>CamelContext</code></strong> with the 
<strong><code>consumerTemplate</code></strong> tag, just like the 
<strong><code>ProducerTemplate</code></strong>. The example below illustrates 
this:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/components/camel-spring/src/test/resources/org/apache/camel/spring/SpringConsumerTemplateTest-context.xml}</plain-text-body>Then
 we can get leverage Spring to inject the 
<strong><code>ConsumerTemplate</code></strong> in our java class. The code 
below is part of an unit test but it shows how the consumer and producer can 
work 
together.<plain-text-body>{snippet:id=e1|lang=java|url=camel/components/camel-spring/src/test/java/org/apache/camel/spring/SpringConsumerTemplateTest.java}</plain-text-body></p><h4
 id="PollingConsumer-TimerBasedPollingConsumer">Timer 
 Based Polling Consumer</h4><p>In this sample we use a <a shape="rect" 
href="timer.html">Timer</a> to schedule a route to be started every 5th second 
and invoke our bean&#160;<strong><code>MyCoolBean</code></strong> where we 
implement the business logic for the <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a>. Here we want to consume all 
messages from a JMS queue, process the message and send them to the next 
queue.</p><p>First we setup our route 
as:<plain-text-body>{snippet:id=e1|lang=java|url=camel/tags/camel-2.6.0/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTimerBasedPollingConsumerTest.java}</plain-text-body>And
 then we have out logic in our 
bean:<plain-text-body>{snippet:id=e2|lang=java|url=camel/tags/camel-2.6.0/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTimerBasedPollingConsumerTest.java}</plain-text-body></p><h3
 id="PollingConsumer-ScheduledPollComponents">Scheduled Poll 
Components</h3><p>Quite a few inbound 
 Camel endpoints use a scheduled poll pattern to receive messages and push them 
through the Camel processing routes. That is to say externally from the client 
the endpoint appears to use an <a shape="rect" 
href="event-driven-consumer.html">Event Driven Consumer</a> but internally a 
scheduled poll is used to monitor some kind of state or resource and then fire 
message exchanges.</p><p>Since this a such a common pattern, polling components 
can extend the <a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a>
 base class which makes it simpler to implement this pattern. There is also the 
<a shape="rect" href="quartz.html">Quartz Component</a> which provides 
scheduled delivery of messages using the Quartz enterprise scheduler.</p><p>For 
more details see:</p><ul><li><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/
 apache/camel/PollingConsumer.html">PollingConsumer</a></li><li>Scheduled 
Polling Components<ul><li><a shape="rect" class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a></li><li><a
 shape="rect" href="scheduler.html">Scheduler</a></li><li><a shape="rect" 
href="atom.html">Atom</a></li><li><a shape="rect" 
href="beanstalk.html">Beanstalk</a></li><li><a shape="rect" 
href="file2.html">File</a></li><li><a shape="rect" 
href="ftp2.html">FTP</a></li><li><a shape="rect" 
href="hbase.html">hbase</a></li><li><a shape="rect" 
href="ibatis.html">iBATIS</a></li><li><a shape="rect" 
href="jpa.html">JPA</a></li><li><a shape="rect" 
href="mail.html">Mail</a></li><li><a shape="rect" 
href="mybatis.html">MyBatis</a></li><li><a shape="rect" 
href="quartz.html">Quartz</a></li><li><a shape="rect" 
href="snmp.html">SNMP</a></li><li><a shape="rect" 
href="aws-s3.html">AWS-S3</a></li><li><a shape="rect" href="aws
 -sqs.html">AWS-SQS</a></li></ul></li></ul><h3 
id="PollingConsumer-ScheduledPollConsumerOptions">ScheduledPollConsumer 
Options</h3><p>The&#160;<strong><code>ScheduledPollConsumer</code></strong> 
supports the following options:</p><parameter 
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>backoffErrorThreshold</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> 
The number of subsequent error polls (failed due some error) that should happen 
before the <strong><code>backoffMultipler</code></strong> should kick-in.</p></t
 d></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>backoffIdleThreshold</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> 
The number of subsequent idle polls that should happen before the 
<strong><code>backoffMultipler</code></strong> should 
kick-in.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>backoffMultiplier</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To let the 
scheduled polling consumer back-off if there has been a number of subsequent 
idles/errors in a row. The multiplier is then the number of polls that will be 
skipped before the next actual attempt is happening again. When this option is 
in use then <strong><code>backoffIdleThreshold</code></strong> and/or 
<strong><code>backoffErrorT
 hreshold</code></strong> must also be configured.</p></td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>delay</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>500</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Milliseconds before the next 
poll.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>greedy</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.10.6/2.11.1:</strong> If greedy is 
enabled, then the&#160;<strong><code>ScheduledPollConsumer</code></strong> will 
run immediately again, if the previous run polled 1 or more 
messages.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>initialDelay</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Milliseconds before the f
 irst poll starts.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>pollStrategy</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>A pluggable 
<strong><code>org.apache.camel.PollingConsumerPollingStrategy</code></strong> 
allowing you to provide your custom implementation to control error handling 
usually occurred during the <strong><code>poll</code></strong> operation 
<em><strong>before</strong></em> an <a shape="rect" 
href="exchange.html">Exchange</a> has been created and routed in Camel. In 
other words the error occurred while the polling was gathering information, for 
instance access to a file network failed so Camel cannot access it to scan for 
files.</p><p>The default implementation will log the caused exception at 
<strong><code>WARN</code></strong> level and ignore it.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>runLoggingLevel</code></p></td><td
  colspan="1" rowspan="1" 
class="confluenceTd"><p><code>TRACE</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><strong>Camel 2.8:</strong> The consumer logs a 
start/complete log line when it polls. This option allows you to configure the 
logging level for that.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>scheduledExecutorService</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> 
Allows for configuring a custom/shared thread pool to use for the consumer. By 
default each consumer has its own single threaded thread pool. This option 
allows you to share a thread pool among multiple 
consumers.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>scheduler</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>
 <strong>Camel 2.12:</strong> Allow to plugin a custom 
<strong><code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code></strong>
 to use as the scheduler for firing when the polling consumer runs. The default 
implementation uses the <strong><code>ScheduledExecutorService</code></strong> 
and there is a <a shape="rect" href="quartz2.html">Quartz2</a>, and <a 
shape="rect" href="spring.html">Spring</a> based which supports CRON 
expressions. <strong>Notice:</strong> If using a custom scheduler then the 
options for <strong><code>initialDelay</code>, 
<code>useFixedDelay</code></strong>, <strong><code>timeUnit</code></strong> and 
<strong><code>scheduledExecutorService</code></strong> may not be in use. Use 
the text <strong><code>quartz2</code></strong> to refer to use the <a 
shape="rect" href="quartz2.html">Quartz2</a> scheduler; and use the text 
<code>spring</code> to use the <a shape="rect" href="spring.html">Spring</a> 
based; and use the text <strong><code>#myScheduler</code></stro
 ng> to refer to a custom scheduler by its id in the <a shape="rect" 
href="registry.html">Registry</a>.</p><p>See <a shape="rect" 
href="quartz2.html">Quartz2</a> page for an example.</p></td></tr><tr><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>scheduler.xxx</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To configure 
additional properties when using a custom 
<strong><code>scheduler</code></strong> or any of the <a shape="rect" 
href="quartz2.html">Quartz2</a>, <a shape="rect" href="spring.html">Spring</a> 
based scheduler.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>sendEmptyMessageWhenIdle</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.9:</strong> If 
the polling consumer did not poll any files, you can e
 nable this option to send an empty message (no body) 
instead.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>startScheduler</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Whether the scheduler should be auto 
started.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>timeUnit</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>TimeUnit.MILLISECONDS</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Time unit for 
<strong><code>initialDelay</code></strong> and 
<strong><code>delay</code></strong> options.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>useFixedDelay</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>Controls if fixed delay or fixed rate is 
used. See <a shape="rect" class="exter
 nal-link" 
href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html";
 rel="nofollow">ScheduledExecutorService</a> in JDK for details. In 
<strong>Camel 2.7.x</strong> or older the default value is 
<strong><code>false</code></strong>.</p><p>From <strong>Camel 2.8</strong>: the 
default value is 
<strong><code>true</code></strong>.</p></td></tr></tbody></table></div></rich-text-body><h3
 
id="PollingConsumer-UsingbackofftoLettheSchedulerbeLessAggressive">Using&#160;<code>backoff</code>
 to Let the Scheduler be Less Aggressive</h3><p><strong>Available as of Camel 
2.12</strong></p><p>The scheduled <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a> is by default static by using 
the same poll frequency whether or not there is messages to pickup or 
not.</p><p>From <strong>Camel 2.12</strong>: you can configure the scheduled <a 
shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more 
dynamic by using <strong><code>backoff</code
 ></strong>. This allows the scheduler to skip N number of polls when it 
 >becomes idle, or there has been X number of errors in a row. See more details 
 >in the table above for the <strong><code>backoffXXX</code></strong> 
 >options.</p><p>For example to let a FTP consumer back-off if its becoming 
 >idle for a while you can do:</p><parameter 
 >ac:name="language">java</parameter><plain-text-body>from("ftp://myserver?username=foo&amp;passowrd=secret?delete=true&amp;delay=5s&amp;backoffMultiplier=6&amp;backoffIdleThreshold=5";)
+  .to("bean:processFile");
+</plain-text-body><p>In this example, the FTP consumer will poll for new FTP 
files every 5th second. But if it has been idle for 5 attempts in a row, then 
it will back-off using a multiplier of 6, which means it will now poll every 5 
x 6 = 30th second instead. When the consumer eventually pickup a file, then the 
back-off will reset, and the consumer will go back and poll every 5th second 
again.</p><p>Camel will log at <strong><code>DEBUG</code></strong> level using 
<strong><code>org.apache.camel.impl.ScheduledPollConsumer</code></strong> when 
back-off is kicking-in.</p><h3 
id="PollingConsumer-AboutErrorHandlingandScheduledPollingConsumers">About Error 
Handling and Scheduled Polling Consumers</h3><p><a shape="rect" 
class="external-link" 
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ScheduledPollConsumer.html";>ScheduledPollConsumer</a>
 is scheduled based and its <strong><code>run</code></strong> method is invoked 
periodically based on schedule se
 ttings. But errors can also occur when a poll is being executed. For instance 
if Camel should poll a file network, and this network resource is not available 
then a <strong><code>java.io.IOException</code></strong> could occur. As this 
error happens <strong>before</strong> any <a shape="rect" 
href="exchange.html">Exchange</a> has been created and prepared for routing, 
then the regular <a shape="rect" href="error-handling-in-camel.html">Error 
handling in Camel</a> does not apply. So what does the consumer do then? Well 
the exception is propagated back to the <strong><code>run</code></strong> 
method where its handled. Camel will by default log the exception at 
<strong><code>WARN</code></strong> level and then ignore it. At next schedule 
the error could have been resolved and thus being able to poll the endpoint 
successfully.</p><h3 id="PollingConsumer-UsingaCustomScheduler">Using a Custom 
Scheduler</h3><p><strong>Available as of Camel 2.12:</strong></p><p>The SPI 
interface <strong><co
 de>org.apache.camel.spi.ScheduledPollConsumerScheduler</code></strong> allows 
to implement a custom scheduler to control when the <a shape="rect" 
href="polling-consumer.html">Polling Consumer</a> runs. The default 
implementation is based on the JDKs 
<strong><code>ScheduledExecutorService</code></strong> with a single thread in 
the thread pool. There is a CRON based implementation in the <a shape="rect" 
href="quartz2.html">Quartz2</a>, and <a shape="rect" 
href="spring.html">Spring</a> components.</p><p>For an example of developing 
and using a custom scheduler, see the unit test 
<strong><code>org.apache.camel.component.file.FileConsumerCustomSchedulerTest</code></strong>
 from the source code in <strong><code>camel-core</code></strong>.</p><h4 
id="PollingConsumer-ErrorHandlingWhenUsingPollingConsumerPollStrategy">Error 
Handling When 
Using&#160;<code>PollingConsumerPollStrategy</code></h4><p><strong><code>org.apache.camel.PollingConsumerPollStrategy</code></strong>
 is a pluggable strate
 gy that you can configure on the 
<strong><code>ScheduledPollConsumer</code></strong>. The default implementation 
<strong><code>org.apache.camel.impl.DefaultPollingConsumerPollStrategy</code></strong>
 will log the caused exception at <strong><code>WARN</code></strong> level and 
then ignore this issue.</p><p>The strategy interface provides the following 
three methods:</p><ul 
class="alternate"><li><strong><code>begin</code></strong><br clear="none"><ul 
class="alternate"><li><code>void begin(Consumer consumer, Endpoint 
endpoint)</code></li></ul></li><li><strong><code>begin</code></strong>&#160;(<strong>Camel
 2.3</strong>)<ul class="alternate"><li><code>boolean begin(Consumer consumer, 
Endpoint 
endpoint)</code></li></ul></li><li><strong><code>commit</code></strong><br 
clear="none"><ul class="alternate"><li><code>void commit(Consumer consumer, 
Endpoint 
endpoint)</code></li></ul></li><li><strong><code>commit</code></strong>&#160;(<strong>Camel
 2.6</strong>)<ul class="alternate"><li><code>v
 oid commit(Consumer consumer, Endpoint endpoint, int 
polledMessages)</code></li></ul></li><li><strong><code>rollback</code></strong><br
 clear="none"><ul class="alternate"><li><code>boolean rollback(Consumer 
consumer, Endpoint endpoint, int retryCounter, Exception e) throws 
Exception</code></li></ul></li></ul><p>In <strong>Camel 2.3</strong>: the begin 
method returns a&#160;<strong><code>boolean</code></strong> which indicates 
whether or not to skipping polling. So you can implement your custom logic and 
return <strong><code>false</code></strong> if you do not want to poll this 
time.</p><p>In <strong>Camel 2.6</strong>: the commit method has an additional 
parameter containing the number of message that was actually polled. For 
example if there was no messages polled, the value would be zero, and you can 
react accordingly.</p><p>The most interesting is the 
<strong><code>rollback</code></strong> as it allows you do handle the caused 
exception and decide what to do.</p><p>For instance i
 f we want to provide a retry feature to a scheduled consumer we can implement 
the <strong><code>PollingConsumerPollStrategy</code></strong> method and put 
the retry logic in the <strong><code>rollback</code></strong> method. Lets just 
retry up till three times:</p><parameter 
ac:name="">java</parameter><plain-text-body>public boolean rollback(Consumer 
consumer, Endpoint endpoint, int retryCounter, Exception e) throws Exception {
   if (retryCounter &lt; 3) {
     // return true to tell Camel that it should retry the poll immediately
     return true;
@@ -223,19 +94,12 @@ public static class MyCoolBean {
 
   // okay we give up do not retry anymore
   return false;
-}]]></script>
-</div></div><p>Notice that we are given the 
<strong><code>Consumer</code></strong> as a parameter. We could use this to 
<em>restart</em> the consumer as we can invoke stop and start:</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[// error occurred lets restart the consumer, 
that could maybe resolve the issue
+}</plain-text-body><p>Notice that we are given the 
<strong><code>Consumer</code></strong> as a parameter. We could use this to 
<em>restart</em> the consumer as we can invoke stop and start:</p><parameter 
ac:name="language">java</parameter><plain-text-body>// error occurred lets 
restart the consumer, that could maybe resolve the issue
 consumer.stop();
 consumer.start();
-]]></script>
-</div></div><p><strong>Note:</strong> if you implement the 
<strong><code>begin</code></strong> operation make sure to avoid throwing 
exceptions as in such a case the <strong><code>poll</code></strong> operation 
is not invoked and Camel will invoke the <strong><code>rollback</code></strong> 
directly.</p><h4 
id="PollingConsumer-ConfiguringantoUsePollingConsumerPollStrategy">Configuring 
an <a shape="rect" href="endpoint.html">Endpoint</a> to Use 
<code>PollingConsumerPollStrategy</code></h4><p>To configure an <a shape="rect" 
href="endpoint.html">Endpoint</a> to use a custom 
<strong><code>PollingConsumerPollStrategy</code></strong> you use the option 
<strong><code>pollStrategy</code></strong>. For example in the file consumer 
below we want to use our custom strategy defined in the <a shape="rect" 
href="registry.html">Registry</a> with the bean id 
<strong><code>myPoll</code></strong>:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[from(&quot;file://inbox/?pollStrategy=#myPoll&quot;)
-  .to(&quot;activemq:queue:inbox&quot;)
-]]></script>
-</div></div><p></p><h4 id="PollingConsumer-UsingThisPattern">Using This 
Pattern</h4>
-
-<p>If you would like to use this EIP Pattern then please read the <a 
shape="rect" href="getting-started.html">Getting Started</a>, you may also find 
the <a shape="rect" href="architecture.html">Architecture</a> useful 
particularly the description of <a shape="rect" 
href="endpoint.html">Endpoint</a> and <a shape="rect" 
href="uris.html">URIs</a>. Then you could try out some of the <a shape="rect" 
href="examples.html">Examples</a> first before trying this pattern out.</p><h3 
id="PollingConsumer-SeeAlso">See Also</h3><ul class="alternate"><li><a 
shape="rect" href="pojo-consuming.html">POJO Consuming</a></li><li><a 
shape="rect" href="batch-consumer.html">Batch Consumer</a></li></ul></div>
+</plain-text-body><p><strong>Note:</strong> if you implement the 
<strong><code>begin</code></strong> operation make sure to avoid throwing 
exceptions as in such a case the <strong><code>poll</code></strong> operation 
is not invoked and Camel will invoke the <strong><code>rollback</code></strong> 
directly.</p><h4 
id="PollingConsumer-ConfiguringantoUsePollingConsumerPollStrategy">Configuring 
an <a shape="rect" href="endpoint.html">Endpoint</a> to Use 
<code>PollingConsumerPollStrategy</code></h4><p>To configure an <a shape="rect" 
href="endpoint.html">Endpoint</a> to use a custom 
<strong><code>PollingConsumerPollStrategy</code></strong> you use the option 
<strong><code>pollStrategy</code></strong>. For example in the file consumer 
below we want to use our custom strategy defined in the <a shape="rect" 
href="registry.html">Registry</a> with the bean id 
<strong><code>myPoll</code></strong>:</p><plain-text-body>from("file://inbox/?pollStrategy=#myPoll")
+  .to("activemq:queue:inbox")
+</plain-text-body><p><parameter ac:name=""><a shape="rect" 
href="using-this-pattern.html">Using This Pattern</a></parameter></p><h3 
id="PollingConsumer-SeeAlso">See Also</h3><ul class="alternate"><li><a 
shape="rect" href="pojo-consuming.html">POJO Consuming</a></li><li><a 
shape="rect" href="batch-consumer.html">Batch Consumer</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/property.html
==============================================================================
--- websites/production/camel/content/property.html (original)
+++ websites/production/camel/content/property.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: Property
@@ -86,23 +75,8 @@
        <tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 
id="Property-PropertyExpressionLanguage">Property Expression 
Language</h2><p>The Property Expression Language allows you to extract values 
of named exchange properties.</p><div class="confluence-information-macro 
confluence-information-macro-note"><span class="aui-icon aui-icon-small 
aui-iconfont-warning confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>From <strong>Camel 2.15</strong> 
onwards the property language has been renamed to exchangeProperty to avoid 
ambiguity, confusion and clash with properties as a general term. So use 
exchangeProperty instead of property when using Camel 2.15 
onwards.</p></div></div><p>&#160;</p><h3 id="Property-Exampleusage">Example 
usage</h3><p>The recipientList element of the Spring DSL can utilize a property 
expression like:</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;recipientList&gt;
-    &lt;exchangeProperty&gt;myProperty&lt;/exchangeProperty&gt;
-  &lt;/recipientList&gt;
-&lt;/route&gt;
-]]></script>
-</div></div><p>In this case, the list of recipients are contained in the 
property 'myProperty'.</p><p>And the same example in Java DSL:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:a&quot;).recipientList(property(&quot;myProperty&quot;));
-]]></script>
-</div></div><p>And with a slightly different syntax where you use the builder 
to the fullest (i.e. avoid using parameters but using stacked operations, 
notice that property is not a parameter but a stacked method call)</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;).recipientList().property(&quot;myProperty&quot;);
-]]></script>
-</div></div><h3 id="Property-Dependencies">Dependencies</h3><p>The Property 
language is part of <strong>camel-core</strong>.</p></div>
+<div class="wiki-content maincontent"><h2 
id="Property-PropertyExpressionLanguage">Property Expression 
Language</h2><p>The Property Expression Language allows you to extract values 
of named exchange properties.</p><rich-text-body><p>From <strong>Camel 
2.15</strong> onwards the property language has been renamed to 
exchangeProperty to avoid ambiguity, confusion and clash with properties as a 
general term. So use exchangeProperty instead of property when using Camel 2.15 
onwards.</p></rich-text-body><p>&#160;</p><h3 
id="Property-Exampleusage">Example usage</h3><p>The recipientList element of 
the Spring DSL can utilize a property expression 
like:</p><plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/recipientListWithStringDelimitedProperty.xml}</plain-text-body><p>In
 this case, the list of recipients are contained in the property 
'myProperty'.</p><p>And the same example in Java DSL:</p><plain-text-body>{
 
snippet:id=example|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RecipientListWithStringDelimitedPropertyTest.java}</plain-text-body><p>And
 with a slightly different syntax where you use the builder to the fullest 
(i.e. avoid using parameters but using stacked operations, notice that property 
is not a parameter but a stacked method call)</p><parameter 
ac:name="">java</parameter><plain-text-body>  
from("direct:a").recipientList().property("myProperty");
+</plain-text-body><h3 id="Property-Dependencies">Dependencies</h3><p>The 
Property language is part of <strong>camel-core</strong>.</p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/python.html
==============================================================================
--- websites/production/camel/content/python.html (original)
+++ websites/production/camel/content/python.html Fri Aug 25 08:22:01 2017
@@ -110,46 +110,19 @@
         &lt;/choice&gt;
     &lt;/route&gt;
 ]]></script>
-</div></div><p></p><h3 
id="Python-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><div class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body">The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</div></div><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><cod
 e>org.apache.camel.CamelContext</code></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The Camel Context.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>context</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The current 
Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> Fun
 ction with a <strong><code>resolve</code></strong> method to make it easier to 
use Camels <a shape="rect" href="properties.html">Properties</a> component from 
scripts. See further below for example.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><code>request</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" 
class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
message.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
The&#160;<strong><code>OUT</code></strong> message. 
The&#160;<strong><code>OUT</code></strong> message 
is&#160;<strong><code>null</code></strong> by default. Use the 
<strong><code>IN</code></strong> message instead.</p></
 td></tr></tbody></table></div><p>See <a shape="rect" 
href="scripting-languages.html">Scripting Languages</a> for the list of 
languages with explicit DSL support.</p><h3 
id="Python-PassingAdditionalArgumentstotheScriptingEngine">Passing Additional 
Arguments to the&#160;<code>ScriptingEngine</code></h3><p><strong>Available 
from Camel 2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:</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 void testArgumentsExample() throws Exception {
-    getMockEndpoint(&quot;mock:result&quot;).expectedMessageCount(0);
-    getMockEndpoint(&quot;mock:unmatched&quot;).expectedMessageCount(1);
-
-    // additional arguments to ScriptEngine
-    Map&lt;String, Object&gt; arguments = new HashMap&lt;String, Object&gt;();
-    arguments.put(&quot;foo&quot;, &quot;bar&quot;);
-    arguments.put(&quot;baz&quot;, 7);
-
-    // those additional arguments is provided as a header on the Camel Message
-    template.sendBodyAndHeader(&quot;direct:start&quot;, &quot;hello&quot;, 
ScriptBuilder.ARGUMENTS, arguments);
-
-    assertMockEndpointsSatisfied();
-}
-]]></script>
-</div></div><h3 id="Python-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>foo</code></strong>.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[.setHeader(&quot;myHeader&quot;).groovy(&quot;context.resolvePropertyPlaceholders(&#39;{{&#39;
 + request.headers.get(&#39;foo&#39;) + &#39;}}&#39;)&quot;)
-]]></script>
-</div></div><p>From <strong>Camel 2.9</strong>: you can now use the properties 
function and the same example is simpler:</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[.setHeader(&quot;myHeader&quot;).groovy(&quot;properties.resolve(request.headers.get(&#39;foo&#39;))&quot;)
-]]></script>
-</div></div><h3 id="Python-LoadingScriptFromExternalResource">Loading Script 
From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</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[.setHeader(&quot;myHeader&quot;).groovy(&quot;resource:classpath:mygroovy.groovy&quot;)
-]]></script>
-</div></div><h3 id="Python-HowtoGettheResultfromMultipleStatementsScript">How 
to Get the Result from Multiple Statements Script</h3><p><strong>Available from 
Camel 2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
-<script class="brush: text; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[bar = &quot;baz&quot;;
+</div></div><p></p><h3 
id="Python-ScriptContextOptions"><code>ScriptContext</code> 
Options</h3><p>&#160;</p><rich-text-body>The&#160;<code>JSR-223</code> 
scripting language's&#160;<strong><code>ScriptContext</code></strong> is 
pre-configured with the following attributes all set at 
<strong><code>ENGINE_SCOPE</code></strong>.</rich-text-body><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Value</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><span><code>camelContext</code><br 
clear="none"></span></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel 
Context.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>context</code
 ></p></td><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.CamelContext</code></p></td><td
 > colspan="1" rowspan="1" class="confluenceTd"><p>The Camel Context (cannot be 
 >used in groovy).</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>exchange</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Exchange</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p>The current 
 >Exchange.</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>properties</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.builder.script.PropertiesFunction</code></p></td><td
 > colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> 
 >Function with a <strong><code>resolve</code></strong> method to make it 
 >easier to use Camels <a shape="rect" href="properties.html">Properties</a> 
 >component from scripts. See further below for example.</p></td
 ></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>request</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
 >colspan="1" rowspan="1" 
 >class="confluenceTd"><p>The&#160;<strong><code>IN</code></strong> 
 >message.</p></td></tr><tr><td colspan="1" rowspan="1" 
 >class="confluenceTd"><p><code>response</code></p></td><td colspan="1" 
 >rowspan="1" 
 >class="confluenceTd"><p><code>org.apache.camel.Message</code></p></td><td 
 >colspan="1" rowspan="1" class="confluenceTd"><p><strong>Deprecated</strong>: 
 >The&#160;<strong><code>OUT</code></strong> message. 
 >The&#160;<strong><code>OUT</code></strong> message 
 >is&#160;<strong><code>null</code></strong> by default. Use the 
 ><strong><code>IN</code></strong> message 
 >instead.</p></td></tr></tbody></table></div><p>See <a shape="rect" 
 >href="scripting-languages.html">Scripting Languages</a> for the list of 
 >languages with explicit DSL support.</p><h3 
 >id="Python-PassingAdditionalArguments
 totheScriptingEngine">Passing Additional Arguments to 
the&#160;<code>ScriptingEngine</code></h3><p><strong>Available from Camel 
2.8</strong></p><p>You can provide additional arguments to the 
<strong><code>ScriptingEngine</code></strong> using a header on the Camel 
message with the key 
<strong><code>CamelScriptArguments</code></strong>.</p><p>Example:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-script/src/test/java/org/apache/camel/builder/script/JavaScriptExpressionTest.java}</plain-text-body></p><h3
 id="Python-UsingPropertiesFunction">Using Properties 
Function</h3><p><strong>Available from Camel 2.9</strong></p><p>If you need to 
use the <a shape="rect" href="properties.html">Properties</a> component from a 
script to lookup property placeholders, then its a bit cumbersome to do so. For 
example, to set a header name&#160;<strong><code>myHeader</code></strong> with 
a value from a property placeholder, whose key is taken from a header named 
<strong><code>f
 
oo</code></strong>.</p><plain-text-body>.setHeader("myHeader").groovy("context.resolvePropertyPlaceholders('{{'
 + request.headers.get('foo') + '}}')")
+</plain-text-body><p>From <strong>Camel 2.9</strong>: you can now use the 
properties function and the same example is simpler:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("properties.resolve(request.headers.get('foo'))")
+</plain-text-body><h3 id="Python-LoadingScriptFromExternalResource">Loading 
Script From External Resource</h3><p><strong>Available from Camel 
2.11</strong></p><p>You can externalize the script and have Camel load it from 
a resource such as <strong><code>classpath:</code></strong>, 
<strong><code>file:</code></strong>, or <strong><code>http:</code></strong>. 
This is done using the following syntax: 
<strong><code>resource:scheme:location</code></strong> e.g. to refer to a file 
on the classpath you can do:</p><parameter 
ac:name="language">java</parameter><plain-text-body>.setHeader("myHeader").groovy("resource:classpath:mygroovy.groovy")
+</plain-text-body><h3 
id="Python-HowtoGettheResultfromMultipleStatementsScript">How to Get the Result 
from Multiple Statements Script</h3><p><strong>Available from Camel 
2.14</strong></p><p>The script engine's eval method returns 
a&#160;<strong><code>null</code></strong> when it runs a multi-statement 
script. However, Camel can look up the value of a script's result by using the 
key <strong><code>result</code></strong> from the value set. When writing a 
multi-statement script set the value of 
the&#160;<strong><code>result</code></strong> variable as the script return 
value.</p><parameter ac:name="language">text</parameter><plain-text-body>bar = 
"baz";
 # some other statements ... 
 # camel take the result value as the script evaluation result
 result = body * 2 + 1
-]]></script>
-</div></div><p>&#160;</p><h3 id="Python-Dependencies">Dependencies</h3><p>To 
use scripting languages in your camel routes you need to add the a dependency 
on <strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</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;dependency&gt;
+</plain-text-body><p>&#160;</p><h3 
id="Python-Dependencies">Dependencies</h3><p>To use scripting languages in your 
camel routes you need to add the a dependency on 
<strong><code>camel-script</code></strong> which integrates the JSR-223 
scripting engine.</p><p>If you use maven you could just add the following to 
your <strong><code>pom.xml</code></strong>, substituting the version number for 
the latest &amp; greatest release (see <a shape="rect" href="download.html">the 
download page for the latest versions</a>).</p><parameter 
ac:name="">xml</parameter><plain-text-body>&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-script&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;
 &lt;/dependency&gt;
-]]></script>
-</div></div></div>
+</plain-text-body></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to