Modified: websites/production/camel/content/book-pattern-appendix.html ============================================================================== --- websites/production/camel/content/book-pattern-appendix.html (original) +++ websites/production/camel/content/book-pattern-appendix.html Tue Sep 22 19:20:06 2015 @@ -2731,7 +2731,16 @@ from("seda:a").throttle(3).tim </div></div><p>So the above example will throttle messages all messages received on <strong>seda:a</strong> before being sent to <strong>mock:result</strong> ensuring that a maximum of 3 messages are sent in any 10 second window.</p><p>Note that since <code>timePeriodMillis</code> defaults to 1000 milliseconds, just setting the <code>maximumRequestsPerPeriod</code> has the effect of setting the maximum number of requests per second. So to throttle requests at 100 requests per second between two endpoints, it would look more 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[from("seda:a").throttle(100).to("seda:b"); ]]></script> -</div></div><p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java?view=markup">junit test case</a></p><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><h4 id="BookPatternAppendix-Camel2.7.xorolder">Camel 2.7.x or older</h4><div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div><h4 id="BookPatternAppendix-Camel2.8onwards">Camel 2.8 onwards</h4><p>In Camel 2.8 onwards you must set the maximum period as an <a shape="rect" href="expression.html">Expression</a> as shown below where we use a <a shape="rect" href="constant.html">Constant</a> expression:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>For further examples of this pattern in use you could look at the <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThrottlerTest.java?view=markup">junit test case</a></p><p><strong>Using the <a shape="rect" href="spring-xml-extensions.html">Spring XML Extensions</a></strong></p><h4 id="BookPatternAppendix-Camel2.7.xorolder">Camel 2.7.x or older</h4><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[ +<route> + <from uri="seda:a" /> + <throttle maximumRequestsPerPeriod="3" timePeriodMillis="10000"> + <to uri="mock:result" /> + </throttle> +</route> +]]></script> +</div></div><h4 id="BookPatternAppendix-Camel2.8onwards">Camel 2.8 onwards</h4><p>In Camel 2.8 onwards you must set the maximum period as an <a shape="rect" href="expression.html">Expression</a> as shown below where we use a <a shape="rect" href="constant.html">Constant</a> expression:</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[ <route> <from uri="seda:a"/> @@ -4014,7 +4023,52 @@ public class SpringConsumerTemplateTest } ]]></script> -</div></div><h4 id="BookPatternAppendix-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 <strong>MyCoolBean</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="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>And then we have out logic in our bean:<div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div><h3 id="BookPatternAppendix-ScheduledPollComponents">Scheduled Poll Components</h3><p>Quite a few inbound Camel endpoints use a scheduled poll pa ttern 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.</p><p>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="BookPatternAppendix-ScheduledPollConsumerOptions">ScheduledPollConsumer Options</h3><p>The ScheduledPollConsumer 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>pollStrategy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd"><p>A pluggable <code>org.apache.camel.PollingConsumerPollingStrategy</code> allowing you to provide your custom implementation to control error handling usually occurred during the <code>poll</code> operation <strong>before</strong> an <a shape="rect" href="exchange.html">Exchange</a> have been created and being 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. The default implementation will log the caused exception at <code>WARN</code> level and ignore it.</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 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>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>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>useFixedDelay</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Controls 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 <code>false</code>. From <strong>Camel 2.8</strong> onwards the default value is <code>true</code>.</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 <code>initialDelay</code> and <code>delay</code> options.</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="confluenceT d"><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>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 ScheduledPollConsumer 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>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 <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code> to use as the scheduler for firing when the polling consumer runs. The default implementation uses the <code>ScheduledExecutorService</code> 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 <code>initialDelay</code>, <code>useFixedDelay</code>, <code>timeUnit</code>, and <code>scheduledExecutorService</code> may not be in use. Use the text <code>quartz2</code> 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 <code>#myScheduler</code> to refer to a custom scheduler by its id in the <a shape="rect" href="registry.html">Registry</a>. 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 <code>scheduler</code> 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>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 backoff 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 th en <code>backoffIdleThreshold</code> and/or <code>backoffErrorThreshold</code> must also be configured.</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 <code>backoffMultipler</code> should kick-in.</p></td></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 <code>backoffMultipler</code> should kick-in.</p></td></tr></tbody></table></div></div><h3 id="BookPatternAppendix-Usingbackofftolettheschedulerbelessaggre ssive">Using backoff 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. From Camel 2.12 onwards you can configure the scheduled <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more dynamic by using backoff. 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 <code>backoffXXX</code> options.</p><p>For example to let a FTP consumer backoff 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"> +</div></div><h4 id="BookPatternAppendix-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 <strong>MyCoolBean</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("timer://foo?period=5000").bean(cool, "someBusinessLogic"); + +from("activemq:queue.foo").to("mock:result"); +]]></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("activemq:queue.inbox", 3000, String.class); + if (msg == null) { + // no more messages in queue + break; + } + + // do something with body + msg = "Hello " + msg; + + // send it to the next queue + producer.sendBodyAndHeader("activemq:queue.foo", msg, "number", count++); + } + } +} +]]></script> +</div></div><h3 id="BookPatternAppendix-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.</p><p>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 detai ls 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 sh ape="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="BookPatternAppendix-ScheduledPollConsumerOptions">ScheduledPollConsumer Options</h3><p>The ScheduledPollConsumer 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>pollStrategy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd"><p>A pluggable <code>org.apache.camel.PollingConsumerPollingStrategy</code> allowing you to provide your custom implementation to control error handling usually occ urred during the <code>poll</code> operation <strong>before</strong> an <a shape="rect" href="exchange.html">Exchange</a> have been created and being 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. The default implementation will log the caused exception at <code>WARN</code> level and ignore it.</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 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>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>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>useFixedDelay</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Controls 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 <code>false</code>. From <strong>Camel 2.8</strong> onwards the default value is <code>true</code>.</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 <code>initialDelay</code> and <code>delay</code> options.</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>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 ScheduledPollConsumer 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>scheduler</code></p></td><td colspan="1" row span="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 <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code> to use as the scheduler for firing when the polling consumer runs. The default implementation uses the <code>ScheduledExecutorService</code> 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 <code>initialDelay</code>, <code>useFixedDelay</code>, <code>timeUnit</code>, and <code>scheduledExecutorService</code> may not be in use. Use the text <code>quartz2</code> 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 <code>#myScheduler</code> to refer to a custom scheduler by its id in the <a shape="rect" href="registry.html">Registry</a>. 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 <code>scheduler</code> 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>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 backoff if there has been a number of subsequent idles/erro rs 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 <code>backoffIdleThreshold</code> and/or <code>backoffErrorThreshold</code> must also be configured.</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 <code>backoffMultipler</code> should kick-in.</p></td></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 th e <code>backoffMultipler</code> should kick-in.</p></td></tr></tbody></table></div></div><h3 id="BookPatternAppendix-Usingbackofftolettheschedulerbelessaggressive">Using backoff 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. From Camel 2.12 onwards you can configure the scheduled <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more dynamic by using backoff. 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 <code>backoffXXX</code> options.</p><p>For example to let a FTP consumer backoff if its becoming idle for a while you can do:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panel Content pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("ftp://myserver?username=foo&passowrd=secret?delete=true&delay=5s&backoffMultiplier=6&backoffIdleThreshold=5") .to("bean:processFile"); ]]></script>
Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/camel/content/polling-consumer.html ============================================================================== --- websites/production/camel/content/polling-consumer.html (original) +++ websites/production/camel/content/polling-consumer.html Tue Sep 22 19:20:06 2015 @@ -157,7 +157,52 @@ public class SpringConsumerTemplateTest } ]]></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 <strong>MyCoolBean</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="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>And then we have out logic in our bean:<div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </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.</p><p>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">Pollin gConsumer</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 ScheduledPollConsumer 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>pollStrategy</code></p></td><td >colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" >rowspan="1" class="confluenceTd"><p>A pluggable ><code>org.apache.camel.PollingConsumerPollingStrategy</code> allowing you to >provide your custom implementation to control error handling usually occurred >during the <code>poll</code> operation <strong>before</strong> an <a >shape="rect" href="exchange.html">Exchange</a> have been created and being >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. The default implementation will log the caused exception at <code>WARN</code> level and ignore it.</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 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="confl uenceTd"><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>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>useFixedDelay</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Controls 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 <code>false</code>. From <strong>Camel 2.8</strong> onwards the default value is <code>true</code>.</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 <code>initialDelay</code> and <code>delay</code> options.</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>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 ScheduledPollConsumer 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>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 <cod e>org.apache.camel.spi.ScheduledPollConsumerScheduler</code> to use as the scheduler for firing when the polling consumer runs. The default implementation uses the <code>ScheduledExecutorService</code> 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 <code>initialDelay</code>, <code>useFixedDelay</code>, <code>timeUnit</code>, and <code>scheduledExecutorService</code> may not be in use. Use the text <code>quartz2</code> 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 <code>#myScheduler</code> to refer to a custom scheduler by its id in the <a shape="rect" href="registry.html">Registry</a>. 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 <code>scheduler</code> 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>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 backoff 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 <code>bac koffIdleThreshold</code> and/or <code>backoffErrorThreshold</code> must also be configured.</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 <code>backoffMultipler</code> should kick-in.</p></td></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 <code>backoffMultipler</code> should kick-in.</p></td></tr></tbody></table></div></div><h3 id="PollingConsumer-Usingbackofftolettheschedulerbelessaggressive">Using bac koff 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. From Camel 2.12 onwards you can configure the scheduled <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more dynamic by using backoff. 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 <code>backoffXXX</code> options.</p><p>For example to let a FTP consumer backoff 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"> +</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 <strong>MyCoolBean</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("timer://foo?period=5000").bean(cool, "someBusinessLogic"); + +from("activemq:queue.foo").to("mock:result"); +]]></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("activemq:queue.inbox", 3000, String.class); + if (msg == null) { + // no more messages in queue + break; + } + + // do something with body + msg = "Hello " + msg; + + // send it to the next queue + producer.sendBodyAndHeader("activemq:queue.foo", msg, "number", 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.</p><p>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 s ee:</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 ScheduledPollConsumer 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>pollStrategy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1" rowspan="1" class="confluenceTd"><p>A pluggable <code>org.apache.camel.PollingConsumerPollingStrategy</code> allowing you to provide your custom implementation to control error handling usually occurred du ring the <code>poll</code> operation <strong>before</strong> an <a shape="rect" href="exchange.html">Exchange</a> have been created and being 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. The default implementation will log the caused exception at <code>WARN</code> level and ignore it.</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 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>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>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>useFixedDelay</code></p></td><td colspan="1" >rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" >rowspan="1" class="confluenceTd"><p>Controls 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 <code>false</code>. From <strong>Camel 2.8</strong> onwards the default value is <code>true</code>.</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 <code>initialDelay</code> and <code>delay</code> options.</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>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 ScheduledPollConsumer >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>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 <code>org.apache.camel.spi.ScheduledPollConsumerScheduler</code> to use as the scheduler for firing when the polling consumer runs. The default implementation uses the <code>ScheduledExecutorService</code> 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 <code>initialDelay</code>, <code>useFixedDelay</code>, <code>timeUnit</code>, and <code>scheduledExecutorService</code> may not be in use. Use the text <code>quartz2</code> 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 <code>#myScheduler</code> to refer to a custom scheduler by its id in the <a shape="rect" href="registry.html">Registry</a>. 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 <code>scheduler</code> 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>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 backoff 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 <code>backoffIdleThreshold</code> and/or <code>backoffErrorThreshold</code> must also be configured.</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 <code>backoffMultipler</code> should kick-in.</p></td></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 <code> backoffMultipler</code> should kick-in.</p></td></tr></tbody></table></div></div><h3 id="PollingConsumer-Usingbackofftolettheschedulerbelessaggressive">Using backoff 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. From Camel 2.12 onwards you can configure the scheduled <a shape="rect" href="polling-consumer.html">Polling Consumer</a> to be more dynamic by using backoff. 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 <code>backoffXXX</code> options.</p><p>For example to let a FTP consumer backoff 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("ftp://myserver?username=foo&passowrd=secret?delete=true&delay=5s&backoffMultiplier=6&backoffIdleThreshold=5") .to("bean:processFile"); ]]></script>