You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2015/07/08 09:21:06 UTC
svn commit: r957484 [1/3] - in /websites/production/camel/content:
book-component-appendix.html book-in-one-page.html cache/main.pageCache
jt400.html
Author: buildbot
Date: Wed Jul 8 07:21:05 2015
New Revision: 957484
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/book-component-appendix.html
websites/production/camel/content/book-in-one-page.html
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/jt400.html
Modified: websites/production/camel/content/book-component-appendix.html
==============================================================================
--- websites/production/camel/content/book-component-appendix.html (original)
+++ websites/production/camel/content/book-component-appendix.html Wed Jul 8 07:21:05 2015
@@ -101,33 +101,33 @@
<h3 id="BookComponentAppendix-URIformat">URI format</h3>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
activemq:[queue:|topic:]destinationName
-</pre>
+]]></script>
</div></div>
<p>Where <strong>destinationName</strong> is an ActiveMQ queue or topic name. By default, the <strong>destinationName</strong> is interpreted as a queue name. For example, to connect to the queue, <code>FOO.BAR</code>, use:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
activemq:FOO.BAR
-</pre>
+]]></script>
</div></div>
<p>You can include the optional <code>queue:</code> prefix, if you prefer:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
activemq:queue:FOO.BAR
-</pre>
+]]></script>
</div></div>
<p>To connect to a topic, you must include the <code>topic:</code> prefix. For example, to connect to the topic, <code>Stocks.Prices</code>, use:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
activemq:topic:Stocks.Prices
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-Options">Options</h3>
@@ -138,9 +138,9 @@ activemq:topic:Stocks.Prices
<p>This <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java">test case</a> shows how to add an ActiveMQComponent to the <a shape="rect" href="camelcontext.html">CamelContext</a> using the <a shape="rect" class="external-link" href="http://activemq.apache.org/maven/5.5.0/activemq-camel/apidocs/org/apache/activemq/camel/component/ActiveMQComponent.html#activeMQComponent%28java.lang.String%29"><code>activeMQComponent()</code> method</a> while specifying the <a shape="rect" class="external-link" href="http://activemq.apache.org/configuring-transports.html">brokerURL</a> used to connect to ActiveMQ. </p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false"));
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false"));
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-ConfiguringtheConnectionFactoryusingSpringXML">Configuring the Connection Factory using Spring XML</h3>
@@ -148,25 +148,25 @@ camelContext.addComponent("activemq", ac
<p>You can configure the ActiveMQ broker URL on the ActiveMQComponent as follows</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring
- http://camel.apache.org/schema/spring/camel-spring.xsd">
+ http://camel.apache.org/schema/spring/camel-spring.xsd">
- <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
</camelContext>
- <bean id="activemq"
- class="org.apache.activemq.camel.component.ActiveMQComponent">
- <property name="brokerURL" value="tcp://somehost:61616"/>
+ <bean id="activemq"
+ class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="brokerURL" value="tcp://somehost:61616"/>
</bean>
</beans>
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-Usingconnectionpooling">Using connection pooling</h3>
@@ -175,46 +175,46 @@ camelContext.addComponent("activemq", ac
<p>You can grab ActiveMQ's <code>org.apache.activemq.pool.PooledConnectionFactory</code> with Maven:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.6.0</version>
</dependency>
-</pre>
+]]></script>
</div></div>
<p>And then setup the <strong>activemq</strong> Camel component as follows:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
-<bean id="jmsConnectionFactory"
- class="org.apache.activemq.ActiveMQConnectionFactory">
- <property name="brokerURL" value="tcp://localhost:61616" />
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+<bean id="jmsConnectionFactory"
+ class="org.apache.activemq.ActiveMQConnectionFactory">
+ <property name="brokerURL" value="tcp://localhost:61616" />
</bean>
-<bean id="pooledConnectionFactory"
- class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
- <property name="maxConnections" value="8" />
- <property name="connectionFactory" ref="jmsConnectionFactory" />
+<bean id="pooledConnectionFactory"
+ class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
+ <property name="maxConnections" value="8" />
+ <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>
-<bean id="jmsConfig"
- class="org.apache.camel.component.jms.JmsConfiguration">
- <property name="connectionFactory" ref="pooledConnectionFactory"/>
- <property name="concurrentConsumers" value="10"/>
+<bean id="jmsConfig"
+ class="org.apache.camel.component.jms.JmsConfiguration">
+ <property name="connectionFactory" ref="pooledConnectionFactory"/>
+ <property name="concurrentConsumers" value="10"/>
</bean>
-<bean id="activemq"
- class="org.apache.activemq.camel.component.ActiveMQComponent">
- <property name="configuration" ref="jmsConfig"/>
+<bean id="activemq"
+ class="org.apache.activemq.camel.component.ActiveMQComponent">
+ <property name="configuration" ref="jmsConfig"/>
<!-- if we are using transacted then enable CACHE_CONSUMER (if not using XA) to run faster
see more details at: http://camel.apache.org/jms
- <property name="transacted" value="true"/>
- <property name="cacheLevelName" value="CACHE_CONSUMER" />
+ <property name="transacted" value="true"/>
+ <property name="cacheLevelName" value="CACHE_CONSUMER" />
-->
</bean>
-</pre>
+]]></script>
</div></div>
<div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body">
@@ -232,21 +232,21 @@ camelContext.addComponent("activemq", ac
<p>So for example you can create a MessageListener in JMS like this:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
public class MyListener implements MessageListener {
public void onMessage(Message jmsMessage) {
// ...
}
}
-</pre>
+]]></script>
</div></div>
<p>Then use it in your Camel route as follows</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-from("file://foo/bar").
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+from("file://foo/bar").
bean(MyListener.class);
-</pre>
+]]></script>
</div></div>
<p>That is, you can reuse any of the Camel <a shape="rect" href="components.html">Components</a> and easily integrate them into your JMS <code>MessageListener</code> POJO!</p>
@@ -280,16 +280,16 @@ from("file://foo/bar").
<p>The below route starts by reading the topic <em>ActiveMQ.Advisory.Connection</em>. To watch another topic, simply change the name according to the name provided in ActiveMQ Advisory Messages documentation. The parameter mapJmsMessage=false allows for converting the org.apache.activemq.command.ActiveMqMessage object from the jms queue. Next, the body received is converted into a String for the purposes of this example and a carriage return is added. Finally, the string is added to a file</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
<route>
- <from uri="activemq:topic:ActiveMQ.Advisory.Connection?mapJmsMessage=false" />
- <convertBodyTo type="java.lang.String"/>
+ <from uri="activemq:topic:ActiveMQ.Advisory.Connection?mapJmsMessage=false" />
+ <convertBodyTo type="java.lang.String"/>
<transform>
<simple>${in.body}&#13;</simple>
</transform>
- <to uri="file://data/activemq/?fileExist=Append&amp;fileName=advisoryConnection-${date:now:yyyyMMdd}.txt" />
+ <to uri="file://data/activemq/?fileExist=Append&amp;fileName=advisoryConnection-${date:now:yyyyMMdd}.txt" />
</route>
-</pre>
+]]></script>
</div></div>
<p>If you consume a message on a queue, you should see the following files under the data/activemq folder :</p>
@@ -300,7 +300,7 @@ advisoryProducer-20100312.txt</p>
<p>and containing string:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
ActiveMQMessage {commandId = 0, responseRequired = false,
messageId = ID:dell-charles-3258-1268399815140
-1:0:0:0:221, originalDestination = null, originalTransactionId = null,
@@ -319,7 +319,7 @@ clientMaster = true}, redeliveryCounter
{originBrokerName=master, originBrokerId=ID:dell-charles-3258-1268399815140-0:0,
originBrokerURL=vm://master}, readOnlyProperties = true, readOnlyBody = true,
droppable = false}
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-GettingComponentJAR">Getting Component JAR</h3>
@@ -331,67 +331,67 @@ droppable = false}
<p><a shape="rect" href="activemq.html">ActiveMQ</a> is an extension of the <a shape="rect" href="jms.html">JMS</a> component released with the <a shape="rect" class="external-link" href="http://activemq.apache.org">ActiveMQ project</a>.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.6.0</version>
</dependency>
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-SeeAlso">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul> <div class="error"><span class="error">Unable to render {include}</span> The included page could not be found.</div> <h2 id="BookComponentAppendix-AMQP">AMQP</h2><p><strong>Available as of Camel X.X</strong></p><p>The <strong>amqp:</strong> component supports the <a shape="rect" class="external-link" href="http://www.amqp.org/" rel="nofollow">AMQP protocol</a> using the Client API of the <a shape="rect" class="external-link" href="http://qpid.apache.org/">Qpid</a> project. In case you want to use AMQP with RabbitMQ you might also be interested in the <a shape="rect" href="rabbitmq.html">Camel RabbitMQ</a> component.</p><p>Maven users will need to add the following dependency to their <code>pom.xml</code> for thi
s component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency>
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-amqp</artifactId>
<version>${camel.version}</version> <!-- use the same version as your Camel core version -->
</dependency>
-</pre>
+]]></script>
</div></div><h3 id="BookComponentAppendix-URIformat.1">URI format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">amqp:[queue:|topic:]destinationName[?options]
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[amqp:[queue:|topic:]destinationName[?options]
+]]></script>
</div></div><h3 id="BookComponentAppendix-AMQPOptions">AMQP Options</h3><p>You can specify all of the various configuration options of the <a shape="rect" href="jms.html">JMS</a> component after the destination name.</p><h3 id="BookComponentAppendix-Usingtopics">Using topics</h3><p>To have using topics working with camel-amqp you need to configure the component to use "topic://" as topic prefix, as shown below</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <bean id="amqpConnection" class="org.apache.camel.component.jms.JmsComponent" >
- <property name="connectionFactory">
- <bean class="org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl" factory-method="createFromURL">
- <constructor-arg index="0" type="java.lang.String" value="amqp://localhost:5672" />
- <property name="topicPrefix" value="topic://" /> <!-- only necessary when connecting to ActiveMQ over AMQP 1.0 -->
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ <bean id="amqpConnection" class="org.apache.camel.component.jms.JmsComponent" >
+ <property name="connectionFactory">
+ <bean class="org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl" factory-method="createFromURL">
+ <constructor-arg index="0" type="java.lang.String" value="amqp://localhost:5672" />
+ <property name="topicPrefix" value="topic://" /> <!-- only necessary when connecting to ActiveMQ over AMQP 1.0 -->
</bean>
</property>
- </bean></pre>
+ </bean>]]></script>
</div></div><p> </p><p> </p><p></p><h3 id="BookComponentAppendix-SeeAlso.1">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul> <h2 id="BookComponentAppendix-SQSComponent">SQS Component</h2><p><strong>Available as of Camel 2.6</strong></p><p>The sqs component supports sending and receiving messages to <a shape="rect" class="external-link" href="http://aws.amazon.com/sqs" rel="nofollow">Amazon's SQS</a> service.</p><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Prerequisites</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>You must have a valid Amazon Web Services developer account, and be signed up to use Amazon SQS. More information are available at <a shape="rect" class="external-link
" href="http://aws.amazon.com/sqs" rel="nofollow">Amazon SQS</a>.</p></div></div><h3 id="BookComponentAppendix-URIFormat">URI Format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">aws-sqs://queue-name[?options]
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[aws-sqs://queue-name[?options]
+]]></script>
</div></div><p>The queue will be created if they don't already exists.<br clear="none"> You can append query options to the URI in the following format, ?options=value&option2=value&...</p><h3 id="BookComponentAppendix-URIOptions">URI Options</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Context</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>amazonSQSClient</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Reference to a <code>com.amazonaws.services.sqs.AmazonSQS</code> in the <a shape="rect" href="registry.html">Regist
ry</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>accessKey</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Amazon AWS Access Key</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>secretKey</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Amazon AWS Secret Key</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>amazonSQSEndpoint</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The region with which the AWS-SQS client wants to work with. Only works if Camel crea
tes the AWS-SQS client, i.e., if you explicitly set amazonSQSClient, then this setting will have no effect. You would have to set it on the client you create directly</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>attributeNames</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>A list of attributes to set in the <code>com.amazonaws.services.sqs.model.ReceiveMessageRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">concurrentConsumers</td><td colspan="1" rowspan="1" class="confluenceTd">1</td><td colspan="1" rowspan="1" class="confluenceTd">Consumer</td><td colspan="1" rowspan="1" class="confluenceTd">(<strong>as of 2.15.0</strong>) Allows you to use multiple threads to poll the sqs queue to increase throughput</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>de
faultVisibilityTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The visibility timeout (in seconds) to set in the <code>com.amazonaws.services.sqs.model.CreateQueueRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>deleteAfterRead</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Delete message from SQS after it has been read</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>deleteIfFiltered</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12.2,
2.13.0</strong> Whether or not to send the DeleteMessage to the SQS queue if an exchange fails to get through a filter. If 'false' and exchange does not make it through a Camel filter upstream in the route, then don't send DeleteMessage.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>maxMessagesPerPoll</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The maximum number of messages which can be received in one poll to set in the <code>com.amazonaws.services.sqs.model.ReceiveMessageRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>visibilityTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The duration (in seconds
) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request to set in the <code>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</code>. This only make sense if its different from <code>defaultVisibilityTimeout</code>. It changes the queue visibility timeout attribute permanently.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>messageVisibilityTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a ReceiveMessage request to set in the <code>com.amazonaws.services.sqs.model.ReceiveMessageRequest</code>. It does <strong>NOT</strong> change the queue visibility timeout attribute perman
ently.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>extendMessageVisibility</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Consumer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> If enabled then a scheduled background task will keep extending the message visibility on SQS. This is needed if it taks a long time to process the message. If set to true <code>defaultVisibilityTimeout</code> must be set. See details at <a shape="rect" class="external-link" href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Query_QueryChangeMessageVisibility.html" rel="nofollow">Amazon docs</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>maximumMessageSize</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sha
red</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The maximumMessageSize (in bytes) an SQS message can contain for this queue, to set in the <code>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>messageRetentionPeriod</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The messageRetentionPeriod (in seconds) a message will be retained by SQS for this queue, to set in the <code>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>policy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspa
n="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> The policy for this queue to set in the <code>com.amazonaws.services.sqs.model.SetQueueAttributesRequest</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>delaySeconds</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Producer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9.3:</strong> Delay sending messages for a number of seconds.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>waitTimeSeconds</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Producer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> Duration in seconds (0 to 20) that the ReceiveMessage action call will wait until a message is in the queue to include in the res
ponse.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>receiveMessageWaitTimeSeconds</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> If you do not specify WaitTimeSeconds in the request, the queue attribute ReceiveMessageWaitTimeSeconds is used to determine how long to wait.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>queueOwnerAWSAccountId</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> Specify the queue owner aws account id when you need to connect the queue with different account owner.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>region</p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Shared</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12.3:</strong> Specify the queue region which could be used with <code>queueOwnerAWSAccountId</code> to build the service URL.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>redrivePolicy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><code>null</code></td><td colspan="1" rowspan="1" class="confluenceTd">Shared</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15</strong>: Specify the policy that send message to DeadLetter queue. See detail at <a shape="rect" class="external-link" href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues-redrivepolicy.html" rel="nofollow">Amazon docs</a>.</td></tr></tbody></table></div><div class="confluence-information-macro confluence-information-macro-inf
ormation"><p class="title">Required SQS component options</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>You have to provide the amazonSQSClient in the <a shape="rect" href="registry.html">Registry</a> or your accessKey and secretKey to access the <a shape="rect" class="external-link" href="http://aws.amazon.com/sqs" rel="nofollow">Amazon's SQS</a>.</p></div></div><h3 id="BookComponentAppendix-BatchConsumer">Batch Consumer</h3><p>This component implements the <a shape="rect" href="batch-consumer.html">Batch Consumer</a>.</p><p>This allows you for instance to know how many messages exists in this batch and for instance let the <a shape="rect" href="aggregator.html">Aggregator</a> aggregate this number of messages.</p><h3 id="BookComponentAppendix-Usage">Usage</h3><h4 id="BookComponentAppendix-MessageheaderssetbytheSQSproducer">Message headers set by the SQS producer</h4><div class="
table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsMD5OfBody</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The MD5 checksum of the Amazon SQS message.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsMessageId</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The Amazon SQS message ID.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsDelaySeconds</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Integer</code></p>
</td><td colspan="1" rowspan="1" class="confluenceTd"><p>Since <strong>Camel 2.11</strong>, the delay seconds that the Amazon SQS message can be see by others.</p></td></tr></tbody></table></div><h4 id="BookComponentAppendix-MessageheaderssetbytheSQSconsumer">Message headers set by the SQS consumer</h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsMD5OfBody</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The MD5 checksum of the Amazon SQS message.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsMessageId</code></p></td><td colspan="1" rowspan="1" class
="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The Amazon SQS message ID.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsReceiptHandle</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The Amazon SQS message receipt handle.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelAwsSqsAttributes</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Map<String, String></code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The Amazon SQS message attributes.</p></td></tr></tbody></table></div><h4 id="BookComponentAppendix-AdvancedAmazonSQSconfiguration">Advanced AmazonSQS configuration</h4><p>If your Camel Application is running behind a firewall or if you need to have more control over the AmazonSQS instance configuration, you can create y
our own instance:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[AWSCredentials awsCredentials = new BasicAWSCredentials("myAccessKey", "mySecretKey");
ClientConfiguration clientConfiguration = new ClientConfiguration();
-clientConfiguration.setProxyHost("http://myProxyHost");
+clientConfiguration.setProxyHost("http://myProxyHost");
clientConfiguration.setProxyPort(8080);
AmazonSQS client = new AmazonSQSClient(awsCredentials, clientConfiguration);
-registry.bind("client", client);
-</pre>
+registry.bind("client", client);
+]]></script>
</div></div><p>and refer to it in your Camel aws-sqs component configuration:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("aws-sqs://MyQueue?amazonSQSClient=#client&delay=5000&maxMessagesPerPoll=5")
-.to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("aws-sqs://MyQueue?amazonSQSClient=#client&delay=5000&maxMessagesPerPoll=5")
+.to("mock:result");
+]]></script>
</div></div><h3 id="BookComponentAppendix-Dependencies">Dependencies</h3><p>Maven users will need to add the following dependency to their pom.xml.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>pom.xml</b></div><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency>
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws</artifactId>
<version>${camel-version}</version>
</dependency>
-</pre>
+]]></script>
</div></div><p>where <code>${camel-version</code>} must be replaced by the actual version of Camel (2.6 or higher).</p><h3 id="BookComponentAppendix-JMS-styleSelectors">JMS-style Selectors</h3><p>SQS does not allow selectors, but you can effectively achieve this by using the <a shape="rect" href="message-filter.html">Camel Filter EIP</a> and setting an appropriate <code>visibilityTimeout</code>. When SQS dispatches a message, it will wait up to the visibility timeout before it will try to dispatch the message to a different consumer unless a DeleteMessage is received. By default, Camel will always send the DeleteMessage at the end of the route, unless the route ended in failure. To achieve appropriate filtering and not send the DeleteMessage even on successful completion of the route, use a Filter:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("aws-sqs://MyQueue?amazonSQSClient=#client&defaultVisibilityTimeout=5000&deleteIfFiltered=false")
-.filter("${header.login} == true")
-.to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("aws-sqs://MyQueue?amazonSQSClient=#client&defaultVisibilityTimeout=5000&deleteIfFiltered=false")
+.filter("${header.login} == true")
+.to("mock:result");
+]]></script>
</div></div><p>In the above code, if an exchange doesn't have an appropriate header, it will not make it through the filter AND also not be deleted from the SQS queue. After 5000 miliseconds, the message will become visible to other consumers.</p><p></p><h3 id="BookComponentAppendix-SeeAlso.2">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul><ul class="alternate"><li><a shape="rect" href="aws.html">AWS Component</a></li></ul> <h2 id="BookComponentAppendix-AtomComponent">Atom Component</h2>
@@ -402,22 +402,22 @@ registry.bind("client", client);
<p>Maven users will need to add the following dependency to their <code>pom.xml</code> for this component:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-atom</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-URIformat.2">URI format</h3>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
atom://atomUri[?options]
-</pre>
+]]></script>
</div></div>
<p>Where <strong>atomUri</strong> is the URI to the Atom feed to poll. </p>
@@ -447,9 +447,9 @@ atom://atomUri[?options]
<h3 id="BookComponentAppendix-Samples">Samples</h3>
<p>In this sample we poll James Strachan's blog.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
-from("atom://http://macstrac.blogspot.com/feeds/posts/default").to("seda:feeds");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+from("atom://http://macstrac.blogspot.com/feeds/posts/default").to("seda:feeds");
+]]></script>
</div></div>
<p>In this sample we want to filter only good blogs we like to a SEDA queue. The sample also shows how to setup Camel standalone, not running in any Container or using Spring.</p>
@@ -557,9 +557,9 @@ public class BlogService {
<h3 id="BookComponentAppendix-URIformat.3">URI format</h3>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
bean:beanID[?options]
-</pre>
+]]></script>
</div></div>
<p>Where <strong>beanID</strong> can be any string which is used to look up the bean in the <a shape="rect" href="registry.html">Registry</a></p>
@@ -613,12 +613,12 @@ assertEquals("Good Bye!", rc);
<p>And the same route using Spring DSL:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
<route>
- <from uri="direct:hello">
- <to uri="bean:bye"/>
+ <from uri="direct:hello">
+ <to uri="bean:bye"/>
</route>
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-Beanasendpoint">Bean as endpoint</h3>
@@ -655,30 +655,30 @@ public class ExampleBean {
<p>Java DSL comes with syntactic sugar for the <a shape="rect" href="bean.html">Bean</a> component. Instead of specifying the bean explicitly as the endpoint (i.e. <code>to("bean:beanName")</code>) you can use the following syntax:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
// Send message to the bean endpoint
// and invoke method resolved using Bean Binding.
-from("direct:start").beanRef("beanName");
+from("direct:start").beanRef("beanName");
// Send message to the bean endpoint
// and invoke given method.
-from("direct:start").beanRef("beanName", "methodName");
-</pre>
+from("direct:start").beanRef("beanName", "methodName");
+]]></script>
</div></div>
<p>Instead of passing name of the reference to the bean (so that Camel will lookup for it in the registry), you can specify the bean itself:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
// Send message to the given bean instance.
-from("direct:start").bean(new ExampleBean());
+from("direct:start").bean(new ExampleBean());
// Explicit selection of bean method to be invoked.
-from("direct:start").bean(new ExampleBean(), "methodName");
+from("direct:start").bean(new ExampleBean(), "methodName");
// Camel will create the instance of bean and cache it for you.
-from("direct:start").bean(ExampleBean.class);
-</pre>
+from("direct:start").bean(ExampleBean.class);
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-BeanBinding">Bean Binding</h3>
@@ -695,9 +695,9 @@ from("direct:start").bean(ExampleBean.cl
<h3 id="BookComponentAppendix-URIformat.4">URI format</h3>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
browse:someName[?options]
-</pre>
+]]></script>
</div></div>
<p>Where <strong>someName</strong> can be any string to uniquely identify the endpoint.</p>
@@ -705,19 +705,19 @@ browse:someName[?options]
<h3 id="BookComponentAppendix-Sample">Sample</h3>
<p>In the route below, we insert a <code>browse:</code> component to be able to browse the Exchanges that are passing through:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
- from("activemq:order.in").to("browse:orderReceived").to("bean:processOrder");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+ from("activemq:order.in").to("browse:orderReceived").to("bean:processOrder");
+]]></script>
</div></div>
<p>We can now inspect the received exchanges from within the Java code:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
private CamelContext context;
public void inspectRecievedOrders() {
- BrowsableEndpoint browse = context.getEndpoint("browse:orderReceived", BrowsableEndpoint.class);
+ BrowsableEndpoint browse = context.getEndpoint("browse:orderReceived", BrowsableEndpoint.class);
List<Exchange> exchanges = browse.getExchanges();
...
// then we can inspect the list of received exchanges from Java
@@ -726,77 +726,77 @@ browse:someName[?options]
...
}
}
-</pre>
+]]></script>
</div></div>
<h3 id="BookComponentAppendix-SeeAlso.5">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul> <h2 id="BookComponentAppendix-CacheComponent">Cache Component</h2><p><strong>Available as of Camel 2.1</strong></p><p>The <strong>cache</strong> component enables you to perform caching operations using EHCache as the Cache Implementation. The cache itself is created on demand or if a cache of that name already exists then it is simply utilized with its original settings.</p><p>This component supports producer and event based consumer endpoints.</p><p>The Cache consumer is an event based consumer and can be used to listen and respond to specific cache activities. If you need to perform selections from a pre-existing cache, use the processors defined for the cache component.</p><p>Maven users will need to add the
following dependency to their <code>pom.xml</code> for this component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency>
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cache</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-</pre>
+]]></script>
</div></div><h3 id="BookComponentAppendix-URIformat.5">URI format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">cache://cacheName[?options]
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[cache://cacheName[?options]
+]]></script>
</div></div><p>You can append query options to the URI in the following format, <code>?option=value&option=#beanRef&...</code></p><h3 id="BookComponentAppendix-Options.3">Options</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>maxElementsInMemory</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The number of elements that may be stored in the defined cache</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>memoryStoreEvictionPolicy</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>MemoryStoreEvictionPolicy.LFU</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The number of elements that may be stored in the defined cache. Options include</p><ul class="alternate"><li>MemoryStoreEvictionPolicy.LFU - Least frequently used</li><li>MemoryStoreEvictionPolicy.LRU - Least recently used</li><li>MemoryStoreEvictionPolicy.FIFO - first in first out, the oldest element by creation time</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>overflowToDisk</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies whether cache may overflow to disk</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>eternal</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets whether elements are eternal. If eternal, timeouts are ignored and the<br clear="none" class="atl-forced-newline"> eleme
nt never expires.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>timeToLiveSeconds</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>300</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The maximum time between creation time and when an element expires.<br clear="none" class="atl-forced-newline"> Is used only if the element is not eternal</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>timeToIdleSeconds</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>300</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The maximum amount of time between accesses before an element expires</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>diskPersistent</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether the disk store persists between rest
arts of the Virtual Machine.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>diskExpiryThreadIntervalSeconds</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>120</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The number of seconds between runs of the disk expiry thread.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>cacheManagerFactory</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.8:</strong> If you want to use a custom factory which instantiates and creates the EHCache <code>net.sf.ehcache.CacheManager</code>. <br clear="none" class="atl-forced-newline"> <br clear="none" class="atl-forced-newline"> <em>Type:</em> abstract org.apache.camel.component.cache.CacheManagerFactory</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>eventListenerRegistry</c
ode></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.8:</strong> Sets a list of EHCache <code>net.sf.ehcache.event.CacheEventListener</code> for all new caches- no need to define it per cache in EHCache xml config anymore. <br clear="none" class="atl-forced-newline"> <br clear="none" class="atl-forced-newline"> <em>Type:</em> org.apache.camel.component.cache.CacheEventListenerRegistry</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>cacheLoaderRegistry</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.8:</strong> Sets a list of <code>org.apache.camel.component.cache.CacheLoaderWrapper</code> that extends EHCache <code>net.sf.ehcache.loader.CacheLoader</code> for all new caches- no need to define it per cache in EHCache xml config anymore. <br c
lear="none" class="atl-forced-newline"> <br clear="none" class="atl-forced-newline"> <em>Type:</em> org.apache.camel.component.cache.CacheLoaderRegistry</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>key</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> To configure using a cache key by default. If a key is provided in the message header, then the key from the header takes precedence.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>operation</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> To configure using an cache operation by default. If an operation in the message header, then the operation from the header takes precedence.</p></td></tr><tr><td colspan="1" rowspan="1" class="conf
luenceTd"><code>objectCache</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15:</strong> Whether to turn on allowing to store non serializable objects in the cache. If this option is enabled then overflow to disk cannot be enabled as well.</td></tr></tbody></table></div><h3 id="BookComponentAppendix-CacheComponentoptions">Cache Component options</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>configuration</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>To use a custom <code>org.apache.camel.component.cach
e.CacheConfiguration</code> configuration.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>cacheManagerFactory</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>To use a custom <code>org.apache.camel.component.cache.CacheManagerFactory</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>configurationFile</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.13/2.12.3:</strong> To configure the location of the <code>ehcache.xml</code> file to use, such as <code>classpath:com/foo/mycache.xml</code> to load from classpath. If no configuration is given, then the default settings from EHCache is used.</p></td></tr></tbody></table></div><h3 id="BookComponentAppendix-Sending/ReceivingMessagesto/fromthecache"><span style="line-height: 1.5625;">Sending/Recei
ving Messages to/from the cache</span></h3><h4 id="BookComponentAppendix-MessageHeadersuptoCamel2.7">Message Headers up to Camel 2.7</h4><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CACHE_OPERATION</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The operation to be performed on the cache. Valid options are</p><ul class="alternate"><li>GET</li><li>CHECK</li><li>ADD</li><li>UPDATE</li><li>DELETE</li><li>DELETEALL<br clear="none" class="atl-forced-newline"> <code>GET</code> and <code>CHECK</code> requires <strong>Camel 2.3</strong> onwards.</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CACHE_KEY</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The cache key u
sed to store the Message in the cache. The cache key is optional if the CACHE_OPERATION is DELETEALL</p></td></tr></tbody></table></div></div><h4 id="BookComponentAppendix-MessageHeadersCamel2.8+">Message Headers Camel 2.8+</h4><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Header changes in Camel 2.8</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The header names and supported values have changed to be prefixed with 'CamelCache' and use mixed case. This makes them easier to identify and keep separate from other headers. The CacheConstants variable names remain unchanged, just their values have been changed. Also, these headers are now removed from the exchange after the cache operation is performed.</p></div></div><div class="confluenceTableSmall"><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelCacheOperation</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The operation to be performed on the cache. The valid options are</p><ul class="alternate"><li>CamelCacheGet</li><li>CamelCacheCheck</li><li>CamelCacheAdd</li><li>CamelCacheUpdate</li><li>CamelCacheDelete</li><li>CamelCacheDeleteAll</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelCacheKey</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The cache key used to store the Message in the cache. The cache key is optional if the CamelCacheOperation is CamelCacheDeleteAll</p></td></tr></tbody></table></div></div><p>The <code>CamelCacheAdd</code> and <code>CamelCacheUpdate</code> operations support additional headers:</p><div class="confluenceTableSmall"><div class
="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Header</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelCacheTimeToLive</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Integer</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> Time to live in seconds.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelCacheTimeToIdle</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Integer</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> Time to idle in seconds.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>CamelCacheEternal</code></p></td><td colspan="1" rowspan="1" class="conflu
enceTd"><p><code>Boolean</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11:</strong> Whether the content is eternal.</p></td></tr></tbody></table></div></div><h4 id="BookComponentAppendix-CacheProducer">Cache Producer</h4><p>Sending data to the cache involves the ability to direct payloads in exchanges to be stored in a pre-existing or created-on-demand cache. The mechanics of doing this involve</p><ul class="alternate"><li>setting the Message Exchange Headers shown above.</li><li>ensuring that the Message Exchange Body contains the message directed to the cache</li></ul><h4 id="BookComponentAppendix-CacheConsumer">Cache Consumer</h4><p>Receiving data from the cache involves the ability of the CacheConsumer to listen on a pre-existing or created-on-demand Cache using an event Listener and receive automatic notifications when any cache activity take place (i.e CamelCacheGet/CamelCacheUpdate/CamelCacheDelete/CamelCacheDeleteAll). Upon such an activi
ty taking place</p><ul class="alternate"><li>an exchange containing Message Exchange Headers and a Message Exchange Body containing the just added/updated payload is placed and sent.</li><li>in case of a CamelCacheDeleteAll operation, the Message Exchange Header CamelCacheKey and the Message Exchange Body are not populated.</li></ul><h4 id="BookComponentAppendix-CacheProcessors">Cache Processors</h4><p>There are a set of nice processors with the ability to perform cache lookups and selectively replace payload content at the</p><ul class="alternate"><li>body</li><li>token</li><li>xpath level</li></ul><h3 id="BookComponentAppendix-CacheUsageSamples">Cache Usage Samples</h3><h4 id="BookComponentAppendix-Example1:Configuringthecache">Example 1: Configuring the cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("cache://MyApplicationCache" +
- "?maxElementsInMemory=1000" +
- "&memoryStoreEvictionPolicy=" +
- "MemoryStoreEvictionPolicy.LFU" +
- "&overflowToDisk=true" +
- "&eternal=true" +
- "&timeToLiveSeconds=300" +
- "&timeToIdleSeconds=true" +
- "&diskPersistent=true" +
- "&diskExpiryThreadIntervalSeconds=300")
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("cache://MyApplicationCache" +
+ "?maxElementsInMemory=1000" +
+ "&memoryStoreEvictionPolicy=" +
+ "MemoryStoreEvictionPolicy.LFU" +
+ "&overflowToDisk=true" +
+ "&eternal=true" +
+ "&timeToLiveSeconds=300" +
+ "&timeToIdleSeconds=true" +
+ "&diskPersistent=true" +
+ "&diskExpiryThreadIntervalSeconds=300")
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example2:Addingkeystothecache">Example 2: Adding keys to the cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("direct:start")
+ from("direct:start")
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_ADD))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
- .to("cache://TestCache1")
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
+ .to("cache://TestCache1")
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example2:Updatingexistingkeysinacache">Example 2: Updating existing keys in a cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("direct:start")
+ from("direct:start")
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_UPDATE))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
- .to("cache://TestCache1")
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
+ .to("cache://TestCache1")
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example3:Deletingexistingkeysinacache">Example 3: Deleting existing keys in a cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("direct:start")
+ from("direct:start")
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_DELETE))
- .setHeader(CacheConstants.CACHE_KEY", constant("Ralph_Waldo_Emerson"))
- .to("cache://TestCache1")
+ .setHeader(CacheConstants.CACHE_KEY", constant("Ralph_Waldo_Emerson"))
+ .to("cache://TestCache1")
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example4:Deletingallexistingkeysinacache">Example 4: Deleting all existing keys in a cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("direct:start")
+ from("direct:start")
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_DELETEALL))
- .to("cache://TestCache1");
+ .to("cache://TestCache1");
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example5:NotifyinganychangesregisteringinaCachetoProcessorsandotherProducers">Example 5: Notifying any changes registering in a Cache to Processors and other Producers</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("cache://TestCache1")
+ from("cache://TestCache1")
.process(new Processor() {
public void process(Exchange exchange)
throws Exception {
@@ -808,81 +808,81 @@ browse:someName[?options]
})
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example6:UsingProcessorstoselectivelyreplacepayloadwithcachevalues">Example 6: Using Processors to selectively replace payload with cache values</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">RouteBuilder builder = new RouteBuilder() {
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
public void configure() {
//Message Body Replacer
- from("cache://TestCache1")
- .filter(header(CacheConstants.CACHE_KEY).isEqualTo("greeting"))
- .process(new CacheBasedMessageBodyReplacer("cache://TestCache1","farewell"))
- .to("direct:next");
+ from("cache://TestCache1")
+ .filter(header(CacheConstants.CACHE_KEY).isEqualTo("greeting"))
+ .process(new CacheBasedMessageBodyReplacer("cache://TestCache1","farewell"))
+ .to("direct:next");
//Message Token replacer
- from("cache://TestCache1")
- .filter(header(CacheConstants.CACHE_KEY).isEqualTo("quote"))
- .process(new CacheBasedTokenReplacer("cache://TestCache1","novel","#novel#"))
- .process(new CacheBasedTokenReplacer("cache://TestCache1","author","#author#"))
- .process(new CacheBasedTokenReplacer("cache://TestCache1","number","#number#"))
- .to("direct:next");
+ from("cache://TestCache1")
+ .filter(header(CacheConstants.CACHE_KEY).isEqualTo("quote"))
+ .process(new CacheBasedTokenReplacer("cache://TestCache1","novel","#novel#"))
+ .process(new CacheBasedTokenReplacer("cache://TestCache1","author","#author#"))
+ .process(new CacheBasedTokenReplacer("cache://TestCache1","number","#number#"))
+ .to("direct:next");
//Message XPath replacer
- from("cache://TestCache1").
- .filter(header(CacheConstants.CACHE_KEY).isEqualTo("XML_FRAGMENT"))
- .process(new CacheBasedXPathReplacer("cache://TestCache1","book1","/books/book1"))
- .process (new CacheBasedXPathReplacer("cache://TestCache1","book2","/books/book2"))
- .to("direct:next");
+ from("cache://TestCache1").
+ .filter(header(CacheConstants.CACHE_KEY).isEqualTo("XML_FRAGMENT"))
+ .process(new CacheBasedXPathReplacer("cache://TestCache1","book1","/books/book1"))
+ .process (new CacheBasedXPathReplacer("cache://TestCache1","book2","/books/book2"))
+ .to("direct:next");
}
};
-</pre>
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example7:GettinganentryfromtheCache">Example 7: Getting an entry from the Cache</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("direct:start")
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start")
// Prepare headers
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_GET))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson")).
- .to("cache://TestCache1").
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson")).
+ .to("cache://TestCache1").
// Check if entry was not found
.choice().when(header(CacheConstants.CACHE_ELEMENT_WAS_FOUND).isNull()).
// If not found, get the payload and put it to cache
- .to("cxf:bean:someHeavyweightOperation").
+ .to("cxf:bean:someHeavyweightOperation").
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_ADD))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
- .to("cache://TestCache1")
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
+ .to("cache://TestCache1")
.end()
- .to("direct:nextPhase");
-</pre>
+ .to("direct:nextPhase");
+]]></script>
</div></div><h4 id="BookComponentAppendix-Example8:CheckingforanentryintheCache">Example 8: Checking for an entry in the Cache</h4><p>Note: The CHECK command tests existence of an entry in the cache but doesn't place a message in the body.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">from("direct:start")
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from("direct:start")
// Prepare headers
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_CHECK))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson")).
- .to("cache://TestCache1").
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson")).
+ .to("cache://TestCache1").
// Check if entry was not found
.choice().when(header(CacheConstants.CACHE_ELEMENT_WAS_FOUND).isNull()).
// If not found, get the payload and put it to cache
- .to("cxf:bean:someHeavyweightOperation").
+ .to("cxf:bean:someHeavyweightOperation").
.setHeader(CacheConstants.CACHE_OPERATION, constant(CacheConstants.CACHE_OPERATION_ADD))
- .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
- .to("cache://TestCache1")
+ .setHeader(CacheConstants.CACHE_KEY, constant("Ralph_Waldo_Emerson"))
+ .to("cache://TestCache1")
.end();
-</pre>
+]]></script>
</div></div><h3 id="BookComponentAppendix-ManagementofEHCache">Management of EHCache</h3><p><a shape="rect" class="external-link" href="http://ehcache.org/" rel="nofollow">EHCache</a> has its own statistics and management from <a shape="rect" href="camel-jmx.html">JMX</a>.</p><p>Here's a snippet on how to expose them via JMX in a Spring application context:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><bean id="ehCacheManagementService" class="net.sf.ehcache.management.ManagementService" init-method="init" lazy-init="false">
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<bean id="ehCacheManagementService" class="net.sf.ehcache.management.ManagementService" init-method="init" lazy-init="false">
<constructor-arg>
- <bean class="net.sf.ehcache.CacheManager" factory-method="getInstance"/>
+ <bean class="net.sf.ehcache.CacheManager" factory-method="getInstance"/>
</constructor-arg>
<constructor-arg>
- <bean class="org.springframework.jmx.support.JmxUtils" factory-method="locateMBeanServer"/>
+ <bean class="org.springframework.jmx.support.JmxUtils" factory-method="locateMBeanServer"/>
</constructor-arg>
- <constructor-arg value="true"/>
- <constructor-arg value="true"/>
- <constructor-arg value="true"/>
- <constructor-arg value="true"/>
+ <constructor-arg value="true"/>
+ <constructor-arg value="true"/>
+ <constructor-arg value="true"/>
+ <constructor-arg value="true"/>
</bean>
-</pre>
+]]></script>
</div></div><p>Of course you can do the same thing in straight Java:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">ManagementService.registerMBeans(CacheManager.getInstance(), mbeanServer, true, true, true, true);
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ManagementService.registerMBeans(CacheManager.getInstance(), mbeanServer, true, true, true, true);
+]]></script>
</div></div><p>You can get cache hits, misses, in-memory hits, disk hits, size stats this way. You can also change CacheConfiguration parameters on the fly.</p><h3 id="BookComponentAppendix-CachereplicationCamel2.8+">Cache replication Camel 2.8+</h3><p>The Camel Cache component is able to distribute a cache across server nodes using several different replication mechanisms including: RMI, JGroups, JMS and Cache Server.</p><p>There are two different ways to make it work:</p><p><strong>1.</strong> You can configure <code>ehcache.xml</code> manually</p><p>OR</p><p><strong>2.</strong> You can configure these three options:</p><ul class="alternate"><li>cacheManagerFactory</li><li>eventListenerRegistry</li><li>cacheLoaderRegistry</li></ul><p>Configuring Camel Cache replication using the first option is a bit of hard work as you have to configure all caches separately. So in a situation when the all names of caches are not known, using <code>ehcache.xml</code> is not a good idea.</p><p>The
second option is much better when you want to use many different caches as you do not need to define options per cache. This is because replication options are set per <code>CacheManager</code> and per <code>CacheEndpoint</code>. Also it is the only way when cache names are not know at the development phase.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>It might be useful to read the <a shape="rect" class="external-link" href="http://ehcache.org/documentation" rel="nofollow">EHCache manual</a> to get a better understanding of the Camel Cache replication mechanism.</p></div></div><h4 id="BookComponentAppendix-Example:JMScachereplication">Example: JMS cache replication</h4><p>JMS replication is the most powerful and secured replication method. Used together with Camel Cache replication makes it also rath
er simple.<br clear="none"> An example is available on <a shape="rect" href="cachereplicationjmsexample.html">a separate page</a>.</p> <h2 id="BookComponentAppendix-ClassComponent">Class Component</h2>
<p><strong>Available as of Camel 2.4</strong></p>
@@ -891,9 +891,9 @@ browse:someName[?options]
<h3 id="BookComponentAppendix-URIformat.6">URI format</h3>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
class:className[?options]
-</pre>
+]]></script>
</div></div>
<p>Where <strong>className</strong> is the fully qualified class name to create and use as bean.</p>
@@ -909,36 +909,36 @@ class:className[?options]
<p>You simply use the <strong>class</strong> component just as the <a shape="rect" href="bean.html">Bean</a> component but by specifying the fully qualified classname instead.<br clear="none">
For example to use the <code>MyFooBean</code> you have to do as follows:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
- from("direct:start").to("class:org.apache.camel.component.bean.MyFooBean").to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+ from("direct:start").to("class:org.apache.camel.component.bean.MyFooBean").to("mock:result");
+]]></script>
</div></div>
<p>You can also specify which method to invoke on the <code>MyFooBean</code>, for example <code>hello</code>:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
- from("direct:start").to("class:org.apache.camel.component.bean.MyFooBean?method=hello").to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+ from("direct:start").to("class:org.apache.camel.component.bean.MyFooBean?method=hello").to("mock:result");
+]]></script>
</div></div>
<h2 id="BookComponentAppendix-Settingpropertiesonthecreatedinstance">Setting properties on the created instance</h2>
<p>In the endpoint uri you can specify properties to set on the created instance, for example if it has a <code>setPrefix</code> method:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
- from("direct:start")
- .to("class:org.apache.camel.component.bean.MyPrefixBean?prefix=Bye")
- .to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+ from("direct:start")
+ .to("class:org.apache.camel.component.bean.MyPrefixBean?prefix=Bye")
+ .to("mock:result");
+]]></script>
</div></div>
<p>And you can also use the <code>#</code> syntax to refer to properties to be looked up in the <a shape="rect" href="registry.html">Registry</a>.</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
- from("direct:start")
- .to("class:org.apache.camel.component.bean.MyPrefixBean?cool=#foo")
- .to("mock:result");
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+ from("direct:start")
+ .to("class:org.apache.camel.component.bean.MyPrefixBean?cool=#foo")
+ .to("mock:result");
+]]></script>
</div></div>
<p>Which will lookup a bean from the <a shape="rect" href="registry.html">Registry</a> with the id <code>foo</code> and invoke the <code>setCool</code> method on the created instance of the <code>MyPrefixBean</code> class.</p>
@@ -948,28 +948,28 @@ For example to use the <code>MyFooBean</
<h3 id="BookComponentAppendix-SeeAlso.6">See Also</h3>
<ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul>
<ul><li><a shape="rect" href="bean.html">Bean</a></li><li><a shape="rect" href="bean-binding.html">Bean Binding</a></li><li><a shape="rect" href="bean-integration.html">Bean Integration</a></li></ul> <h2 id="BookComponentAppendix-CometdComponent">Cometd Component</h2><p>The <strong>cometd:</strong> component is a transport for working with the <a shape="rect" class="external-link" href="http://www.mortbay.org/jetty" rel="nofollow">jetty</a> implementation of the <a shape="rect" class="external-link" href="http://docs.codehaus.org/display/JETTY/Cometd+%28aka+Bayeux%29" rel="nofollow">cometd/bayeux protocol</a>.<br clear="none"> Using this component in combination with the dojo toolkit library it's possible to push Camel messages directly into the browser using an AJAX based mechanism.</p><p>Maven users will need to add the following dependency to their <code>pom.xml</code> for this component:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelConte
nt pdl">
-<pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;"><dependency>
+<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cometd</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-</pre>
+]]></script>
</div></div><h3 id="BookComponentAppendix-URIformat.7">URI format</h3><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">cometd://host:port/channelName[?options]
-</pre>
+<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[cometd://host:port/channelName[?options]
+]]></script>
</div></div><p>The <strong>channelName</strong> represents a topic that can be subscribed to by the Camel endpoints.</p><h3 id="BookComponentAppendix-Examples">Examples</h3><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>cometd://localhost:8080/service/mychannel
cometds://localhost:8443/service/mychannel
</pre>
[... 9451 lines stripped ...]