Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/camel-2120-release.html
==============================================================================
--- websites/production/camel/content/camel-2120-release.html (original)
+++ websites/production/camel/content/camel-2120-release.html Tue Jun 25
07:18:29 2013
@@ -36,6 +36,16 @@
<![endif]-->
+ <link href='http://camel.apache.org/styles/highlighter/styles/shCore.css'
rel='stylesheet' type='text/css' />
+ <link
href='http://camel.apache.org/styles/highlighter/styles/shThemeEclipse.css'
rel='stylesheet' type='text/css' />
+ <script src='http://camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script
src='http://camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+ <script
src='http://camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
+
+ <script type="text/javascript">
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
<title>
Apache Camel: Camel 2.12.0 Release
@@ -86,7 +96,7 @@
<p>Welcome to the 2.12.0 release which approx XXX issues resolved (new
features, improvements and bug fixes such as...)</p>
-<ul><li><a shape="rect" href="endpoint-annotations.html" title="Endpoint
Annotations">Endpoint Annotations</a> along with automatically created HTML
documentation for the endpoint parameters; this makes it easier for component
developers to add a few refactoring-safe annotations to their Endpoint or
Consumer implementations and, (along with javadoc comments on the field or
setter method), get nice user documentation on how to use the endpoint for
free.</li><li><a shape="rect" href="componentconfiguration.html"
title="ComponentConfiguration">ComponentConfiguration</a> API provides a handy
API for tools developers to introspect on a Component to find all the possible
parameters, their types and any extra annotations (like Bean Validation
Annotations) to be able to create/edit endpoints or URI strings so that tools
can generate nicer UIs for configuring endpoints than just letting folks edit
Strings.</li><li><a shape="rect" href="endpointcompleter.html"
title="EndpointCompleter
">EndpointCompleter</a> API provides a hook so that command line tools (like
<a shape="rect" class="external-link"
href="http://karaf.apache.org/manual/latest-2.3.x/users-guide/using-console.html">Karaf's
shell</a>), IDEs and web tools can get (bash tab like) auto-completion on
endpoint paths (such as file or directory names, message queue names, database
table names) when creating or using new endpoints</li><li>Reduced stack-frames
in use during routing, that also makes Camel's stack traces being logged much
less verbose. This also allows people to easier debug the internals of Camel as
less <tt>AsyncCallback</tt> callbacks are in use during routing.</li><li>Easy
to use <a shape="rect" href="message-history.html" title="Message
History">Message History</a> out of the box. And included message history as
"route stack-trace" when exceptions logged by <a shape="rect"
href="error-handler.html" title="Error Handler">Error Handler</a> to make it
easier for end users to spot where
the exception occurred.</li><li><a shape="rect"
href="spring-web-services.html" title="Spring Web Services">Spring Web
Services</a> now supports setting/receiving SOAP headers more easily using a
header on the Camel <a shape="rect" href="message.html"
title="Message">Message</a>.</li><li>Evaluating <a shape="rect"
href="groovy.html" title="Groovy">Groovy</a> expressions is faster as we cache
the compiled scripts.</li><li>Added <tt>base64</tt> option to <a shape="rect"
href="shiro-security.html" title="Shiro Security">Shiro Security</a> to allow
transferring security token over <a shape="rect" href="jms.html"
title="JMS">JMS</a> and other transports as base64 encoded
representation.</li><li>Made it easier to use <a shape="rect"
href="shiro-security.html" title="Shiro Security">Shiro Security</a> as the
credentials can be provided in headers, when sending a message to a secured
route.</li><li><a shape="rect" href="bindy.html" title="Bindy">Bindy</a> now
supports enums.</li><l
i>Added new <a shape="rect" href="backlogdebugger.html"
title="BacklogDebugger">BacklogDebugger</a> to perform live debugging of
messages during routing. The <a shape="rect" href="backlogdebugger.html"
title="BacklogDebugger">BacklogDebugger</a> has JMX API allows tooling to
control the debugger.</li><li>While using the <a shape="rect"
class="external-link" href="http://xircles.codehaus.org/projects/jackson"
rel="nofollow">Jackson library</a> through the <a shape="rect" href="json.html"
title="JSON">JSON</a> Dataformat there's now a <tt>jsonView</tt> attribute you
could make use of directly inside the <a shape="rect" href="dsl.html"
title="DSL">DSL</a> itself.</li><li><a shape="rect" href="smpp.html"
title="SMPP">SMPP</a> now supports optional parameters in all commands where
they are possible.</li><li><a shape="rect" href="jdbc.html"
title="JDBC">JDBC</a> now supports named parameters.</li><li>Added timeout
support for <a shape="rect" href="direct.html" title="Direct">Direc
t</a> producers to wait for consumer to become active.</li><li>Added
<tt>stats</tt> action to <a shape="rect" href="controlbus.html"
title="ControlBus">ControlBus</a> to easily get performance statics in a single
XML message.</li><li>Added support for request timeout on <a shape="rect"
href="netty.html" title="Netty">Netty</a> producer, and to configure logging
level on <a shape="rect" href="netty.html" title="Netty">Netty</a> consumer to
be less noisy for ChannelClosedException which can flood the logs when client
disconnects abruptly.</li><li><a shape="rect" href="springbatch.html"
title="SpringBatch">Spring Batch</a> component producer now returns the
<tt>JobExecution</tt> instance as the output message. Users can use the
<tt>JobExecution</tt> instance to perform some operations using the Spring
Batch API directly.</li><li>Added support for NULL values in <a shape="rect"
href="sql-component.html" title="SQL Component">SQL</a> with named
parameters.</li></ul>
+<ul><li><a shape="rect" href="endpoint-annotations.html" title="Endpoint
Annotations">Endpoint Annotations</a> along with automatically created HTML
documentation for the endpoint parameters; this makes it easier for component
developers to add a few refactoring-safe annotations to their Endpoint or
Consumer implementations and, (along with javadoc comments on the field or
setter method), get nice user documentation on how to use the endpoint for
free.</li><li><a shape="rect" href="componentconfiguration.html"
title="ComponentConfiguration">ComponentConfiguration</a> API provides a handy
API for tools developers to introspect on a Component to find all the possible
parameters, their types and any extra annotations (like Bean Validation
Annotations) to be able to create/edit endpoints or URI strings so that tools
can generate nicer UIs for configuring endpoints than just letting folks edit
Strings.</li><li><a shape="rect" href="endpointcompleter.html"
title="EndpointCompleter
">EndpointCompleter</a> API provides a hook so that command line tools (like
<a shape="rect" class="external-link"
href="http://karaf.apache.org/manual/latest-2.3.x/users-guide/using-console.html">Karaf's
shell</a>), IDEs and web tools can get (bash tab like) auto-completion on
endpoint paths (such as file or directory names, message queue names, database
table names) when creating or using new endpoints</li><li>Reduced stack-frames
in use during routing, that also makes Camel's stack traces being logged much
less verbose. This also allows people to easier debug the internals of Camel as
less <tt>AsyncCallback</tt> callbacks are in use during routing.</li><li>Easy
to use <a shape="rect" href="message-history.html" title="Message
History">Message History</a> out of the box. And included message history as
"route stack-trace" when exceptions logged by <a shape="rect"
href="error-handler.html" title="Error Handler">Error Handler</a> to make it
easier for end users to spot where
the exception occurred.</li><li><a shape="rect"
href="spring-web-services.html" title="Spring Web Services">Spring Web
Services</a> now supports setting/receiving SOAP headers more easily using a
header on the Camel <a shape="rect" href="message.html"
title="Message">Message</a>.</li><li>Evaluating <a shape="rect"
href="groovy.html" title="Groovy">Groovy</a> expressions is faster as we cache
the compiled scripts.</li><li>Added <tt>base64</tt> option to <a shape="rect"
href="shiro-security.html" title="Shiro Security">Shiro Security</a> to allow
transferring security token over <a shape="rect" href="jms.html"
title="JMS">JMS</a> and other transports as base64 encoded
representation.</li><li>Made it easier to use <a shape="rect"
href="shiro-security.html" title="Shiro Security">Shiro Security</a> as the
credentials can be provided in headers, when sending a message to a secured
route.</li><li><a shape="rect" href="bindy.html" title="Bindy">Bindy</a> now
supports enums.</li><l
i>Added new <a shape="rect" href="backlogdebugger.html"
title="BacklogDebugger">BacklogDebugger</a> to perform live debugging of
messages during routing. The <a shape="rect" href="backlogdebugger.html"
title="BacklogDebugger">BacklogDebugger</a> has JMX API allows tooling to
control the debugger.</li><li>While using the <a shape="rect"
class="external-link" href="http://xircles.codehaus.org/projects/jackson"
rel="nofollow">Jackson library</a> through the <a shape="rect" href="json.html"
title="JSON">JSON</a> Dataformat there's now a <tt>jsonView</tt> attribute you
could make use of directly inside the <a shape="rect" href="dsl.html"
title="DSL">DSL</a> itself.</li><li><a shape="rect" href="smpp.html"
title="SMPP">SMPP</a> now supports optional parameters in all commands where
they are possible.</li><li><a shape="rect" href="jdbc.html"
title="JDBC">JDBC</a> now supports named parameters.</li><li>Added timeout
support for <a shape="rect" href="direct.html" title="Direct">Direc
t</a> producers to wait for consumer to become active.</li><li>Added
<tt>stats</tt> action to <a shape="rect" href="controlbus.html"
title="ControlBus">ControlBus</a> to easily get performance statics in a single
XML message.</li><li>Added support for request timeout on <a shape="rect"
href="netty.html" title="Netty">Netty</a> producer, and to configure logging
level on <a shape="rect" href="netty.html" title="Netty">Netty</a> consumer to
be less noisy for ChannelClosedException which can flood the logs when client
disconnects abruptly.</li><li><a shape="rect" href="springbatch.html"
title="SpringBatch">Spring Batch</a> component producer now returns the
<tt>JobExecution</tt> instance as the output message. Users can use the
<tt>JobExecution</tt> instance to perform some operations using the Spring
Batch API directly.</li><li>Added support for NULL values in <a shape="rect"
href="sql-component.html" title="SQL Component">SQL</a> with named
parameters.</li><li>Optimized <a sh
ape="rect" href="jetty.html" title="Jetty">Jetty</a> streaming responses in
non-chunked mode; and as well using buffer sizes based on
<tt>HttpServletResponse.getBufferSize()</tt> instead of fixed size of
4kb.</li><li>Added <tt>greedy</tt> option to <a shape="rect"
href="polling-consumer.html" title="Polling Consumer">scheduled polling
consumer</a>.</li></ul>
<h3><a shape="rect" name="Camel2.12.0Release-FixedIssues"></a>Fixed Issues</h3>
@@ -158,17 +168,23 @@
<h3><a shape="rect"
name="Camel2.12.0Release-GettingtheBinariesusingMaven2"></a>Getting the
Binaries using Maven 2</h3>
<p>To use this release in your maven project, the proper dependency
configuration that you should use in your <a shape="rect" class="external-link"
href="http://maven.apache.org/guides/introduction/introduction-to-the-pom.html">Maven
POM</a> is:</p>
-<div class="error"><span class="error">Unknown macro: {code}</span>
-<p><dependency><br clear="none">
- <groupId>org.apache.camel</groupId><br clear="none">
- <artifactId>camel-core</artifactId><br clear="none">
- <version>2.12.0</version><br clear="none">
-</dependency></p></div>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <version>2.12.0</version>
+</dependency>
+]]></script>
+</div></div>
<h3><a shape="rect" name="Camel2.12.0Release-SVNTagCheckout"></a>SVN Tag
Checkout</h3>
-<div class="error"><span class="error">Unknown macro: {code}</span>
-<p>svn co <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/tags/camel-2.12.0">http://svn.apache.org/repos/asf/camel/tags/camel-2.12.0</a></p></div>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+svn co http://svn.apache.org/repos/asf/camel/tags/camel-2.12.0
+]]></script>
+</div></div>
<h2><a shape="rect" name="Camel2.12.0Release-Changelog"></a>Changelog</h2>
Modified: websites/production/camel/content/polling-consumer.html
==============================================================================
--- websites/production/camel/content/polling-consumer.html (original)
+++ websites/production/camel/content/polling-consumer.html Tue Jun 25 07:18:29
2013
@@ -35,6 +35,17 @@
</style>
<![endif]-->
+
+ <link href='http://camel.apache.org/styles/highlighter/styles/shCore.css'
rel='stylesheet' type='text/css' />
+ <link
href='http://camel.apache.org/styles/highlighter/styles/shThemeEclipse.css'
rel='stylesheet' type='text/css' />
+ <script src='http://camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
+ <script
src='http://camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
+
+ <script type="text/javascript">
+ SyntaxHighlighter.defaults['toolbar'] = false;
+ SyntaxHighlighter.all();
+ </script>
+
<title>
Apache Camel: Polling Consumer
</title>
@@ -52,8 +63,8 @@
<div class="content_r">
<div>
<!-- Banner -->
-<div id="banner-content">
- <div id="asf_logo">
+<div id="banner-content"><p>
+ </p><div id="asf_logo">
<div id="activemq_logo" style="height:108px; background:transparent
url(banner.data/apache-camel-7.png) no-repeat scroll left top;">
<a shape="rect" style="float:left;
width:310px;display:block;text-indent:-5000px;text-decoration:none;line-height:140px;
margin-top:20px; margin-left:18px;" href="http://camel.apache.org/">Camel</a>
<a shape="rect" style="float:right;
width:180px;display:block;text-indent:-5000px;text-decoration:none;line-height:80px;
margin-top:45px; margin-right:10px;" href="http://www.apache.org">Apache</a>
@@ -84,11 +95,11 @@
<p>So in your Java code you can do</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
-Endpoint endpoint = context.getEndpoint(<span
class="code-quote">"activemq:my.queue"</span>);
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+Endpoint endpoint = context.getEndpoint("activemq:my.queue");
PollingConsumer consumer = endpoint.createPollingConsumer();
Exchange exchange = consumer.receive();
-</pre>
+]]></script>
</div></div>
<p>The <tt>ConsumerTemplate</tt> (discussed below) is also available.</p>
@@ -107,82 +118,84 @@ Exchange exchange = consumer.receive();
<p>The template supports the 3 operations above, but also including convenient
methods for returning the body, etc <tt>consumeBody</tt>.<br clear="none">
The example from above using ConsumerTemplate is:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
-Exchange exchange = consumerTemplate.receive(<span
class="code-quote">"activemq:my.queue"</span>);
-</pre>
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+Exchange exchange = consumerTemplate.receive("activemq:my.queue");
+]]></script>
</div></div>
<p>Or to extract and get the body you can do:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
-<span class="code-object">Object</span> body =
consumerTemplate.receiveBody(<span
class="code-quote">"activemq:my.queue"</span>);
-</pre>
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+Object body = consumerTemplate.receiveBody("activemq:my.queue");
+]]></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" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
-<span class="code-object">String</span> body =
consumerTemplate.receiveBody(<span
class="code-quote">"activemq:my.queue"</span>, <span
class="code-object">String</span>.class);
-</pre>
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+String body = consumerTemplate.receiveBody("activemq:my.queue", String.class);
+]]></script>
</div></div>
<p>You get hold of a <tt>ConsumerTemplate</tt> from the <tt>CamelContext</tt>
with the <tt>createConsumerTemplate</tt> operation:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
ConsumerTemplate consumer = context.createConsumerTemplate();
-</pre>
+]]></script>
</div></div>
<h4><a shape="rect"
name="PollingConsumer-UsingConsumerTemplatewithSpringDSL"></a>Using
ConsumerTemplate with Spring DSL</h4>
<p>With the Spring DSL we can declare the consumer in the CamelContext with
the <b>consumerTemplate</b> tag, just like the ProducerTemplate. The example
below illustrates this:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-xml"><span class="code-tag"><camelContext xmlns=<span
class="code-quote">"http://camel.apache.org/schema/spring"</span>></span>
- <span class="code-tag"><span class="code-comment"><!-- define a
producer template --></span></span>
- <span class="code-tag"><template id=<span
class="code-quote">"producer"</span>/></span>
- <span class="code-tag"><span class="code-comment"><!-- define a
consumer template --></span></span>
- <span class="code-tag"><consumerTemplate id=<span
class="code-quote">"consumer"</span>/></span>
+<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+ <!-- define a producer template -->
+ <template id="producer"/>
+ <!-- define a consumer template -->
+ <consumerTemplate id="consumer"/>
- <span class="code-tag"><route></span>
- <span class="code-tag"><from uri=<span
class="code-quote">"seda:foo"</span>/></span>
- <span class="code-tag"><to id=<span
class="code-quote">"result"</span> uri=<span
class="code-quote">"mock:result"</span>/></span>
- <span class="code-tag"></route></span>
-<span class="code-tag"></camelContext></span>
-</pre>
+ <route>
+ <from uri="seda:foo"/>
+ <to id="result" uri="mock:result"/>
+ </route>
+</camelContext>
+]]></script>
</div></div>
<p>Then we can get leverage Spring to inject the <tt>ConsumerTemplate</tt> in
our java class. The code below is part of an unit test but it shows how the
consumer and producer can work together. </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">@ContextConfiguration
-<span class="code-keyword">public</span> class SpringConsumerTemplateTest
<span class="code-keyword">extends</span> SpringRunWithTestSupport {
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+@ContextConfiguration
+public class SpringConsumerTemplateTest extends SpringRunWithTestSupport {
@Autowired
- <span class="code-keyword">private</span> ProducerTemplate producer;
+ private ProducerTemplate producer;
@Autowired
- <span class="code-keyword">private</span> ConsumerTemplate consumer;
+ private ConsumerTemplate consumer;
- @EndpointInject(ref = <span class="code-quote">"result"</span>)
- <span class="code-keyword">private</span> MockEndpoint mock;
+ @EndpointInject(ref = "result")
+ private MockEndpoint mock;
@Test
- <span class="code-keyword">public</span> void testConsumeTemplate() <span
class="code-keyword">throws</span> Exception {
- <span class="code-comment">// we expect Hello World received in our
mock endpoint
-</span> mock.expectedBodiesReceived(<span class="code-quote">"Hello
World"</span>);
-
- <span class="code-comment">// we use the producer template to send a
message to the seda:start endpoint
-</span> producer.sendBody(<span class="code-quote">"seda:start"</span>,
<span class="code-quote">"Hello World"</span>);
-
- <span class="code-comment">// we consume the body from seda:start
-</span> <span class="code-object">String</span> body =
consumer.receiveBody(<span class="code-quote">"seda:start"</span>, <span
class="code-object">String</span>.class);
- assertEquals(<span class="code-quote">"Hello World"</span>, body);
-
- <span class="code-comment">// and then we send the body again to
seda:foo so it will be routed to the mock
-</span> <span class="code-comment">// endpoint so our unit test can
complete
-</span> producer.sendBody(<span class="code-quote">"seda:foo"</span>,
body);
+ public void testConsumeTemplate() throws Exception {
+ // we expect Hello World received in our mock endpoint
+ mock.expectedBodiesReceived("Hello World");
+
+ // we use the producer template to send a message to the seda:start
endpoint
+ producer.sendBody("seda:start", "Hello World");
+
+ // we consume the body from seda:start
+ String body = consumer.receiveBody("seda:start", String.class);
+ assertEquals("Hello World", 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("seda:foo", body);
- <span class="code-comment">// <span class="code-keyword">assert</span>
mock received the body
-</span> mock.assertIsSatisfied();
+ // assert mock received the body
+ mock.assertIsSatisfied();
}
}
-</pre>
+]]></script>
</div></div>
<h4><a shape="rect" name="PollingConsumer-Timerbasedpollingconsumer"></a>Timer
based polling consumer</h4>
@@ -190,51 +203,53 @@ ConsumerTemplate consumer = context.crea
<p>First we setup our route as:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">MyCoolBean cool = <span class="code-keyword">new</span>
MyCoolBean();
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+MyCoolBean cool = new MyCoolBean();
cool.setProducer(template);
cool.setConsumer(consumer);
-from(<span class="code-quote">"timer:<span
class="code-comment">//foo?period=5000"</span>).bean(cool, <span
class="code-quote">"someBusinessLogic"</span>);
-</span>
-from(<span class="code-quote">"activemq:queue.foo"</span>).to(<span
class="code-quote">"mock:result"</span>);
-</pre>
+from("timer://foo?period=5000").bean(cool, "someBusinessLogic");
+
+from("activemq:queue.foo").to("mock:result");
+]]></script>
</div></div>
<p>And then we have out logic in our bean:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java"><span class="code-keyword">public</span> <span
class="code-keyword">static</span> class MyCoolBean {
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+public static class MyCoolBean {
- <span class="code-keyword">private</span> <span
class="code-object">int</span> count;
- <span class="code-keyword">private</span> ConsumerTemplate consumer;
- <span class="code-keyword">private</span> ProducerTemplate producer;
+ private int count;
+ private ConsumerTemplate consumer;
+ private ProducerTemplate producer;
- <span class="code-keyword">public</span> void setConsumer(ConsumerTemplate
consumer) {
- <span class="code-keyword">this</span>.consumer = consumer;
+ public void setConsumer(ConsumerTemplate consumer) {
+ this.consumer = consumer;
}
- <span class="code-keyword">public</span> void setProducer(ProducerTemplate
producer) {
- <span class="code-keyword">this</span>.producer = producer;
+ public void setProducer(ProducerTemplate producer) {
+ this.producer = producer;
}
- <span class="code-keyword">public</span> void someBusinessLogic() {
- <span class="code-comment">// loop to empty queue
-</span> <span class="code-keyword">while</span> (<span
class="code-keyword">true</span>) {
- <span class="code-comment">// receive the message from the queue,
wait at most 3 sec
-</span> <span class="code-object">String</span> msg =
consumer.receiveBody(<span class="code-quote">"activemq:queue.inbox"</span>,
3000, <span class="code-object">String</span>.class);
- <span class="code-keyword">if</span> (msg == <span
class="code-keyword">null</span>) {
- <span class="code-comment">// no more messages in queue
-</span> <span class="code-keyword">break</span>;
+ 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;
}
- <span class="code-comment">// <span class="code-keyword">do</span>
something with body
-</span> msg = <span class="code-quote">"Hello "</span> + msg;
+ // do something with body
+ msg = "Hello " + msg;
- <span class="code-comment">// send it to the next queue
-</span> producer.sendBodyAndHeader(<span
class="code-quote">"activemq:queue.foo"</span>, msg, <span
class="code-quote">"number"</span>, count++);
+ // send it to the next queue
+ producer.sendBodyAndHeader("activemq:queue.foo", msg, "number",
count++);
}
}
}
-</pre>
+]]></script>
</div></div>
@@ -258,7 +273,7 @@ from(<span class="code-quote">"activemq:
<div class="confluenceTableSmall"><div class="table-wrap">
<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"> Option </th><th colspan="1" rowspan="1"
class="confluenceTh"> Default </th><th colspan="1" rowspan="1"
class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>pollStrategy</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"><ul class="alternate" type="square"><li></li></ul>
-</td><td colspan="1" rowspan="1" class="confluenceTd"> A pluggable
<tt>org.apache.camel.PollingConsumerPollingStrategy</tt> allowing you to
provide your custom implementation to control error handling usually occurred
during the <tt>poll</tt> operation <b>before</b> an <a shape="rect"
href="exchange.html" title="Exchange">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 <tt>WARN</tt> level and ignore it. </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>sendEmptyMessageWhenIdle</tt>
</td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9:</b> If the polling
consumer did not poll any files, you can enable this option to send an empty
message (n
o body) instead. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>startScheduler</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> Whether the scheduler should be auto started.
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>initialDelay</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>1000</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
Milliseconds before the first poll starts. </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>delay</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>500</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> Milliseconds before the next poll. </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>useFixedDelay</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1"
rowspan="1" class="confluenceTd"> Controls if fixed dela
y 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 <b>Camel
2.7.x</b> or older the default value is <tt>false</tt>. From <b>Camel 2.8</b>
onwards the default value is <tt>true</tt>. </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> timeUnit </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>TimeUnit.MILLISECONDS</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> time unit for <tt>initialDelay</tt> and
<tt>delay</tt> options. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>runLoggingLevel</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>TRACE</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <b>Camel 2.8:</b> The consumer logs a start/complete log
line when it polls. This option allows you to configure the logging level for
that. </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>scheduledExecutorService</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>null</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <b>Camel 2.10:</b> 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. </td></tr></tbody></table>
+</td><td colspan="1" rowspan="1" class="confluenceTd"> A pluggable
<tt>org.apache.camel.PollingConsumerPollingStrategy</tt> allowing you to
provide your custom implementation to control error handling usually occurred
during the <tt>poll</tt> operation <b>before</b> an <a shape="rect"
href="exchange.html" title="Exchange">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 <tt>WARN</tt> level and ignore it. </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>sendEmptyMessageWhenIdle</tt>
</td><td colspan="1" rowspan="1" class="confluenceTd"> <tt>false</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> <b>Camel 2.9:</b> If the polling
consumer did not poll any files, you can enable this option to send an empty
message (n
o body) instead. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>startScheduler</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>true</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> Whether the scheduler should be auto started.
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">
<tt>initialDelay</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
<tt>1000</tt> </td><td colspan="1" rowspan="1" class="confluenceTd">
Milliseconds before the first poll starts. </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>delay</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>500</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> Milliseconds before the next poll. </td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"> <tt>useFixedDelay</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> </td><td colspan="1"
rowspan="1" class="confluenceTd"> Controls if fixed dela
y 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 <b>Camel
2.7.x</b> or older the default value is <tt>false</tt>. From <b>Camel 2.8</b>
onwards the default value is <tt>true</tt>. </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>timeUnit</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>TimeUnit.MILLISECONDS</tt> </td><td
colspan="1" rowspan="1" class="confluenceTd"> time unit for
<tt>initialDelay</tt> and <tt>delay</tt> options. </td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>runLoggingLevel</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>TRACE</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <b>Camel 2.8:</b> The consumer logs a
start/complete log line when it polls. This option allows you to configure the
logging
level for that. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>scheduledExecutorService</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <tt>null</tt> </td><td colspan="1"
rowspan="1" class="confluenceTd"> <b>Camel 2.10:</b> 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. </td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>greedy</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <tt>false</tt> </td><td colspan="1" rowspan="1"
class="confluenceTd"> <b>Camel 2.10.6/2.11.1:</b> If greedy is enabled, then
the ScheduledPollConsumer will run immediately again, if the previous run
polled 1 or more messages. </td></tr></tbody></table>
</div>
</div>
@@ -291,25 +306,25 @@ from(<span class="code-quote">"activemq:
<p>For instance if we want to provide a retry feature to a scheduled consumer
we can implement the <tt>PollingConsumerPollStrategy</tt> method and put the
retry logic in the <tt>rollback</tt> method. Lets just retry up till 3
times:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
- <span class="code-keyword">public</span> <span
class="code-object">boolean</span> rollback(Consumer consumer, Endpoint
endpoint, <span class="code-object">int</span> retryCounter, Exception e) <span
class="code-keyword">throws</span> Exception {
- <span class="code-keyword">if</span> (retryCounter < 3) {
- <span class="code-comment">// <span
class="code-keyword">return</span> <span class="code-keyword">true</span> to
tell Camel that it should retry the poll immediately
-</span> <span class="code-keyword">return</span> <span
class="code-keyword">true</span>;
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+ public boolean rollback(Consumer consumer, Endpoint endpoint, int
retryCounter, Exception e) throws Exception {
+ if (retryCounter < 3) {
+ // return true to tell Camel that it should retry the poll
immediately
+ return true;
}
- <span class="code-comment">// okay we give up <span
class="code-keyword">do</span> not retry anymore
-</span> <span class="code-keyword">return</span> <span
class="code-keyword">false</span>;
+ // okay we give up do not retry anymore
+ return false;
}
-</pre>
+]]></script>
</div></div>
<p>Notice that we are given the <tt>Consumer</tt> 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" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
- <span class="code-comment">// error occurred lets restart the consumer,
that could maybe resolve the issue
-</span> consumer.stop();
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+ // error occurred lets restart the consumer, that could maybe resolve the
issue
+ consumer.stop();
consumer.start();
-</pre>
+]]></script>
</div></div>
<p><b>Notice:</b> If you implement the <tt>begin</tt> operation make sure to
avoid throwing exceptions as in such a case the <tt>poll</tt> operation is not
invoked and Camel will invoke the <tt>rollback</tt> directly.</p>
@@ -317,9 +332,9 @@ from(<span class="code-quote">"activemq:
<h4><a shape="rect"
name="PollingConsumer-ConfiguringanEndpointtouse%7B%7BPollingConsumerPollStrategy%7D%7D"></a>Configuring
an <a shape="rect" href="endpoint.html" title="Endpoint">Endpoint</a> to use
<tt>PollingConsumerPollStrategy</tt></h4>
<p>To configure an <a shape="rect" href="endpoint.html"
title="Endpoint">Endpoint</a> to use a custom
<tt>PollingConsumerPollStrategy</tt> you use the option <tt>pollStrategy</tt>.
For example in the file consumer below we want to use our custom strategy
defined in the <a shape="rect" href="registry.html"
title="Registry">Registry</a> with the bean id <tt>myPoll</tt>:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<pre class="code-java">
- from(<span class="code-quote">"file:<span
class="code-comment">//inbox/?pollStrategy=#myPoll"</span>).to(<span
class="code-quote">"activemq:queue:inbox"</span>)</span>
-</pre>
+<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+ from("file://inbox/?pollStrategy=#myPoll").to("activemq:queue:inbox")
+]]></script>
</div></div>
<h4><a shape="rect" name="PollingConsumer-UsingThisPattern"></a>Using This
Pattern</h4>
@@ -346,8 +361,8 @@ from(<span class="code-quote">"activemq:
<h3><a shape="rect" name="Navigation-Search"></a>Search</h3>
-
-<form enctype="application/x-www-form-urlencoded" method="get"
id="cse-search-box" action="http://www.google.com/cse">
+<p>
+</p><form enctype="application/x-www-form-urlencoded" method="get"
id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="007878419884033443453:m5nhvy4hmyq">
<input type="hidden" name="ie" value="UTF-8">