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 Fri Aug 25
08:22:01 2017
@@ -39,7 +39,6 @@
<link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
<link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
<script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushSql.js'
type='text/javascript'></script>
<script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
<script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
<script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
@@ -87,95 +86,70 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><div class="chapter"
id="chapter-component-appendix"><h1
id="BookComponentAppendix-ComponentAppendix">Component Appendix</h1><p>There
now follows the documentation on each Camel component.</p><h2
id="BookComponentAppendix-ActiveMQComponent">ActiveMQ Component</h2><p>The
ActiveMQ component allows messages to be sent to a <a shape="rect"
class="external-link" href="http://java.sun.com/products/jms/"
rel="nofollow">JMS</a> Queue or Topic or messages to be consumed from a JMS
Queue or Topic using <a shape="rect" class="external-link"
href="http://activemq.apache.org/" title="The most popular and powerful open
source message broker">Apache ActiveMQ</a>. This component is based on <a
shape="rect" href="jms.html">JMS Component</a> and uses Spring's JMS support
for declarative transactions, using Spring's
<strong><code>JmsTemplate</code></strong> for sending and a
<strong><code>MessageListenerContainer</code></strong> for consuming. All the
options from
the <a shape="rect" href="jms.html">JMS</a> component also applies for this
component.</p><p>To use this component make sure you have the
<strong><code>activemq.jar</code></strong> or
<strong><code>activemq-core.jar</code></strong> on your classpath along with
any Camel dependencies such as <strong><code>camel-core.jar</code></strong>,
<strong><code>camel-spring.jar</code></strong> and
<strong><code>camel-jms.jar</code></strong>.</p><div
class="confluence-information-macro confluence-information-macro-tip"><p
class="title">Transacted and caching</p><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>See section <em>Transactions and
Cache Levels</em> below on <a shape="rect" href="jms.html">JMS</a> page if you
are using transactions with <a shape="rect" href="jms.html">JMS</a> as it can
impact performance.</p></div></div><h3 id="BookComponentAppendix-URIformat">URI
format</h3><div class
="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[activemq:[queue:|topic:]destinationName
-]]></script>
-</div></div><p>Where <strong><code>destinationName</code></strong> is an
ActiveMQ queue or topic name. By default,
the <strong><code>destinationName</code></strong> is interpreted as a
queue name. For example, to connect to the queue,
<strong><code>FOO.BAR</code></strong>, use:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[activemq:FOO.BAR
-]]></script>
-</div></div><p>You can include the optional
<strong><code>queue:</code></strong> prefix, if you prefer:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[activemq:queue:FOO.BAR
-]]></script>
-</div></div><p>To connect to a topic, you must include the
<strong><code>topic:</code></strong> prefix. For example, to connect to the
topic, <strong><code>Stocks.Prices</code></strong>, use:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[activemq:topic:Stocks.Prices
-]]></script>
-</div></div><h3 id="BookComponentAppendix-Options">Options</h3><p>See Options
on the <a shape="rect" href="jms.html">JMS</a> component as all these options
also apply for this component.</p><h3
id="BookComponentAppendix-ConfiguringtheConnectionFactory">Configuring the
Connection Factory</h3><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 <strong><code>ActiveMQComponent</code></strong> 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-t
ransports.html">brokerURL</a> used to connect to ActiveMQ.</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[camelContext.addComponent("activemq",
activeMQComponent("vm://localhost?broker.persistent=false"));
-]]></script>
-</div></div><h3
id="BookComponentAppendix-ConfiguringtheConnectionFactoryusingSpringXML">Configuring
the Connection Factory using Spring XML</h3><p>You can configure the ActiveMQ
broker URL on the <strong><code>ActiveMQComponent</code></strong> as
follows</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<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
+<div class="wiki-content maincontent"><div class="chapter"
id="chapter-component-appendix"><h1
id="BookComponentAppendix-ComponentAppendix">Component Appendix</h1><p>There
now follows the documentation on each Camel component.</p><h2
id="BookComponentAppendix-ActiveMQComponent">ActiveMQ Component</h2><p>The
ActiveMQ component allows messages to be sent to a <a shape="rect"
class="external-link" href="http://java.sun.com/products/jms/"
rel="nofollow">JMS</a> Queue or Topic or messages to be consumed from a JMS
Queue or Topic using <a shape="rect" class="external-link"
href="http://activemq.apache.org/" title="The most popular and powerful open
source message broker">Apache ActiveMQ</a>. This component is based on <a
shape="rect" href="jms.html">JMS Component</a> and uses Spring's JMS support
for declarative transactions, using Spring's
<strong><code>JmsTemplate</code></strong> for sending and a
<strong><code>MessageListenerContainer</code></strong> for consuming. All the
options from
the <a shape="rect" href="jms.html">JMS</a> component also applies for this
component.</p><p>To use this component make sure you have the
<strong><code>activemq.jar</code></strong> or
<strong><code>activemq-core.jar</code></strong> on your classpath along with
any Camel dependencies such as <strong><code>camel-core.jar</code></strong>,
<strong><code>camel-spring.jar</code></strong> and
<strong><code>camel-jms.jar</code></strong>.</p><parameter
ac:name="title">Transacted and caching</parameter><rich-text-body><p>See
section <em>Transactions and Cache Levels</em> below on <a shape="rect"
href="jms.html">JMS</a> page if you are using transactions with <a shape="rect"
href="jms.html">JMS</a> as it can impact performance.</p></rich-text-body><h3
id="BookComponentAppendix-URIformat">URI
format</h3><plain-text-body>activemq:[queue:|topic:]destinationName
+</plain-text-body><p>Where <strong><code>destinationName</code></strong>
is an ActiveMQ queue or topic name. By default,
the <strong><code>destinationName</code></strong> is interpreted as a
queue name. For example, to connect to the queue,
<strong><code>FOO.BAR</code></strong>, use:</p><plain-text-body>activemq:FOO.BAR
+</plain-text-body><p>You can include the optional
<strong><code>queue:</code></strong> prefix, if you
prefer:</p><plain-text-body>activemq:queue:FOO.BAR
+</plain-text-body><p>To connect to a topic, you must include the
<strong><code>topic:</code></strong> prefix. For example, to connect to the
topic, <strong><code>Stocks.Prices</code></strong>,
use:</p><plain-text-body>activemq:topic:Stocks.Prices
+</plain-text-body><h3 id="BookComponentAppendix-Options">Options</h3><p>See
Options on the <a shape="rect" href="jms.html">JMS</a> component as all these
options also apply for this component.</p><h3
id="BookComponentAppendix-ConfiguringtheConnectionFactory">Configuring the
Connection Factory</h3><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 <strong><code>ActiveMQComponent</code></strong> 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/configu
ring-transports.html">brokerURL</a> used to connect to
ActiveMQ.</p><plain-text-body>camelContext.addComponent("activemq",
activeMQComponent("vm://localhost?broker.persistent=false"));
+</plain-text-body><h3
id="BookComponentAppendix-ConfiguringtheConnectionFactoryusingSpringXML">Configuring
the Connection Factory using Spring XML</h3><p>You can configure the ActiveMQ
broker URL on the <strong><code>ActiveMQComponent</code></strong> as
follows</p><parameter ac:name="">xml</parameter><plain-text-body><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>
-]]></script>
-</div></div><h3 id="BookComponentAppendix-UsingConnectionPooling">Using
Connection Pooling</h3><p>When sending to an ActiveMQ broker using Camel it's
recommended to use a pooled connection factory to efficiently handle pooling of
JMS connections, sessions and producers. This is documented on the <a
shape="rect" class="external-link"
href="http://activemq.apache.org/spring-support.html">ActiveMQ Spring Support
</a> page.</p><p>You can grab ActiveMQ's
<strong><code>org.apache.activemq.pool.PooledConnectionFactory</code></strong>
with Maven:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+</plain-text-body><h3 id="BookComponentAppendix-UsingConnectionPooling">Using
Connection Pooling</h3><p>When sending to an ActiveMQ broker using Camel it's
recommended to use a pooled connection factory to efficiently handle pooling of
JMS connections, sessions and producers. This is documented on the <a
shape="rect" class="external-link"
href="http://activemq.apache.org/spring-support.html">ActiveMQ Spring Support
</a> page.</p><p>You can grab ActiveMQ's
<strong><code>org.apache.activemq.pool.PooledConnectionFactory</code></strong>
with Maven:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.6.0</version>
</dependency>
-]]></script>
-</div></div><p>And then setup the <strong><code>activemq</code></strong>
Camel component as follows:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
- <property name="brokerURL"
value="tcp://localhost:61616"/>
+</plain-text-body><p>And then setup
the <strong><code>activemq</code></strong> Camel component as
follows:</p><parameter ac:name="">xml</parameter><plain-text-body><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 transacted=true 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>
-]]></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"><p>Notice
the <strong><code>init</code></strong>
and <strong><code>destroy</code></strong> methods on the pooled connection
factory. This is important to ensure the connection pool is properly started
and shutdown.</p></div></div><div class="confluence-information-macro
confluence-information-macro-information"><p class="title">Important
information about when using transactions</p><span class="aui-icon
aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>If you are using transactions then
see more details at <a shape="rect" href="jms.html">JMS</a>. And remember to
set <strong><code>cacheLevelName</code></strong> to
<strong><code>CACHE_CONSUMER</code></strong> if you are
not using XA transactions. This can dramatically improve
performance.</p></div></div><p>The
<strong><code>PooledConnectionFactory</code></strong> will then create a
connection pool with up to 8 connections in use at the same time. Each
connection can be shared by many sessions. There is an option named
<strong><code>maximumActive</code></strong> you can use to configure the
maximum number of sessions per connection; the default value is
<strong><code>500</code></strong>. From <strong>ActiveMQ 5.7</strong>: the
option has been renamed to better reflect its purpose, being named as
<strong><code>maximumActiveSessionPerConnection</code></strong>. Notice the
<strong><code>concurrentConsumers</code></strong> is set to a higher value than
<strong><code>maxConnections</code></strong> is. This is okay, as each consumer
is using a session, and as a session can share the same connection, we are in
the safe. In this example we can have <strong><code>8 * 500 =
4000</code></strong> active se
ssions at the same time.</p><h3
id="BookComponentAppendix-InvokingMessageListenerPOJOsinaCamelroute">Invoking
MessageListener POJOs in a Camel route</h3><p>The ActiveMQ component also
provides a helper <a shape="rect" href="type-converter.html">Type Converter</a>
from a JMS <strong><code>MessageListener</code></strong> to a <a
shape="rect" href="processor.html">Processor</a>. This means that the <a
shape="rect" href="bean.html">Bean</a> component is capable of invoking any
JMS <strong><code>MessageListener</code></strong> bean directly inside any
route.</p><p>So for example you can create
a <strong><code>MessageListener</code></strong> in JMS like this:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public class MyListener implements
MessageListener {
+</plain-text-body><rich-text-body><p>Notice
the <strong><code>init</code></strong>
and <strong><code>destroy</code></strong> methods on the pooled connection
factory. This is important to ensure the connection pool is properly started
and shutdown.</p></rich-text-body><parameter ac:name="title">Important
information about when using transactions</parameter><rich-text-body><p>If you
are using transactions then see more details at <a shape="rect"
href="jms.html">JMS</a>. And remember to set
<strong><code>cacheLevelName</code></strong> to
<strong><code>CACHE_CONSUMER</code></strong> if you are not using XA
transactions. This can dramatically improve
performance.</p></rich-text-body><p>The
<strong><code>PooledConnectionFactory</code></strong> will then create a
connection pool with up to 8 connections in use at the same time. Each
connection can be shared by many sessions. There is an option named
<strong><code>maximumActive</code></strong> you can use to configure the maximum
number of sessions per connection; the default value is
<strong><code>500</code></strong>. From <strong>ActiveMQ 5.7</strong>: the
option has been renamed to better reflect its purpose, being named as
<strong><code>maximumActiveSessionPerConnection</code></strong>. Notice the
<strong><code>concurrentConsumers</code></strong> is set to a higher value than
<strong><code>maxConnections</code></strong> is. This is okay, as each consumer
is using a session, and as a session can share the same connection, we are in
the safe. In this example we can have <strong><code>8 * 500 =
4000</code></strong> active sessions at the same time.</p><h3
id="BookComponentAppendix-InvokingMessageListenerPOJOsinaCamelroute">Invoking
MessageListener POJOs in a Camel route</h3><p>The ActiveMQ component also
provides a helper <a shape="rect" href="type-converter.html">Type Converter</a>
from a JMS <strong><code>MessageListener</code></strong> to a <a
shape="rect" href="processor.html">Processor</a>.
This means that the <a shape="rect" href="bean.html">Bean</a> component is
capable of invoking any JMS <strong><code>MessageListener</code></strong>
bean directly inside any route.</p><p>So for example you can create
a <strong><code>MessageListener</code></strong> in JMS like
this:</p><plain-text-body>public class MyListener implements MessageListener {
public void onMessage(Message jmsMessage) {
// ...
}
}
-]]></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">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[from("file://foo/bar")
+</plain-text-body><p>Then use it in your Camel route as
follows</p><plain-text-body>from("file://foo/bar")
.bean(MyListener.class);
-]]></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 <strong><code>MessageListener</code></strong> POJO!</p><h3
id="BookComponentAppendix-UsingActiveMQDestinationOptions">Using ActiveMQ
Destination Options</h3><p><strong>Available as of ActiveMQ
5.6</strong></p><p>You can configure the <a shape="rect" class="external-link"
href="http://activemq.apache.org/destination-options.html">Destination
Options</a> in the endpoint URI, using
the <strong><code>destination.</code></strong> prefix. For example to mark
a consumer as exclusive, and set its prefetch size to
<strong><code>50</code></strong>, you can do as follows:</p><p> </p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<from
uri="activemq:foo?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/>]]></script>
-</div></div><h3 id="BookComponentAppendix-ConsumingAdvisoryMessages">Consuming
Advisory Messages</h3><p>ActiveMQ can generate <a shape="rect"
class="external-link"
href="http://activemq.apache.org/advisory-message.html">Advisory messages </a>
which are put in topics that you can consume. Such messages can help you send
alerts in case you detect slow consumers or to build statistics (number of
messages/produced per day, etc.) The following Spring DSL example shows you how
to read messages from a topic.</p><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 <strong><code>mapJmsMessage=false</code></strong> allows for
converting
the <strong><code>org.apache.activemq.command.ActiveMqMessage</code></strong>
object from the JMS queue. Next, the body received is converted into a String
for the purposes of this e
xample 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">
-<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"/>
+</plain-text-body><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 <strong><code>MessageListener</code></strong> POJO!</p><h3
id="BookComponentAppendix-UsingActiveMQDestinationOptions">Using ActiveMQ
Destination Options</h3><p><strong>Available as of ActiveMQ
5.6</strong></p><p>You can configure the <a shape="rect" class="external-link"
href="http://activemq.apache.org/destination-options.html">Destination
Options</a> in the endpoint URI, using
the <strong><code>destination.</code></strong> prefix. For example to mark
a consumer as exclusive, and set its prefetch size to
<strong><code>50</code></strong>, you can do as
follows:</p><p> </p><plain-text-body><from
uri="activemq:foo?destination.consumer.exclusive=true&amp;destination.consumer.prefetchSize=50"/></plain-text-body><h3
id="BookComponentAppendix-ConsumingAdvisoryMessages">Consuming Advisory
Messages</h3><p>ActiveMQ
can generate <a shape="rect" class="external-link"
href="http://activemq.apache.org/advisory-message.html">Advisory messages </a>
which are put in topics that you can consume. Such messages can help you send
alerts in case you detect slow consumers or to build statistics (number of
messages/produced per day, etc.) The following Spring DSL example shows you how
to read messages from a topic.</p><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 <strong><code>mapJmsMessage=false</code></strong> allows for
converting
the <strong><code>org.apache.activemq.command.ActiveMqMessage</code></strong>
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><plain-text-body><route>
+ <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>
-]]></script>
-</div></div><p>If you consume a message on a queue, you should see the
following files under the <strong><code>data/activemq</code></strong>
folder :</p><p><strong><code>advisoryConnection-20100312.txt</code></strong><br
clear="none"><strong><code>advisoryProducer-20100312.txt</code></strong></p><p>containing
the following string:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[ActiveMQMessage {
+</plain-text-body><p>If you consume a message on a queue, you should see the
following files under the <strong><code>data/activemq</code></strong>
folder :</p><p><strong><code>advisoryConnection-20100312.txt</code></strong><br
clear="none"><strong><code>advisoryProducer-20100312.txt</code></strong></p><p>containing
the following string:</p><plain-text-body>ActiveMQMessage {
commandId = 0,
responseRequired = false,
messageId = ID:dell-charles-3258-1268399815140-1:0:0:0:221,
@@ -220,16 +194,12 @@ readOnlyProperties = true,
readOnlyBody = true,
droppable = false
}
-]]></script>
-</div></div><h3 id="BookComponentAppendix-GettingComponentJAR">Getting
Component JAR</h3><p>You will need this dependency</p><ul
class="alternate"><li><strong><code>activemq-camel</code></strong></li></ul><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">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+</plain-text-body><h3 id="BookComponentAppendix-GettingComponentJAR">Getting
Component JAR</h3><p>You will need this dependency</p><ul
class="alternate"><li><strong><code>activemq-camel</code></strong></li></ul><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><plain-text-body><dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.6.0</version>
</dependency>
-]]></script>
-</div></div><p></p><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>The <strong style="line-height:
1.42857;">amqp:</strong> component supports the <a shape="rect"
class="external-link" href="http://www.amqp.org/" rel="nofollow"
style="line-height: 1.42857;">AMQP 1.0 protocol</a> using the JMS Client API of
the <a shape="rect" class="external-link"
href="https://github.com/apache/qpid-jms/" rel="nofollow">Qpid</a> project. In
case you want to use <strong>AMQP 0.9</strong> (in particular RabbitMQ) you
might also be interested in the <a shape="rect" href="rabbitmq.html">Camel
RabbitMQ</a> component. Please keep in mind
that prior to the <strong>Camel 2.17.0</strong> AMQP component supported
<strong>AMQP 0.9</strong> and above, however since <strong>Camel
2.17.0</strong> it supports only <strong>AMQP 1.0</strong>.</p><p>Maven users
will need to add the following dependency to their
<strong><code>pom.xml</code></strong> for this component:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</plain-text-body><p><parameter ac:name=""><a shape="rect"
href="endpoint-see-also.html">Endpoint See Also</a></parameter></p> <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>The <strong style="line-height:
1.42857;">amqp:</strong> component supports the <a shape="rect"
class="external-link" href="http://www.amqp.org/" rel="nofollow"
style="line-height: 1.42857;">AMQP 1.0 protocol</a> using the JMS Client API of
the <a shape="rect" class="external-link"
href="https://github.com/apache/qpid-jms/" rel="nofollow">Qpid</a> project. In
case you want to use <strong>AMQP 0.9</strong> (in particular RabbitMQ) you
might also be interested in the <a shape="rect" href="rabbitmq.html">Camel
RabbitMQ</a> component. Please keep in mind that prior to the <strong>Camel
2.17.0</strong> AMQP component supported <strong>AMQP 0.9</strong> and above,
however since <strong>Camel 2.17.0</st
rong> it supports only <strong>AMQP 1.0</strong>.</p><p>Maven users will need
to add the following dependency to their <strong><code>pom.xml</code></strong>
for this component:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-amqp</artifactId>
@@ -310,7 +280,7 @@ AMQPConnectionDetails amqpConnection() {
</div></div><h3 id="BookComponentAppendix-UsingamqpinsideKaraf">Using amqp
inside Karaf</h3><p>To use the <strong><code>amqp</code></strong> component
inside Karaf use the predefined feature called
<strong><code>camel-amqp</code></strong> to install the necessary
bundles.</p><p>Example:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
<script class="brush: text; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[karaf@root()> repo-add camel
karaf@root()> feature:install camel-amqp]]></script>
-</div></div><p>and the environment would be set.</p><p>Use the
<strong><code>camel-blueprint</code></strong>
or <strong><code>camel-spring</code></strong> features to define routes in
those contexts.</p><p> </p><p></p><h3
id="BookComponentAppendix-SeeAlso.1">See Also</h3>
+</div></div><p>and the environment would be set.</p><p>Use the
<strong><code>camel-blueprint</code></strong>
or <strong><code>camel-spring</code></strong> features to define routes in
those contexts.</p><p> </p><p></p><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><p> </p> <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">
<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[aws-sqs://queueName[?options]
aws-sqs://queueNameOrArn[?options] (from Camel 2.18)
@@ -342,193 +312,36 @@ registry.bind("client", client
.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 <code>5000</code> 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><p>The <strong>atom:</strong> component is used for polling Atom
feeds.</p><p>Camel will poll the feed every 60 seconds by default.<br
clear="none"> <strong>Note:</strong> The component currently only supports
polling (consuming) feeds.</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">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+</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 <code>5000</code> miliseconds, the message will become
visible to other consumers.</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><ul
class="alternate"><li><a shape="rect" href="aws.html">AWS
Component</a></li></ul> <h2 id="BookComponentAppendix-AtomComponent">Atom
Component</h2><p>The <strong>atom:</strong> component is used for polling Atom
feeds.</p><p>Camel will poll the feed every 60 seconds by default.<br
clear="none"> <strong>Note:</strong> The component currently only supports
polling (consuming) feeds.</p><p>Maven users will need to add the following
dependency to their <code>pom.xml</code> for this component:</p><parameter
ac:name="">xml</parameter><plain-text-body><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>
-]]></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">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[atom://atomUri[?options]
-]]></script>
-</div></div><p>Where <strong>atomUri</strong> is the URI to the Atom feed to
poll.</p><h3 id="BookComponentAppendix-Options.1">Options</h3><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Property</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>splitEntries</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If <code>true</code> Camel will
poll the feed and for the subsequent polls return each entry poll by poll. If
the feed contains 7 entries then Camel will return the first entry on the first
poll, the 2nd entry on the next poll, until no more entries where as Camel will
do a new update on the feed. If <code>false</code> the
n Camel will poll a fresh feed on every invocation.</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>filter</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Is only used by the split
entries to filter the entries to return. Camel will default use the
<code>UpdateDateFilter</code> that only return new entries from the feed. So
the client consuming from the feed never receives the same entry more than
once. The filter will return the entries ordered by the newest
last.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>lastUpdate</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Is only used by the filter, as the starting
timestamp for selection never entries (uses the <code>entry.updated</code>
timestamp). Syntax format is: <code>yyyy-MM-ddTHH:MM:
ss</code>. Example: <code>2007-12-24T17:45:59</code>.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>throttleEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> Sets whether
all entries identified in a single feed poll should be delivered immediately.
If <code>true</code>, only one entry is processed per
<code>consumer.delay</code>. Only applicable when <code>splitEntries</code> is
set to <code>true</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>feedHeader</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Sets whether to add the Abdera Feed object
as a header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sortEntries</code></p></td><td colspan="1"
rowspan="1" class="confl
uenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If <code>splitEntries</code> is <code>true</code>, this
sets whether to sort those entries by updated date.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>500</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Delay in millis between each
poll.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Millis before polling
starts.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.userFixedDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If <code>tru
e</code>, use fixed delay between pools, otherwise 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.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>username</code></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16:</strong> For basic authentication when
polling from a HTTP feed</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>password</code></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16:</strong><span> For basic
authentication when polling from a HTTP
feed</span></td></tr></tbody></table></div></div>
-
-
-<p>You can append query options to the URI in the following format,
<code>?option=value&option=value&...</code></p><h3
id="BookComponentAppendix-Exchangedataformat">Exchange data format</h3><p>Camel
will set the In body on the returned <code>Exchange</code> with the entries.
Depending on the <code>splitEntries</code> flag Camel will either return one
<code>Entry</code> or a <code>List<Entry></code>.</p><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Behavior</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>splitEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Only a single entry from the currently
being proce
ssed feed is set: <code>exchange.in.body(Entry)</code></p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>splitEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The entire list of entries from the feed is
set:
<code>exchange.in.body(List<Entry>)</code></p></td></tr></tbody></table></div></div>
-
-
-<p>Camel can set the <code>Feed</code> object on the In header (see
<code>feedHeader</code> option to disable this):</p><h3
id="BookComponentAppendix-MessageHeaders">Message Headers</h3><p>Camel atom
uses these 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>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>CamelAtomFeed</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>When consuming the
<code>org.apache.abdera.model.Feed</code> object is set to this
header.</p></td></tr></tbody></table></div></div>
-
-
-<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">
-<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><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-
-// This is the CamelContext that is the heart of Camel
-private CamelContext context;
-
-protected CamelContext createCamelContext() throws Exception {
-
- // First we register a blog service in our bean registry
- SimpleRegistry registry = new SimpleRegistry();
- registry.put("blogService", new BlogService());
-
- // Then we create the camel context with our bean registry
- context = new DefaultCamelContext(registry);
-
- // Then we add all the routes we need using the route builder DSL syntax
- context.addRoutes(createMyRoutes());
-
- return context;
-}
-
-/**
- * This is the route builder where we create our routes using the Camel DSL
- */
-protected RouteBuilder createMyRoutes() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- // We pool the atom feeds from the source for further processing
in the seda queue
- // we set the delay to 1 second for each pool as this is a unit
test also and we can
- // not wait the default poll interval of 60 seconds.
- // Using splitEntries=true will during polling only fetch one Atom
Entry at any given time.
- // As the feed.atom file contains 7 entries, using this will
require 7 polls to fetch the entire
- // content. When Camel have reach the end of entries it will
refresh the atom feed from URI source
- // and restart - but as Camel by default uses the
UpdatedDateFilter it will only deliver new
- // blog entries to "seda:feeds". So only when James
Straham updates his blog with a new entry
- // Camel will create an exchange for the seda:feeds.
-
from("atom:file:src/test/data/feed.atom?splitEntries=true&consumer.delay=1000").to("seda:feeds");
-
- // From the feeds we filter each blot entry by using our blog
service class
-
from("seda:feeds").filter().method("blogService",
"isGoodBlog").to("seda:goodBlogs");
-
- // And the good blogs is moved to a mock queue as this sample is
also used for unit testing
- // this is one of the strengths in Camel that you can also use the
mock endpoint for your
- // unit tests
- from("seda:goodBlogs").to("mock:result");
- }
- };
-}
-
-/**
- * This is the actual junit test method that does the assertion that our
routes is working as expected
- */
-@Test
-public void testFiltering() throws Exception {
- // create and start Camel
- context = createCamelContext();
- context.start();
-
- // Get the mock endpoint
- MockEndpoint mock = context.getEndpoint("mock:result",
MockEndpoint.class);
-
- // There should be at least two good blog entries from the feed
- mock.expectedMinimumMessageCount(2);
-
- // Asserts that the above expectations is true, will throw assertions
exception if it failed
- // Camel will default wait max 20 seconds for the assertions to be true,
if the conditions
- // is true sooner Camel will continue
- mock.assertIsSatisfied();
-
- // stop Camel after use
- context.stop();
-}
-
-/**
- * Services for blogs
- */
-public class BlogService {
-
- /**
- * Tests the blogs if its a good blog entry or not
- */
- public boolean isGoodBlog(Exchange exchange) {
- Entry entry = exchange.getIn().getBody(Entry.class);
- String title = entry.getTitle();
-
- // We like blogs about Camel
- boolean good = title.toLowerCase().contains("camel");
- return good;
- }
-
-}
-
-]]></script>
-</div></div><h3 id="BookComponentAppendix-SeeAlso.3">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="rss.html">RSS</a></li></ul> <h2
id="BookComponentAppendix-BeanComponent">Bean Component</h2><p>The
<strong>bean:</strong> component binds beans to Camel message exchanges.</p><h3
id="BookComponentAppendix-URIformat.3">URI format</h3><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[bean:beanID[?options]
-]]></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><h3
id="BookComponentAppendix-Options.2">Options</h3><div
class="confluenceTableSmall"><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>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>method</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The method name from the bean that will be
invoked. If not provided, Camel will try to determine the method itself. In
case of ambiguity an exception will be thrown. See <a shape="rect"
href="bean-binding.html">Bean Binding</a> for more details. From <strong>Camel
2.8</strong> onwards you can specify type qualifiers to pin-point the exact
method to use for overloaded methods. From <strong>Camel 2.9</strong> onwards
you can specify parameter values directly in the method syntax. See more
details at <a shape="rect" href="bean-binding.html">Bean
Binding</a>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>cache</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>If enabled, Camel will cache the result of
the first <a shape="rect" href="registry.html">Registry</a> look-up. Cache can
be enabled if the bean in the <a shape="rect" href="registry.html">Registry</a>
is defined as a singleton scope.</p></td></
tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>multiParameterArray</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>How to treat the parameters which are
passed from the message body; if it is <code>true</code>, the In message body
should be an array of parameters.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>bean.xxx</p></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><p>null</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong style="line-height: 1.42857;">Camel
2.17:</strong> To configure additional options on the create bean instance
from the class name. For example to configure a foo option on the bean, use
bean.foo=123.</p></td></tr></tbody></table></div></div>
-
-
-<p>You can append query options to the URI in the following format,
<code>?option=value&option=value&...</code></p><h3
id="BookComponentAppendix-Using">Using</h3><p>The object instance that is used
to consume messages must be explicitly registered with the <a shape="rect"
href="registry.html">Registry</a>. For example, if you are using Spring you
must define the bean in the Spring configuration, <code>spring.xml</code>; or
if you don't use Spring, by registering the bean in JNDI.</p><div
class="error"><span class="error">Error formatting macro: snippet:
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>Once an
endpoint has been registered, you can build Camel routes that use it to process
exchanges.<div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-// lets add simple route
-camelContext.addRoutes(new RouteBuilder() {
- public void configure() {
- from("direct:hello").transform().constant("Good
Bye!");
- }
-});
-]]></script>
-</div></div>A <strong>bean:</strong> endpoint cannot be defined as the input
to the route; i.e. you cannot consume from it, you can only route from some
inbound message <a shape="rect" href="endpoint.html">Endpoint</a> to the bean
endpoint as output. So consider using a <strong>direct:</strong> or
<strong>queue:</strong> endpoint as the input.<p>You can use the
<code>createProxy()</code> methods on <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>
to create a proxy that will generate BeanExchanges and send them to any
endpoint:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-ISay proxy = new
ProxyBuilder(camelContext).endpoint("direct:hello").build(ISay.class);
-String rc = proxy.say();
-assertEquals("Good Bye!", rc);
-]]></script>
-</div></div>And the same route using Spring DSL:<div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<route>
- <from uri="direct:hello">
- <to uri="bean:bye"/>
+</plain-text-body><h3 id="BookComponentAppendix-URIformat.2">URI
format</h3><plain-text-body>atom://atomUri[?options]
+</plain-text-body><p>Where <strong>atomUri</strong> is the URI to the Atom
feed to poll.</p><h3
id="BookComponentAppendix-Options.1">Options</h3><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Property</p></th><th colspan="1"
rowspan="1" class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>splitEntries</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If <code>true</code> Camel will
poll the feed and for the subsequent polls return each entry poll by poll. If
the feed contains 7 entries then Camel will return the first entry on the first
poll, the 2nd entry on the next poll, until no more entries where as Camel will
do a ne
w update on the feed. If <code>false</code> then Camel will poll a fresh feed
on every invocation.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>filter</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Is only used by the split entries to filter the entries
to return. Camel will default use the <code>UpdateDateFilter</code> that only
return new entries from the feed. So the client consuming from the feed never
receives the same entry more than once. The filter will return the entries
ordered by the newest last.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>lastUpdate</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Is only used by the filter, as the starting
timestamp for selection never entries (uses the <code>entry.updated</code>
timest
amp). Syntax format is: <code>yyyy-MM-ddTHH:MM:ss</code>. Example:
<code>2007-12-24T17:45:59</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>throttleEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.5:</strong> Sets whether
all entries identified in a single feed poll should be delivered immediately.
If <code>true</code>, only one entry is processed per
<code>consumer.delay</code>. Only applicable when <code>splitEntries</code> is
set to <code>true</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>feedHeader</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Sets whether to add the Abdera Feed object
as a header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sortEntries</code></
p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If <code>splitEntries</code> is <code>true</code>, this
sets whether to sort those entries by updated date.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.delay</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>500</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Delay in millis between each
poll.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.initialDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>1000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Millis before polling
starts.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>consumer.userFixedDelay</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" r
owspan="1" class="confluenceTd"><p>If <code>true</code>, use fixed delay
between pools, otherwise 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.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>username</code></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16:</strong> For basic authentication when
polling from a HTTP feed</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>password</code></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><strong>Camel 2.16:</strong><span> For basic
authentication when polling from a HTTP
feed</span></td></tr></tbody></table></div></rich-text-body><p>You can append
query options to the URI in th
e following format, <code>?option=value&option=value&...</code></p><h3
id="BookComponentAppendix-Exchangedataformat">Exchange data format</h3><p>Camel
will set the In body on the returned <code>Exchange</code> with the entries.
Depending on the <code>splitEntries</code> flag Camel will either return one
<code>Entry</code> or a <code>List<Entry></code>.</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Behavior</p></th></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>splitEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Only a single entry from the currently
being processed fe
ed is set: <code>exchange.in.body(Entry)</code></p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>splitEntries</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The entire list of entries from the feed is
set:
<code>exchange.in.body(List<Entry>)</code></p></td></tr></tbody></table></div></rich-text-body><p>Camel
can set the <code>Feed</code> object on the In header (see
<code>feedHeader</code> option to disable this):</p><h3
id="BookComponentAppendix-MessageHeaders">Message Headers</h3><p>Camel atom
uses these headers.</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>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>CamelAtomFeed</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>When consuming the
<code>org.apache.abdera.model.Feed</code> object is set to this
header.</p></td></tr></tbody></table></div></rich-text-body><h3
id="BookComponentAppendix-Samples">Samples</h3><p>In this sample we poll James
Strachan's
blog.</p><plain-text-body>from("atom://http://macstrac.blogspot.com/feeds/posts/default").to("seda:feeds");
+</plain-text-body><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.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomGoodBlogsTest.java}</plain-text-body><parameter
ac:name=""><a shape="rect" href="endpoint-see-also.html">Endpoint See
Also</a></parameter></p><ul class="alternate"><li><a shape="rect"
href="rss.html">RSS</a></li></ul> <h2
id="BookComponentAppendix-BeanComponent">Bean Component</h2><p>The
<strong>bean:</strong> component binds beans to Camel message exchanges.</p><h3
id="BookComponentAppendix-URIformat.3">URI
format</h3><plain-text-body>bean:beanID[?options]
+</plain-text-body><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><h3
id="BookComponentAppendix-Options.2">Options</h3><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>method</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>String</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The method name from the bean that will be
invoked. If not provided, Ca
mel will try to determine the method itself. In case of ambiguity an exception
will be thrown. See <a shape="rect" href="bean-binding.html">Bean Binding</a>
for more details. From <strong>Camel 2.8</strong> onwards you can specify type
qualifiers to pin-point the exact method to use for overloaded methods. From
<strong>Camel 2.9</strong> onwards you can specify parameter values directly in
the method syntax. See more details at <a shape="rect"
href="bean-binding.html">Bean Binding</a>.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>cache</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>boolean</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If enabled, Camel will cache
the result of the first <a shape="rect" href="registry.html">Registry</a>
look-up. Cache can be enabled if the bean in the <a shape="rect"
href="registry.html">Registry<
/a> is defined as a singleton scope.</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>multiParameterArray</code></p></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>boolean</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>How to treat the parameters which are
passed from the message body; if it is <code>true</code>, the In message body
should be an array of parameters.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>bean.xxx</p></td><td colspan="1" rowspan="1"
class="confluenceTd"> </td><td colspan="1" rowspan="1"
class="confluenceTd"><p>null</p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong style="line-height: 1.42857;">Camel
2.17:</strong> To configure additional options on the create bean instance
from the class name. For example to configure a foo option on the bean, use
bean.foo=123.</p></td></t
r></tbody></table></div></rich-text-body><p>You can append query options to
the URI in the following format,
<code>?option=value&option=value&...</code></p><h3
id="BookComponentAppendix-Using">Using</h3><p>The object instance that is used
to consume messages must be explicitly registered with the <a shape="rect"
href="registry.html">Registry</a>. For example, if you are using Spring you
must define the bean in the Spring configuration, <code>spring.xml</code>; or
if you don't use Spring, by registering the bean in
JNDI.<plain-text-body>{snippet:id=register|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/PojoRouteTest.java}</plain-text-body>Once
an endpoint has been registered, you can build Camel routes that use it to
process
exchanges.<plain-text-body>{snippet:id=route|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/PojoRouteTest.java}</plain-text-body>A
<strong>bean:</strong> endpoint cannot be defined a
s the input to the route; i.e. you cannot consume from it, you can only route
from some inbound message <a shape="rect" href="endpoint.html">Endpoint</a> to
the bean endpoint as output. So consider using a <strong>direct:</strong> or
<strong>queue:</strong> endpoint as the input.</p><p>You can use the
<code>createProxy()</code> methods on <a shape="rect" class="external-link"
href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>
to create a proxy that will generate BeanExchanges and send them to any
endpoint:<plain-text-body>{snippet:id=invoke|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/pojo/PojoRouteTest.java}</plain-text-body>And
the same route using Spring DSL:</p><parameter
ac:name="">xml</parameter><plain-text-body><route>
+ <from uri="direct:hello">
+ <to uri="bean:bye"/>
</route>
-]]></script>
-</div></div><h3 id="BookComponentAppendix-Beanasendpoint">Bean as
endpoint</h3><p>Camel also supports invoking <a shape="rect"
href="bean.html">Bean</a> as an Endpoint. In the route below:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-<camelContext xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:start"/>
- <to uri="myBean"/>
- <to uri="mock:results"/>
- </route>
-</camelContext>
-
-<bean id="myBean"
class="org.apache.camel.spring.bind.ExampleBean"/>
-]]></script>
-</div></div>What happens is that when the exchange is routed to the
<code>myBean</code> Camel will use the <a shape="rect"
href="bean-binding.html">Bean Binding</a> to invoke the bean.<br clear="none">
The source for the bean is just a plain POJO:<div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-public class ExampleBean {
-
- public String sayHello(String name) {
- return "Hello " + name + "!";
- }
-}
-]]></script>
-</div></div>Camel will use <a shape="rect" href="bean-binding.html">Bean
Binding</a> to invoke the <code>sayHello</code> method, by converting the
Exchange's In body to the <code>String</code> type and storing the output of
the method on the Exchange Out body.<h3
id="BookComponentAppendix-JavaDSLbeansyntax">Java DSL bean syntax</h3><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">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[// Send message to the bean endpoint
+</plain-text-body><h3 id="BookComponentAppendix-Beanasendpoint">Bean as
endpoint</h3><p>Camel also supports invoking <a shape="rect"
href="bean.html">Bean</a> as an Endpoint. In the route
below:<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/bind/beanAsEndpoint.xml}</plain-text-body>What
happens is that when the exchange is routed to the <code>myBean</code> Camel
will use the <a shape="rect" href="bean-binding.html">Bean Binding</a> to
invoke the bean.<br clear="none"> The source for the bean is just a plain
POJO:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/bind/ExampleBean.java}</plain-text-body>Camel
will use <a shape="rect" href="bean-binding.html">Bean Binding</a> to invoke
the <code>sayHello</code> method, by converting the Exchange's In body to the
<code>String</code> type and storing the output of the method on the Exchange
Out
body.</p><h3 id="BookComponentAppendix-JavaDSLbeansyntax">Java DSL bean
syntax</h3><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><parameter ac:name="">java</parameter><plain-text-body>//
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");
-]]></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">
-<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").beanRef("beanName", "methodName");
+</plain-text-body><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><parameter ac:name="">java</parameter><plain-text-body>// Send
message to the given bean instance.
+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);
-]]></script>
-</div></div><h3 id="BookComponentAppendix-BeanBinding">Bean Binding</h3><p>How
bean methods to be invoked are chosen (if they are not specified explicitly
through the <strong>method</strong> parameter) and how parameter values are
constructed from the <a shape="rect" href="message.html">Message</a> are all
defined by the <a shape="rect" href="bean-binding.html">Bean Binding</a>
mechanism which is used throughout all of the various <a shape="rect"
href="bean-integration.html">Bean Integration</a> mechanisms in
Camel.</p><p></p><h3 id="BookComponentAppendix-SeeAlso.4">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="class.html">Class</a> component</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> <div
class="error"><span class="error">Unable to render {include}</span> The
included page could not be found.</div> <h2
id="BookComponentAppendix-BrowseComponent">Browse Component</h2>
+from("direct:start").bean(ExampleBean.class);
+</plain-text-body><h3 id="BookComponentAppendix-BeanBinding">Bean
Binding</h3><p>How bean methods to be invoked are chosen (if they are not
specified explicitly through the <strong>method</strong> parameter) and how
parameter values are constructed from the <a shape="rect"
href="message.html">Message</a> are all defined by the <a shape="rect"
href="bean-binding.html">Bean Binding</a> mechanism which is used throughout
all of the various <a shape="rect" href="bean-integration.html">Bean
Integration</a> mechanisms in Camel.</p><p><parameter ac:name=""><a
shape="rect" href="endpoint-see-also.html">Endpoint See
Also</a></parameter></p><ul><li><a shape="rect" href="class.html">Class</a>
component</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> <div class="error"><span class="error">Unable to
render {include}</span> The included page could not be found.</div> <h2
id="BookComponentAppendix
-BrowseComponent">Browse Component</h2>
<p>The Browse component provides a simple <a shape="rect"
href="browsableendpoint.html">BrowsableEndpoint</a> which can be useful for
testing, visualisation tools or debugging. The exchanges sent to the endpoint
are all available to be browsed.</p>
@@ -571,7 +384,7 @@ browse:someName[?options]
</div></div>
-<h3 id="BookComponentAppendix-SeeAlso.5">See Also</h3>
+<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> <h2
id="BookComponentAppendix-CacheComponent">Cache Component</h2><div
class="confluence-information-macro confluence-information-macro-warning"><span
class="aui-icon aui-icon-small aui-iconfont-error
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>This component is deprecated. As
of Camel 2.18.0 You should use <a shape="rect"
href="ehcache.html">Ehcache</a>.</p></div></div><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 s
ettings.</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">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
@@ -767,7 +580,7 @@ browse:someName[?options]
.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><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">See more</p><span
class="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>See more details at the <a
shape="rect" href="bean.html">Bean</a> component as the <strong>class</strong>
component works in much the same way.</p></div></div><p></p><h3
id="BookComponentAppendix-SeeAlso.6">See Also</h3>
+</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><div class="confluence-information-macro
confluence-information-macro-tip"><p class="title">See more</p><span
class="aui-icon aui-icon-small aui-iconfont-approve
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>See more details at the <a
shape="rect" href="bean.html">Bean</a> component as the <strong>class</strong>
component works in much the same way.</p></div></div><p></p><h3
id="BookComponentAppendix-SeeAlso.3">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 panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
@@ -828,7 +641,7 @@ commetdComponent.setSslContextParameters
...
<to
uri="cometds://127.0.0.1:443/service/test?baseResource=file:./target/test-classes/webapp&timeout=240000&interval=0&maxInterval=30000&multiFrameInterval=1500&jsonCommented=true&logLevel=2"/>...
]]></script>
-</div></div><p></p><h3 id="BookComponentAppendix-SeeAlso.7">See Also</h3>
+</div></div><p></p><h3 id="BookComponentAppendix-SeeAlso.4">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-ContextComponent">Context
Component</h2><p><strong>Available as of Camel 2.7</strong></p><div
class="confluence-information-macro confluence-information-macro-warning"><span
class="aui-icon aui-icon-small aui-iconfont-error
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Deprecated do NOT
use</p></div></div><p> </p><p>The <strong>context</strong> component
allows you to create new Camel Components from a CamelContext with a number of
routes which is then treated as a black box, allowing you to refer to the local
endpoints within the component from other CamelContexts.</p><p>It is similar to
the <a shape="rect" href="routebox.html">Rou
tebox</a> component in idea, though the Context component tries to be really
simple for end users; just a simple convention over configuration approach to
refer to local endpoints inside the CamelContext 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">
<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
<groupId>org.apache.camel</groupId>
@@ -884,605 +697,138 @@ registry.bind("accounts", blac
</route>
</camelContext>
]]></script>
-</div></div><h4 id="BookComponentAppendix-Namingendpoints">Naming
endpoints</h4><p>A context component instance can have many public input and
output endpoints that can be accessed from outside it's CamelContext. When
there are many it is recommended that you use logical names for them to hide
the middleware as shown above.</p><p>However when there is only one input,
output or error/dead letter endpoint in a component we recommend using the
common posix shell names <strong>in</strong>, <strong>out</strong> and
<strong>err</strong></p> <h2
id="BookComponentAppendix-CryptocomponentforDigitalSignatures">Crypto component
for Digital Signatures</h2><p><strong>Available as of Camel
2.3</strong></p><p>With Camel cryptographic endpoints and Java's Cryptographic
extension it is easy to create Digital Signatures for <a shape="rect"
href="exchange.html">Exchange</a>s. Camel provides a pair of flexible endpoints
which get used in concert to create a signature for an exchange in one part of
the
exchange's workflow and then verify the signature in a later part of the
workflow.</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">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+</div></div><h4 id="BookComponentAppendix-Namingendpoints">Naming
endpoints</h4><p>A context component instance can have many public input and
output endpoints that can be accessed from outside it's CamelContext. When
there are many it is recommended that you use logical names for them to hide
the middleware as shown above.</p><p>However when there is only one input,
output or error/dead letter endpoint in a component we recommend using the
common posix shell names <strong>in</strong>, <strong>out</strong> and
<strong>err</strong></p> <h2
id="BookComponentAppendix-CryptocomponentforDigitalSignatures">Crypto component
for Digital Signatures</h2><p><strong>Available as of Camel
2.3</strong></p><p>With Camel cryptographic endpoints and Java's Cryptographic
extension it is easy to create Digital Signatures for <a shape="rect"
href="exchange.html">Exchange</a>s. Camel provides a pair of flexible endpoints
which get used in concert to create a signature for an exchange in one part of
the
exchange's workflow and then verify the signature in a later part of the
workflow.</p><p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-crypto</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-]]></script>
-</div></div><h3
id="BookComponentAppendix-Introduction">Introduction</h3><p>Digital signatures
make use of Asymmetric Cryptographic techniques to sign messages. From a (very)
high level, the algorithms use pairs of complimentary keys with the special
property that data encrypted with one key can only be decrypted with the other.
One, the private key, is closely guarded and used to 'sign' the message while
the other, public key, is shared around to anyone interested in verifying the
signed messages. Messages are signed by using the private key to encrypting a
digest of the message. This encrypted digest is transmitted along with the
message. On the other side the verifier recalculates the message digest and
uses the public key to decrypt the the digest in the signature. If both digests
match the verifier knows only the holder of the private key could have created
the signature.</p><p>Camel uses the Signature service from the Java
Cryptographic Extension to do all the heavy cryptograp
hic lifting required to create exchange signatures. The following are some
excellent resources for explaining the mechanics of Cryptography, Message
digests and Digital Signatures and how to leverage them with the JCE.</p><ul
class="alternate"><li>Bruce Schneier's Applied Cryptography</li><li>Beginning
Cryptography with Java by David Hook</li><li>The ever insightful Wikipedia <a
shape="rect" class="external-link"
href="http://en.wikipedia.org/wiki/Digital_signature"
rel="nofollow">Digital_signatures</a></li></ul><h3
id="BookComponentAppendix-URIformat.9">URI format</h3><p>As mentioned Camel
provides a pair of crypto endpoints to create and verify signatures</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[crypto:sign:name[?options]
[... 7996 lines stripped ...]