Modified: websites/production/camel/content/book-tutorials.html
==============================================================================
--- websites/production/camel/content/book-tutorials.html (original)
+++ websites/production/camel/content/book-tutorials.html Thu Jan 28 04:22:00 
2016
@@ -143,11 +143,11 @@ The tutorial has been designed in two pa
 While not actual tutorials you might find working through the source of the 
various <a shape="rect" href="examples.html">Examples</a> useful.</li></ul>
 
 <h2 id="BookTutorials-TutorialonSpringRemotingwithJMS">Tutorial on Spring 
Remoting with JMS</h2><p>&#160;</p><div class="confluence-information-macro 
confluence-information-macro-information"><p class="title">Thanks</p><span 
class="aui-icon aui-icon-small aui-iconfont-info 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>This tutorial was kindly donated 
to Apache Camel by Martin Gilday.</p></div></div><h2 
id="BookTutorials-Preface">Preface</h2><p>This tutorial aims to guide the 
reader through the stages of creating a project which uses Camel to facilitate 
the routing of messages from a JMS queue to a <a shape="rect" 
class="external-link" href="http://www.springramework.org"; 
rel="nofollow">Spring</a> service. The route works in a synchronous fashion 
returning a response to the client.</p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1453930118966 {padding: 0px;}
-div.rbtoc1453930118966 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1453930118966 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1453954730119 {padding: 0px;}
+div.rbtoc1453954730119 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1453954730119 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1453930118966">
+/*]]>*/</style></p><div class="toc-macro rbtoc1453954730119">
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-TutorialonSpringRemotingwithJMS">Tutorial on Spring 
Remoting with JMS</a></li><li><a shape="rect" 
href="#BookTutorials-Preface">Preface</a></li><li><a shape="rect" 
href="#BookTutorials-Prerequisites">Prerequisites</a></li><li><a shape="rect" 
href="#BookTutorials-Distribution">Distribution</a></li><li><a shape="rect" 
href="#BookTutorials-About">About</a></li><li><a shape="rect" 
href="#BookTutorials-CreatetheCamelProject">Create the Camel Project</a>
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-UpdatethePOMwithDependencies">Update the POM with 
Dependencies</a></li></ul>
 </li><li><a shape="rect" href="#BookTutorials-WritingtheServer">Writing the 
Server</a>
@@ -156,7 +156,7 @@ div.rbtoc1453930118966 li {margin-left:
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-ClientUsingTheProducerTemplate">Client Using The 
ProducerTemplate</a></li><li><a shape="rect" 
href="#BookTutorials-ClientUsingSpringRemoting">Client Using Spring 
Remoting</a></li><li><a shape="rect" 
href="#BookTutorials-ClientUsingMessageEndpointEIPPattern">Client Using Message 
Endpoint EIP Pattern</a></li><li><a shape="rect" 
href="#BookTutorials-RuntheClients">Run the Clients</a></li></ul>
 </li><li><a shape="rect" href="#BookTutorials-UsingtheCamelMavenPlugin">Using 
the Camel Maven Plugin</a></li><li><a shape="rect" 
href="#BookTutorials-UsingCamelJMX">Using Camel JMX</a></li><li><a shape="rect" 
href="#BookTutorials-SeeAlso">See Also</a></li></ul>
 </div><h2 id="BookTutorials-Prerequisites">Prerequisites</h2><p>This tutorial 
uses Maven to setup the Camel project and for dependencies for 
artifacts.</p><h2 id="BookTutorials-Distribution">Distribution</h2><p>This 
sample is distributed with the Camel distribution as 
<code>examples/camel-example-spring-jms</code>.</p><h2 
id="BookTutorials-About">About</h2><p>This tutorial is a simple example that 
demonstrates more the fact how well Camel is seamless integrated with Spring to 
leverage the best of both worlds. This sample is client server solution using 
JMS messaging as the transport. The sample has two flavors of servers and also 
for clients demonstrating different techniques for easy 
communication.</p><p>The Server is a JMS message broker that routes incoming 
messages to a business service that does computations on the received message 
and returns a response.<br clear="none"> The EIP patterns used in this sample 
are:</p><div class="table-wrap"><table class="confluenceTable"><tbody>
 <tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Pattern</p></th><th 
colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="message-channel.html">Message Channel</a></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>We need a channel so the Clients can 
communicate with the server.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message.html">Message 
</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The 
information is exchanged using the Camel Message 
interface.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message-translator.html">Message 
Translator</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This 
is where Camel shines as the message exchange between the Server and the 
Clients are text based strings with numbers. However our business service uses 
int 
 for numbers. So Camel can do the message translation 
automatically.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message-endpoint.html">Message 
Endpoint</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>It 
should be easy to send messages to the Server from the the clients. This is 
achieved with Camels powerful Endpoint pattern that even can be more powerful 
combined with Spring remoting. The tutorial has clients using each kind of 
technique for this.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" 
href="point-to-point-channel.html">Point to Point Channel</a></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The client and server exchanges 
data using point to point using a JMS queue.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="event-driven-consumer.html">Event Driven Consumer</a></p></td><td 
colspan="1" rowspan="1" class="confluence
 Td"><p><span>The JMS broker is event driven and is invoked when the client 
sends a message to the server.</span></p></td></tr></tbody></table></div><p>We 
use the following Camel components:</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Component</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="activemq.html">ActiveMQ</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>We use Apache ActiveMQ as the JMS broker on the Server 
side</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
shape="rect" href="bean.html">Bean</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>We use the bean binding to easily route the messages to 
our business service. This is a very powerful component in 
Camel.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
 shape="rect" href="file2.html">File</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>In the AOP enabled Server we store audit trails as 
files.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
shape="rect" href="jms.html">JMS</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Used for the JMS 
messaging</p></td></tr></tbody></table></div><h2 
id="BookTutorials-CreatetheCamelProject">Create the Camel Project</h2><div 
class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>For the purposes of the tutorial a 
single Maven project will be used for both the client and server. Ideally you 
would break your application down into the appropriate 
components.</p></div></div><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[mvn archetype:create -DgroupId=org.example 
-DartifactId=CamelWithJmsAndSpring
+<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[mvn archetype:generate -DgroupId=org.example 
-DartifactId=CamelWithJmsAndSpring
 ]]></script>
 </div></div><h3 id="BookTutorials-UpdatethePOMwithDependencies">Update the POM 
with Dependencies</h3><p>First we need to have dependencies for the core Camel 
jars, its spring, jms components and finally ActiveMQ as the message 
broker.</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[
@@ -182,7 +182,7 @@ div.rbtoc1453930118966 li {margin-left:
     &lt;artifactId&gt;activemq-pool&lt;/artifactId&gt;
 &lt;/dependency&gt;
 ]]></script>
-</div></div><p>As we use spring xml configuration for the ActiveMQ JMS broker 
we need this dependency:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+</div></div>As we use spring xml configuration for the ActiveMQ JMS broker we 
need this dependency:<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- xbean is required for ActiveMQ broker configuration in the spring xml 
file --&gt;
 &lt;dependency&gt;
@@ -204,7 +204,7 @@ public interface Multiplier {
 
 }
 ]]></script>
-</div></div><p>And the implementation of this service is:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>And the implementation of this service is:<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[
 @Service(value = &quot;multiplier&quot;)
 public class Treble implements Multiplier {
@@ -215,7 +215,7 @@ public class Treble implements Multiplie
 
 }
 ]]></script>
-</div></div><p>Notice that this class has been annotated with the @Service 
spring annotation. This ensures that this class is registered as a bean in the 
registry with the given name <strong>multiplier</strong>.</p><h3 
id="BookTutorials-DefinetheCamelRoutes">Define the Camel Routes</h3><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div>Notice that this class has been annotated with the @Service spring 
annotation. This ensures that this class is registered as a bean in the 
registry with the given name <strong>multiplier</strong>.<h3 
id="BookTutorials-DefinetheCamelRoutes">Define the Camel Routes</h3><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[
 public class ServerRoutes extends RouteBuilder {
 
@@ -241,7 +241,7 @@ public class ServerRoutes extends RouteB
 
 }
 ]]></script>
-</div></div><p>This defines a Camel route <em>from</em> the JMS queue named 
<strong>numbers</strong> <em>to</em> the Spring <a shape="rect" 
href="bean.html">bean</a> named <strong>multiplier</strong>. Camel will create 
a consumer to the JMS queue which forwards all received messages onto the the 
Spring bean, using the method named <strong>multiply</strong>.</p><h3 
id="BookTutorials-ConfigureSpring">Configure Spring</h3><p>The Spring config 
file is placed under <code>META-INF/spring</code> as this is the default 
location used by the <a shape="rect" href="camel-maven-plugin.html">Camel Maven 
Plugin</a>, which we will later use to run our server.<br clear="none"> First 
we need to do the standard scheme declarations in the top. In the 
camel-server.xml we are using spring beans as the default 
<strong>bean:</strong> namespace and springs <strong>context:</strong>. For 
configuring ActiveMQ we use <strong>broker:</strong> and for Camel we of course 
have <strong>camel:</strong>. Notice that 
 we don't use version numbers for the camel-spring schema. At runtime the 
schema is resolved in the Camel bundle. If we use a specific version number 
such as 1.4 then its IDE friendly as it would be able to import it and provide 
smart completion etc. See <a shape="rect" href="xml-reference.html">Xml 
Reference</a> for further details.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>This defines a Camel route <em>from</em> the JMS queue named 
<strong>numbers</strong> <em>to</em> the Spring <a shape="rect" 
href="bean.html">bean</a> named <strong>multiplier</strong>. Camel will create 
a consumer to the JMS queue which forwards all received messages onto the the 
Spring bean, using the method named <strong>multiply</strong>.<h3 
id="BookTutorials-ConfigureSpring">Configure Spring</h3><p>The Spring config 
file is placed under <code>META-INF/spring</code> as this is the default 
location used by the <a shape="rect" href="camel-maven-plugin.html">Camel Maven 
Plugin</a>, which we will later use to run our server.<br clear="none"> First 
we need to do the standard scheme declarations in the top. In the 
camel-server.xml we are using spring beans as the default 
<strong>bean:</strong> namespace and springs <strong>context:</strong>. For 
configuring ActiveMQ we use <strong>broker:</strong> and for Camel we of course 
have <strong>camel:</strong>. Notice that we don'
 t use version numbers for the camel-spring schema. At runtime the schema is 
resolved in the Camel bundle. If we use a specific version number such as 1.4 
then its IDE friendly as it would be able to import it and provide smart 
completion etc. See <a shape="rect" href="xml-reference.html">Xml Reference</a> 
for further details.</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -254,12 +254,12 @@ public class ServerRoutes extends RouteB
          http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
          http://activemq.apache.org/schema/core 
http://activemq.apache.org/schema/core/activemq-core.xsd&quot;&gt;
 ]]></script>
-</div></div><p>We use Spring annotations for doing IoC dependencies and its 
component-scan features comes to the rescue as it scans for spring annotations 
in the given package name:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+</div></div>We use Spring annotations for doing IoC dependencies and its 
component-scan features comes to the rescue as it scans for spring annotations 
in the given package name:<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- let Spring do its IoC stuff in this package --&gt;
 &lt;context:component-scan 
base-package=&quot;org.apache.camel.example.server&quot;/&gt;
 ]]></script>
-</div></div><p>Camel will of course not be less than Spring in this regard so 
it supports a similar feature for scanning of Routes. This is configured as 
shown below.<br clear="none"> Notice that we also have enabled the <a 
shape="rect" href="camel-jmx.html">JMXAgent</a> so we will be able to 
introspect the Camel Server with a JMX Console.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Camel will of course not be less than Spring in this regard so it 
supports a similar feature for scanning of Routes. This is configured as shown 
below.<br clear="none"> Notice that we also have enabled the <a shape="rect" 
href="camel-jmx.html">JMXAgent</a> so we will be able to introspect the Camel 
Server with a JMX Console.<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- declare a camel context that scans for classes that is RouteBuilder
      in the package org.apache.camel.example.server --&gt;
@@ -270,7 +270,7 @@ public class ServerRoutes extends RouteB
   &lt;camel:jmxAgent id=&quot;agent&quot; createConnector=&quot;true&quot;/&gt;
 &lt;/camel:camelContext&gt;
 ]]></script>
-</div></div><p>The ActiveMQ JMS broker is also configured in this xml file. We 
set it up to listen on TCP port 61610.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The ActiveMQ JMS broker is also configured in this xml file. We 
set it up to listen on TCP port 61610.<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- lets configure the ActiveMQ JMS broker server --&gt;
 &lt;broker:broker useJmx=&quot;true&quot; persistent=&quot;false&quot; 
brokerName=&quot;myBroker&quot;&gt;
@@ -282,14 +282,14 @@ public class ServerRoutes extends RouteB
   &lt;/broker:transportConnectors&gt;
 &lt;/broker:broker&gt;
 ]]></script>
-</div></div><p>As this examples uses JMS then Camel needs a <a shape="rect" 
href="jms.html">JMS component</a> that is connected with the ActiveMQ broker. 
This is configured as shown below:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>As this examples uses JMS then Camel needs a <a shape="rect" 
href="jms.html">JMS component</a> that is connected with the ActiveMQ broker. 
This is configured as shown below:<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- lets configure the Camel ActiveMQ to use the embedded ActiveMQ broker 
declared above --&gt;
 &lt;bean id=&quot;jms&quot; 
class=&quot;org.apache.activemq.camel.component.ActiveMQComponent&quot;&gt;
   &lt;property name=&quot;brokerURL&quot; value=&quot;vm://myBroker&quot;/&gt;
 &lt;/bean&gt;
 ]]></script>
-</div></div><p><strong>Notice:</strong> The <a shape="rect" 
href="jms.html">JMS component</a> is configured in standard Spring beans, but 
the gem is that the bean id can be referenced from Camel routes - meaning we 
can do routing using the JMS Component by just using <strong>jms:</strong> 
prefix in the route URI. What happens is that Camel will find in the Spring 
Registry for a bean with the id="jms". Since the bean id can have arbitrary 
name you could have named it id="jmsbroker" and then referenced to it in the 
routing as <code>from="jmsbroker:queue:numbers).to("multiplier");</code><br 
clear="none"> We use the vm protocol to connect to the ActiveMQ server as its 
embedded in this application.</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>component-scan</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Spring stereotype 
annotations, in this case, to load the "mu
 ltiplier" bean</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camel-context</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Camel routes. 
Will find the <code>ServerRoutes</code> class and create the routes contained 
within it</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Creates the Camel JMS 
component</p></td></tr></tbody></table></div><h3 
id="BookTutorials-RuntheServer">Run the Server</h3><p>The Server is started 
using the <code>org.apache.camel.spring.Main</code> class that can start 
camel-spring application out-of-the-box. The Server can be started in several 
flavors:</p><ul class="alternate"><li>as a standard java main application - 
just start the <code>org.apache.camel.spring.Main</code> class</li><li>using 
maven jave:exec</li><li>using <a shape="rect" 
href="camel-run-maven-goal.html">camel:run</a></li></ul><p>In th
 is sample as there are two servers (with and without AOP) we have prepared 
some profiles in maven to start the Server of your choice.<br clear="none"> The 
server is started with:<br clear="none"> <code>mvn compile exec:java 
-PCamelServer</code></p><h2 id="BookTutorials-WritingTheClients">Writing The 
Clients</h2><p>This sample has three clients demonstrating different Camel 
techniques for communication</p><ul class="alternate"><li>CamelClient using the 
<a shape="rect" href="producertemplate.html">ProducerTemplate</a> for Spring 
template style coding</li><li>CamelRemoting using Spring 
Remoting</li><li>CamelEndpoint using the Message Endpoint EIP pattern using a 
neutral Camel API</li></ul><h3 
id="BookTutorials-ClientUsingTheProducerTemplate">Client Using The 
ProducerTemplate</h3><p>We will initially create a client by directly using 
<code>ProducerTemplate</code>. We will later create a client which uses Spring 
remoting to hide the fact that messaging is being used.</p><div class="code 
 panel pdl" style="border-width: 1px;"><div class="codeContent panelContent 
pdl">
+</div></div><strong>Notice:</strong> The <a shape="rect" href="jms.html">JMS 
component</a> is configured in standard Spring beans, but the gem is that the 
bean id can be referenced from Camel routes - meaning we can do routing using 
the JMS Component by just using <strong>jms:</strong> prefix in the route URI. 
What happens is that Camel will find in the Spring Registry for a bean with the 
id="jms". Since the bean id can have arbitrary name you could have named it 
id="jmsbroker" and then referenced to it in the routing as 
<code>from="jmsbroker:queue:numbers).to("multiplier");</code><br clear="none"> 
We use the vm protocol to connect to the ActiveMQ server as its embedded in 
this application.<div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>component-scan</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Spring stereotype 
annotations, in this case, to load the "multiplie
 r" bean</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camel-context</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Camel routes. 
Will find the <code>ServerRoutes</code> class and create the routes contained 
within it</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Creates the Camel JMS 
component</p></td></tr></tbody></table></div><h3 
id="BookTutorials-RuntheServer">Run the Server</h3><p>The Server is started 
using the <code>org.apache.camel.spring.Main</code> class that can start 
camel-spring application out-of-the-box. The Server can be started in several 
flavors:</p><ul class="alternate"><li>as a standard java main application - 
just start the <code>org.apache.camel.spring.Main</code> class</li><li>using 
maven jave:exec</li><li>using <a shape="rect" 
href="camel-run-maven-goal.html">camel:run</a></li></ul><p>In this samp
 le as there are two servers (with and without AOP) we have prepared some 
profiles in maven to start the Server of your choice.<br clear="none"> The 
server is started with:<br clear="none"> <code>mvn compile exec:java 
-PCamelServer</code></p><h2 id="BookTutorials-WritingTheClients">Writing The 
Clients</h2><p>This sample has three clients demonstrating different Camel 
techniques for communication</p><ul class="alternate"><li>CamelClient using the 
<a shape="rect" href="producertemplate.html">ProducerTemplate</a> for Spring 
template style coding</li><li>CamelRemoting using Spring 
Remoting</li><li>CamelEndpoint using the Message Endpoint EIP pattern using a 
neutral Camel API</li></ul><h3 
id="BookTutorials-ClientUsingTheProducerTemplate">Client Using The 
ProducerTemplate</h3><p>We will initially create a client by directly using 
<code>ProducerTemplate</code>. We will later create a client which uses Spring 
remoting to hide the fact that messaging is being used.</p><div class="code 
panel p
 dl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -313,7 +313,7 @@ public class ServerRoutes extends RouteB
   &lt;property name=&quot;brokerURL&quot; 
value=&quot;tcp://localhost:${tcp.port}&quot;/&gt;
 &lt;/bean&gt;
 ]]></script>
-</div></div><p>The client will not use the <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> so the Spring XML has 
been placed in <em>src/main/resources</em> to not conflict with the server 
configs.</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camelContext</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The Camel context is defined but does not contain any 
routes</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>template</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The <code>ProducerTemplate</code> is used to place 
messages onto the JMS queue</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>This initialises the Camel JMS component, allowing us 
to place messages onto the queue</p></td></tr></tbody></table></div><p>And the 
CamelClient source code:</p><div cl
 ass="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div>The client will not use the <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> so the Spring XML has 
been placed in <em>src/main/resources</em> to not conflict with the server 
configs.<div class="table-wrap"><table class="confluenceTable"><tbody><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>camelContext</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel context is defined 
but does not contain any routes</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>template</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The <code>ProducerTemplate</code> is used to place 
messages onto the JMS queue</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>This initialises the Camel JMS component, allowing us 
to place messages onto the queue</p></td></tr></tbody></table></div><p>And the 
CamelClient source code:</p><div class="co
 de panel pdl" style="border-width: 1px;"><div class="codeContent panelContent 
pdl">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 public static void main(final String[] args) throws Exception {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -332,7 +332,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>The <code>ProducerTemplate</code> is retrieved from a Spring 
<code>ApplicationContext</code> and used to manually place a message on the 
"numbers" JMS queue. The <code>requestBody</code> method will use the exchange 
pattern InOut, which states that the call should be synchronous, and that the 
caller expects a response.</p><p>Before running the client be sure that both 
the ActiveMQ broker and the <code>CamelServer</code> are running.</p><h3 
id="BookTutorials-ClientUsingSpringRemoting">Client Using Spring 
Remoting</h3><p><a shape="rect" href="spring-remoting.html">Spring Remoting</a> 
"eases the development of remote-enabled services". It does this by allowing 
you to invoke remote services through your regular Java interface, masking that 
a remote service is being called.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The <code>ProducerTemplate</code> is retrieved from a Spring 
<code>ApplicationContext</code> and used to manually place a message on the 
"numbers" JMS queue. The <code>requestBody</code> method will use the exchange 
pattern InOut, which states that the call should be synchronous, and that the 
caller expects a response.<p>Before running the client be sure that both the 
ActiveMQ broker and the <code>CamelServer</code> are running.</p><h3 
id="BookTutorials-ClientUsingSpringRemoting">Client Using Spring 
Remoting</h3><p><a shape="rect" href="spring-remoting.html">Spring Remoting</a> 
"eases the development of remote-enabled services". It does this by allowing 
you to invoke remote services through your regular Java interface, masking that 
a remote service is being called.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- Camel proxy for a given service, in this case the JMS queue --&gt;
 &lt;camel:proxy
@@ -340,7 +340,7 @@ public static void main(final String[] a
   serviceInterface=&quot;org.apache.camel.example.server.Multiplier&quot;
   serviceUrl=&quot;jms:queue:numbers&quot;/&gt;
 ]]></script>
-</div></div><p>The snippet above only illustrates the different and how Camel 
easily can setup and use Spring Remoting in one line configurations.</p><p>The 
<strong>proxy</strong> will create a proxy service bean for you to use to make 
the remote invocations. The <strong>serviceInterface</strong> property details 
which Java interface is to be implemented by the proxy. 
<strong>serviceUrl</strong> defines where messages sent to this proxy bean will 
be directed. Here we define the JMS endpoint with the "numbers" queue we used 
when working with Camel template directly. The value of the <strong>id</strong> 
property is the name that will be the given to the bean when it is exposed 
through the Spring <code>ApplicationContext</code>. We will use this name to 
retrieve the service in our client. I have named the bean 
<em>multiplierProxy</em> simply to highlight that it is not the same multiplier 
bean as is being used by <code>CamelServer</code>. They are in completely 
independent contexts and
  have no knowledge of each other. As you are trying to mask the fact that 
remoting is being used in a real application you would generally not include 
proxy in the name.</p><p>And the Java client source code:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The snippet above only illustrates the different and how Camel 
easily can setup and use Spring Remoting in one line configurations.<p>The 
<strong>proxy</strong> will create a proxy service bean for you to use to make 
the remote invocations. The <strong>serviceInterface</strong> property details 
which Java interface is to be implemented by the proxy. 
<strong>serviceUrl</strong> defines where messages sent to this proxy bean will 
be directed. Here we define the JMS endpoint with the "numbers" queue we used 
when working with Camel template directly. The value of the <strong>id</strong> 
property is the name that will be the given to the bean when it is exposed 
through the Spring <code>ApplicationContext</code>. We will use this name to 
retrieve the service in our client. I have named the bean 
<em>multiplierProxy</em> simply to highlight that it is not the same multiplier 
bean as is being used by <code>CamelServer</code>. They are in completely 
independent contexts and have n
 o knowledge of each other. As you are trying to mask the fact that remoting is 
being used in a real application you would generally not include proxy in the 
name.</p><p>And the Java client source code:</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 static void main(final String[] args) {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -359,7 +359,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>Again, the client is similar to the original client, but with 
some important differences.</p><ol><li>The Spring context is created with the 
new <em>camel-client-remoting.xml</em></li><li>We retrieve the proxy bean 
instead of a <code>ProducerTemplate</code>. In a non-trivial example you would 
have the bean injected as in the standard Spring manner.</li><li>The multiply 
method is then called directly. In the client we are now working to an 
interface. There is no mention of Camel or JMS inside our Java 
code.</li></ol><h3 
id="BookTutorials-ClientUsingMessageEndpointEIPPattern">Client Using Message 
Endpoint EIP Pattern</h3><p>This client uses the Message Endpoint EIP pattern 
to hide the complexity to communicate to the Server. The Client uses the same 
simple API to get hold of the endpoint, create an exchange that holds the 
message, set the payload and create a producer that does the send and receive. 
All done using the same neutral Camel API for <strong>all</strong> the c
 omponents in Camel. So if the communication was socket TCP based you just get 
hold of a different endpoint and all the java code stays the same. That is 
really powerful.</p><p>Okay enough talk, show me the code!</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Again, the client is similar to the original client, but with some 
important differences.<ol><li>The Spring context is created with the new 
<em>camel-client-remoting.xml</em></li><li>We retrieve the proxy bean instead 
of a <code>ProducerTemplate</code>. In a non-trivial example you would have the 
bean injected as in the standard Spring manner.</li><li>The multiply method is 
then called directly. In the client we are now working to an interface. There 
is no mention of Camel or JMS inside our Java code.</li></ol><h3 
id="BookTutorials-ClientUsingMessageEndpointEIPPattern">Client Using Message 
Endpoint EIP Pattern</h3><p>This client uses the Message Endpoint EIP pattern 
to hide the complexity to communicate to the Server. The Client uses the same 
simple API to get hold of the endpoint, create an exchange that holds the 
message, set the payload and create a producer that does the send and receive. 
All done using the same neutral Camel API for <strong>all</strong> the componen
 ts in Camel. So if the communication was socket TCP based you just get hold of 
a different endpoint and all the java code stays the same. That is really 
powerful.</p><p>Okay enough talk, show me the code!</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 static void main(final String[] args) throws Exception {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -398,7 +398,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>Switching to a different component is just a matter of using 
the correct endpoint. So if we had defined a TCP endpoint as: 
<code>"mina:tcp://localhost:61610"</code> then its just a matter of getting 
hold of this endpoint instead of the JMS and all the rest of the java code is 
exactly the same.</p><h3 id="BookTutorials-RuntheClients">Run the 
Clients</h3><p>The Clients is started using their main class 
respectively.</p><ul class="alternate"><li>as a standard java main application 
- just start their main class</li><li>using maven jave:exec</li></ul><p>In this 
sample we start the clients using maven:<br clear="none"> <code>mvn compile 
exec:java -PCamelClient</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientRemoting</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientEndpoint</code></p><p>Also see the Maven <code>pom.xml</code> file 
how the profiles for the clients is defined.</p><h2 
id="BookTutorials-UsingtheCamelMavenPlugin">Using the Camel M
 aven Plugin</h2><p>The <a shape="rect" href="camel-maven-plugin.html">Camel 
Maven Plugin</a> allows you to run your Camel routes directly from Maven. This 
negates the need to create a host application, as we did with Camel server, 
simply to start up the container. This can be very useful during development to 
get Camel routes running quickly.</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">
+</div></div>Switching to a different component is just a matter of using the 
correct endpoint. So if we had defined a TCP endpoint as: 
<code>"mina:tcp://localhost:61610"</code> then its just a matter of getting 
hold of this endpoint instead of the JMS and all the rest of the java code is 
exactly the same.<h3 id="BookTutorials-RuntheClients">Run the 
Clients</h3><p>The Clients is started using their main class 
respectively.</p><ul class="alternate"><li>as a standard java main application 
- just start their main class</li><li>using maven jave:exec</li></ul><p>In this 
sample we start the clients using maven:<br clear="none"> <code>mvn compile 
exec:java -PCamelClient</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientRemoting</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientEndpoint</code></p><p>Also see the Maven <code>pom.xml</code> file 
how the profiles for the clients is defined.</p><h2 
id="BookTutorials-UsingtheCamelMavenPlugin">Using the Camel Maven Pl
 ugin</h2><p>The <a shape="rect" href="camel-maven-plugin.html">Camel Maven 
Plugin</a> allows you to run your Camel routes directly from Maven. This 
negates the need to create a host application, as we did with Camel server, 
simply to start up the container. This can be very useful during development to 
get Camel routes running quickly.</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">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;build&gt;
   &lt;plugins&gt;
     &lt;plugin&gt;
@@ -413,7 +413,7 @@ public static void main(final String[] a
 DefaultInstrumentationAgent    INFO  JMX connector thread started on 
service:jmx:rmi:///jndi/rmi://claus-acer:1099/jmxrmi/camel
 ...
 ]]></script>
-</div></div><p>In the screenshot below we can see the route and its 
performance metrics:<br clear="none"> <span 
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" 
src="book-tutorials.data/jconsole_jms_tutorial.PNG" 
data-image-src="/confluence/download/attachments/82923/jconsole_jms_tutorial.PNG?version=1&amp;modificationDate=1214345078000&amp;api=v2"
 data-unresolved-comment-count="0" data-linked-resource-id="59672517" 
data-linked-resource-version="1" data-linked-resource-type="attachment" 
data-linked-resource-default-alias="jconsole_jms_tutorial.PNG" 
data-base-url="https://cwiki.apache.org/confluence"; 
data-linked-resource-content-type="image/png" 
data-linked-resource-container-id="82923" 
data-linked-resource-container-version="35"></span></p><h2 
id="BookTutorials-SeeAlso">See Also</h2><ul><li><a shape="rect" 
class="external-link" href="http://aminsblog.wordpress.com/2008/05/06/15/"; 
rel="nofollow">Spring Remoting with JMS Example</a> on <a shape="rect" cl
 ass="external-link" href="http://aminsblog.wordpress.com/"; rel="nofollow">Amin 
Abbaspour's Weblog</a></li></ul>
+</div></div><p>In the screenshot below we can see the route and its 
performance metrics:<br clear="none"> <span 
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" 
src="book-tutorials.data/jconsole_jms_tutorial.PNG" 
data-image-src="/confluence/download/attachments/82923/jconsole_jms_tutorial.PNG?version=1&amp;modificationDate=1214345078000&amp;api=v2"
 data-unresolved-comment-count="0" data-linked-resource-id="59672517" 
data-linked-resource-version="1" data-linked-resource-type="attachment" 
data-linked-resource-default-alias="jconsole_jms_tutorial.PNG" 
data-base-url="https://cwiki.apache.org/confluence"; 
data-linked-resource-content-type="image/png" 
data-linked-resource-container-id="82923" 
data-linked-resource-container-version="36"></span></p><h2 
id="BookTutorials-SeeAlso">See Also</h2><ul><li><a shape="rect" 
class="external-link" href="http://aminsblog.wordpress.com/2008/05/06/15/"; 
rel="nofollow">Spring Remoting with JMS Example</a> on <a shape="rect" cl
 ass="external-link" href="http://aminsblog.wordpress.com/"; rel="nofollow">Amin 
Abbaspour's Weblog</a></li></ul>
 
 <h2 id="BookTutorials-Tutorial-camel-example-reportincident">Tutorial - 
camel-example-reportincident</h2>
 
@@ -2252,11 +2252,11 @@ So we completed the last piece in the pi
 <p>This example has been removed from <strong>Camel 2.9</strong> onwards. 
Apache Axis 1.4 is a very old and unsupported framework. We encourage users to 
use <a shape="rect" href="cxf.html">CXF</a> instead of Axis.</p></div></div>
 
 <style type="text/css">/*<![CDATA[*/
-div.rbtoc1453930119344 {padding: 0px;}
-div.rbtoc1453930119344 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1453930119344 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1453954731070 {padding: 0px;}
+div.rbtoc1453954731070 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1453954731070 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style><div class="toc-macro rbtoc1453930119344">
+/*]]>*/</style><div class="toc-macro rbtoc1453954731070">
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-TutorialusingAxis1.4withApacheCamel">Tutorial using Axis 
1.4 with Apache Camel</a>
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-Prerequisites">Prerequisites</a></li><li><a shape="rect" 
href="#BookTutorials-Distribution">Distribution</a></li><li><a shape="rect" 
href="#BookTutorials-Introduction">Introduction</a></li><li><a shape="rect" 
href="#BookTutorials-SettinguptheprojecttorunAxis">Setting up the project to 
run Axis</a>
 <ul class="toc-indentation"><li><a shape="rect" 
href="#BookTutorials-Maven2">Maven 2</a></li><li><a shape="rect" 
href="#BookTutorials-wsdl">wsdl</a></li><li><a shape="rect" 
href="#BookTutorials-ConfiguringAxis">Configuring Axis</a></li><li><a 
shape="rect" href="#BookTutorials-RunningtheExample">Running the 
Example</a></li></ul>

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/tutorial-jmsremoting.html
==============================================================================
--- websites/production/camel/content/tutorial-jmsremoting.html (original)
+++ websites/production/camel/content/tutorial-jmsremoting.html Thu Jan 28 
04:22:00 2016
@@ -87,7 +87,7 @@
         <tr>
         <td valign="top" width="100%">
 <div class="wiki-content maincontent"><h2 
id="Tutorial-JmsRemoting-TutorialonSpringRemotingwithJMS">Tutorial on Spring 
Remoting with JMS</h2><p>&#160;</p><div class="confluence-information-macro 
confluence-information-macro-information"><p class="title">Thanks</p><span 
class="aui-icon aui-icon-small aui-iconfont-info 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>This tutorial was kindly donated 
to Apache Camel by Martin Gilday.</p></div></div><h2 
id="Tutorial-JmsRemoting-Preface">Preface</h2><p>This tutorial aims to guide 
the reader through the stages of creating a project which uses Camel to 
facilitate the routing of messages from a JMS queue to a <a shape="rect" 
class="external-link" href="http://www.springramework.org"; 
rel="nofollow">Spring</a> service. The route works in a synchronous fashion 
returning a response to the client.</p><p></p><div class="toc-macro 
client-side-toc-macro" data-headerelements="H1,H2,H3,H4,H5,H6,H7"></div><h2
  id="Tutorial-JmsRemoting-Prerequisites">Prerequisites</h2><p>This tutorial 
uses Maven to setup the Camel project and for dependencies for 
artifacts.</p><h2 
id="Tutorial-JmsRemoting-Distribution">Distribution</h2><p>This sample is 
distributed with the Camel distribution as 
<code>examples/camel-example-spring-jms</code>.</p><h2 
id="Tutorial-JmsRemoting-About">About</h2><p>This tutorial is a simple example 
that demonstrates more the fact how well Camel is seamless integrated with 
Spring to leverage the best of both worlds. This sample is client server 
solution using JMS messaging as the transport. The sample has two flavors of 
servers and also for clients demonstrating different techniques for easy 
communication.</p><p>The Server is a JMS message broker that routes incoming 
messages to a business service that does computations on the received message 
and returns a response.<br clear="none"> The EIP patterns used in this sample 
are:</p><div class="table-wrap"><table class="confluenceTa
 ble"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Pattern</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="message-channel.html">Message Channel</a></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>We need a channel so the Clients can 
communicate with the server.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message.html">Message 
</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The 
information is exchanged using the Camel Message 
interface.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message-translator.html">Message 
Translator</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This 
is where Camel shines as the message exchange between the Server and the 
Clients are text based strings with numbers. However our business servi
 ce uses int for numbers. So Camel can do the message translation 
automatically.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="message-endpoint.html">Message 
Endpoint</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>It 
should be easy to send messages to the Server from the the clients. This is 
achieved with Camels powerful Endpoint pattern that even can be more powerful 
combined with Spring remoting. The tutorial has clients using each kind of 
technique for this.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" 
href="point-to-point-channel.html">Point to Point Channel</a></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The client and server exchanges 
data using point to point using a JMS queue.</p></td></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="event-driven-consumer.html">Event Driven Consumer</a></p></td><td 
colspan="1" rowspan="1" class
 ="confluenceTd"><p><span>The JMS broker is event driven and is invoked when 
the client sends a message to the 
server.</span></p></td></tr></tbody></table></div><p>We use the following Camel 
components:</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Component</p></th><th colspan="1" rowspan="1" 
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" 
rowspan="1" class="confluenceTd"><p><a shape="rect" 
href="activemq.html">ActiveMQ</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>We use Apache ActiveMQ as the JMS broker on the Server 
side</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a 
shape="rect" href="bean.html">Bean</a></p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>We use the bean binding to easily route the messages to 
our business service. This is a very powerful component in 
Camel.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluen
 ceTd"><p><a shape="rect" href="file2.html">File</a></p></td><td colspan="1" 
rowspan="1" class="confluenceTd"><p>In the AOP enabled Server we store audit 
trails as files.</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><a shape="rect" href="jms.html">JMS</a></p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>Used for the JMS 
messaging</p></td></tr></tbody></table></div><h2 
id="Tutorial-JmsRemoting-CreatetheCamelProject">Create the Camel 
Project</h2><div class="confluence-information-macro 
confluence-information-macro-information"><span class="aui-icon aui-icon-small 
aui-iconfont-info confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>For the purposes of the tutorial a 
single Maven project will be used for both the client and server. Ideally you 
would break your application down into the appropriate 
components.</p></div></div><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelConten
 t pdl">
-<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[mvn archetype:create -DgroupId=org.example 
-DartifactId=CamelWithJmsAndSpring
+<script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[mvn archetype:generate -DgroupId=org.example 
-DartifactId=CamelWithJmsAndSpring
 ]]></script>
 </div></div><h3 id="Tutorial-JmsRemoting-UpdatethePOMwithDependencies">Update 
the POM with Dependencies</h3><p>First we need to have dependencies for the 
core Camel jars, its spring, jms components and finally ActiveMQ as the message 
broker.</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[
@@ -113,7 +113,7 @@
     &lt;artifactId&gt;activemq-pool&lt;/artifactId&gt;
 &lt;/dependency&gt;
 ]]></script>
-</div></div><p>As we use spring xml configuration for the ActiveMQ JMS broker 
we need this dependency:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+</div></div>As we use spring xml configuration for the ActiveMQ JMS broker we 
need this dependency:<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- xbean is required for ActiveMQ broker configuration in the spring xml 
file --&gt;
 &lt;dependency&gt;
@@ -135,7 +135,7 @@ public interface Multiplier {
 
 }
 ]]></script>
-</div></div><p>And the implementation of this service is:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>And the implementation of this service is:<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[
 @Service(value = &quot;multiplier&quot;)
 public class Treble implements Multiplier {
@@ -146,7 +146,7 @@ public class Treble implements Multiplie
 
 }
 ]]></script>
-</div></div><p>Notice that this class has been annotated with the @Service 
spring annotation. This ensures that this class is registered as a bean in the 
registry with the given name <strong>multiplier</strong>.</p><h3 
id="Tutorial-JmsRemoting-DefinetheCamelRoutes">Define the Camel Routes</h3><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div>Notice that this class has been annotated with the @Service spring 
annotation. This ensures that this class is registered as a bean in the 
registry with the given name <strong>multiplier</strong>.<h3 
id="Tutorial-JmsRemoting-DefinetheCamelRoutes">Define the Camel 
Routes</h3><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[
 public class ServerRoutes extends RouteBuilder {
 
@@ -172,7 +172,7 @@ public class ServerRoutes extends RouteB
 
 }
 ]]></script>
-</div></div><p>This defines a Camel route <em>from</em> the JMS queue named 
<strong>numbers</strong> <em>to</em> the Spring <a shape="rect" 
href="bean.html">bean</a> named <strong>multiplier</strong>. Camel will create 
a consumer to the JMS queue which forwards all received messages onto the the 
Spring bean, using the method named <strong>multiply</strong>.</p><h3 
id="Tutorial-JmsRemoting-ConfigureSpring">Configure Spring</h3><p>The Spring 
config file is placed under <code>META-INF/spring</code> as this is the default 
location used by the <a shape="rect" href="camel-maven-plugin.html">Camel Maven 
Plugin</a>, which we will later use to run our server.<br clear="none"> First 
we need to do the standard scheme declarations in the top. In the 
camel-server.xml we are using spring beans as the default 
<strong>bean:</strong> namespace and springs <strong>context:</strong>. For 
configuring ActiveMQ we use <strong>broker:</strong> and for Camel we of course 
have <strong>camel:</strong>. Notic
 e that we don't use version numbers for the camel-spring schema. At runtime 
the schema is resolved in the Camel bundle. If we use a specific version number 
such as 1.4 then its IDE friendly as it would be able to import it and provide 
smart completion etc. See <a shape="rect" href="xml-reference.html">Xml 
Reference</a> for further details.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>This defines a Camel route <em>from</em> the JMS queue named 
<strong>numbers</strong> <em>to</em> the Spring <a shape="rect" 
href="bean.html">bean</a> named <strong>multiplier</strong>. Camel will create 
a consumer to the JMS queue which forwards all received messages onto the the 
Spring bean, using the method named <strong>multiply</strong>.<h3 
id="Tutorial-JmsRemoting-ConfigureSpring">Configure Spring</h3><p>The Spring 
config file is placed under <code>META-INF/spring</code> as this is the default 
location used by the <a shape="rect" href="camel-maven-plugin.html">Camel Maven 
Plugin</a>, which we will later use to run our server.<br clear="none"> First 
we need to do the standard scheme declarations in the top. In the 
camel-server.xml we are using spring beans as the default 
<strong>bean:</strong> namespace and springs <strong>context:</strong>. For 
configuring ActiveMQ we use <strong>broker:</strong> and for Camel we of course 
have <strong>camel:</strong>. Notice that 
 we don't use version numbers for the camel-spring schema. At runtime the 
schema is resolved in the Camel bundle. If we use a specific version number 
such as 1.4 then its IDE friendly as it would be able to import it and provide 
smart completion etc. See <a shape="rect" href="xml-reference.html">Xml 
Reference</a> for further details.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -185,12 +185,12 @@ public class ServerRoutes extends RouteB
          http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
          http://activemq.apache.org/schema/core 
http://activemq.apache.org/schema/core/activemq-core.xsd&quot;&gt;
 ]]></script>
-</div></div><p>We use Spring annotations for doing IoC dependencies and its 
component-scan features comes to the rescue as it scans for spring annotations 
in the given package name:</p><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+</div></div>We use Spring annotations for doing IoC dependencies and its 
component-scan features comes to the rescue as it scans for spring annotations 
in the given package name:<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- let Spring do its IoC stuff in this package --&gt;
 &lt;context:component-scan 
base-package=&quot;org.apache.camel.example.server&quot;/&gt;
 ]]></script>
-</div></div><p>Camel will of course not be less than Spring in this regard so 
it supports a similar feature for scanning of Routes. This is configured as 
shown below.<br clear="none"> Notice that we also have enabled the <a 
shape="rect" href="camel-jmx.html">JMXAgent</a> so we will be able to 
introspect the Camel Server with a JMX Console.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Camel will of course not be less than Spring in this regard so it 
supports a similar feature for scanning of Routes. This is configured as shown 
below.<br clear="none"> Notice that we also have enabled the <a shape="rect" 
href="camel-jmx.html">JMXAgent</a> so we will be able to introspect the Camel 
Server with a JMX Console.<div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- declare a camel context that scans for classes that is RouteBuilder
      in the package org.apache.camel.example.server --&gt;
@@ -201,7 +201,7 @@ public class ServerRoutes extends RouteB
   &lt;camel:jmxAgent id=&quot;agent&quot; createConnector=&quot;true&quot;/&gt;
 &lt;/camel:camelContext&gt;
 ]]></script>
-</div></div><p>The ActiveMQ JMS broker is also configured in this xml file. We 
set it up to listen on TCP port 61610.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The ActiveMQ JMS broker is also configured in this xml file. We 
set it up to listen on TCP port 61610.<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- lets configure the ActiveMQ JMS broker server --&gt;
 &lt;broker:broker useJmx=&quot;true&quot; persistent=&quot;false&quot; 
brokerName=&quot;myBroker&quot;&gt;
@@ -213,14 +213,14 @@ public class ServerRoutes extends RouteB
   &lt;/broker:transportConnectors&gt;
 &lt;/broker:broker&gt;
 ]]></script>
-</div></div><p>As this examples uses JMS then Camel needs a <a shape="rect" 
href="jms.html">JMS component</a> that is connected with the ActiveMQ broker. 
This is configured as shown below:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>As this examples uses JMS then Camel needs a <a shape="rect" 
href="jms.html">JMS component</a> that is connected with the ActiveMQ broker. 
This is configured as shown below:<div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- lets configure the Camel ActiveMQ to use the embedded ActiveMQ broker 
declared above --&gt;
 &lt;bean id=&quot;jms&quot; 
class=&quot;org.apache.activemq.camel.component.ActiveMQComponent&quot;&gt;
   &lt;property name=&quot;brokerURL&quot; value=&quot;vm://myBroker&quot;/&gt;
 &lt;/bean&gt;
 ]]></script>
-</div></div><p><strong>Notice:</strong> The <a shape="rect" 
href="jms.html">JMS component</a> is configured in standard Spring beans, but 
the gem is that the bean id can be referenced from Camel routes - meaning we 
can do routing using the JMS Component by just using <strong>jms:</strong> 
prefix in the route URI. What happens is that Camel will find in the Spring 
Registry for a bean with the id="jms". Since the bean id can have arbitrary 
name you could have named it id="jmsbroker" and then referenced to it in the 
routing as <code>from="jmsbroker:queue:numbers).to("multiplier");</code><br 
clear="none"> We use the vm protocol to connect to the ActiveMQ server as its 
embedded in this application.</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>component-scan</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Spring stereotype 
annotations, in this case, to load the "mu
 ltiplier" bean</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camel-context</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Camel routes. 
Will find the <code>ServerRoutes</code> class and create the routes contained 
within it</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Creates the Camel JMS 
component</p></td></tr></tbody></table></div><h3 
id="Tutorial-JmsRemoting-RuntheServer">Run the Server</h3><p>The Server is 
started using the <code>org.apache.camel.spring.Main</code> class that can 
start camel-spring application out-of-the-box. The Server can be started in 
several flavors:</p><ul class="alternate"><li>as a standard java main 
application - just start the <code>org.apache.camel.spring.Main</code> 
class</li><li>using maven jave:exec</li><li>using <a shape="rect" 
href="camel-run-maven-goal.html">camel:run</a></li></ul><
 p>In this sample as there are two servers (with and without AOP) we have 
prepared some profiles in maven to start the Server of your choice.<br 
clear="none"> The server is started with:<br clear="none"> <code>mvn compile 
exec:java -PCamelServer</code></p><h2 
id="Tutorial-JmsRemoting-WritingTheClients">Writing The Clients</h2><p>This 
sample has three clients demonstrating different Camel techniques for 
communication</p><ul class="alternate"><li>CamelClient using the <a 
shape="rect" href="producertemplate.html">ProducerTemplate</a> for Spring 
template style coding</li><li>CamelRemoting using Spring 
Remoting</li><li>CamelEndpoint using the Message Endpoint EIP pattern using a 
neutral Camel API</li></ul><h3 
id="Tutorial-JmsRemoting-ClientUsingTheProducerTemplate">Client Using The 
ProducerTemplate</h3><p>We will initially create a client by directly using 
<code>ProducerTemplate</code>. We will later create a client which uses Spring 
remoting to hide the fact that messaging is being used.
 </p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+</div></div><strong>Notice:</strong> The <a shape="rect" href="jms.html">JMS 
component</a> is configured in standard Spring beans, but the gem is that the 
bean id can be referenced from Camel routes - meaning we can do routing using 
the JMS Component by just using <strong>jms:</strong> prefix in the route URI. 
What happens is that Camel will find in the Spring Registry for a bean with the 
id="jms". Since the bean id can have arbitrary name you could have named it 
id="jmsbroker" and then referenced to it in the routing as 
<code>from="jmsbroker:queue:numbers).to("multiplier");</code><br clear="none"> 
We use the vm protocol to connect to the ActiveMQ server as its embedded in 
this application.<div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>component-scan</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Spring stereotype 
annotations, in this case, to load the "multiplie
 r" bean</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camel-context</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Defines the package to be scanned for Camel routes. 
Will find the <code>ServerRoutes</code> class and create the routes contained 
within it</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>Creates the Camel JMS 
component</p></td></tr></tbody></table></div><h3 
id="Tutorial-JmsRemoting-RuntheServer">Run the Server</h3><p>The Server is 
started using the <code>org.apache.camel.spring.Main</code> class that can 
start camel-spring application out-of-the-box. The Server can be started in 
several flavors:</p><ul class="alternate"><li>as a standard java main 
application - just start the <code>org.apache.camel.spring.Main</code> 
class</li><li>using maven jave:exec</li><li>using <a shape="rect" 
href="camel-run-maven-goal.html">camel:run</a></li></ul><p>In th
 is sample as there are two servers (with and without AOP) we have prepared 
some profiles in maven to start the Server of your choice.<br clear="none"> The 
server is started with:<br clear="none"> <code>mvn compile exec:java 
-PCamelServer</code></p><h2 id="Tutorial-JmsRemoting-WritingTheClients">Writing 
The Clients</h2><p>This sample has three clients demonstrating different Camel 
techniques for communication</p><ul class="alternate"><li>CamelClient using the 
<a shape="rect" href="producertemplate.html">ProducerTemplate</a> for Spring 
template style coding</li><li>CamelRemoting using Spring 
Remoting</li><li>CamelEndpoint using the Message Endpoint EIP pattern using a 
neutral Camel API</li></ul><h3 
id="Tutorial-JmsRemoting-ClientUsingTheProducerTemplate">Client Using The 
ProducerTemplate</h3><p>We will initially create a client by directly using 
<code>ProducerTemplate</code>. We will later create a client which uses Spring 
remoting to hide the fact that messaging is being used.</p><di
 v class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
@@ -244,7 +244,7 @@ public class ServerRoutes extends RouteB
   &lt;property name=&quot;brokerURL&quot; 
value=&quot;tcp://localhost:${tcp.port}&quot;/&gt;
 &lt;/bean&gt;
 ]]></script>
-</div></div><p>The client will not use the <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> so the Spring XML has 
been placed in <em>src/main/resources</em> to not conflict with the server 
configs.</p><div class="table-wrap"><table 
class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>camelContext</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The Camel context is defined but does not contain any 
routes</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>template</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The <code>ProducerTemplate</code> is used to place 
messages onto the JMS queue</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>This initialises the Camel JMS component, allowing us 
to place messages onto the queue</p></td></tr></tbody></table></div><p>And the 
CamelClient source code:</p><div cl
 ass="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div>The client will not use the <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> so the Spring XML has 
been placed in <em>src/main/resources</em> to not conflict with the server 
configs.<div class="table-wrap"><table class="confluenceTable"><tbody><tr><td 
colspan="1" rowspan="1" class="confluenceTd"><p>camelContext</p></td><td 
colspan="1" rowspan="1" class="confluenceTd"><p>The Camel context is defined 
but does not contain any routes</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>template</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>The <code>ProducerTemplate</code> is used to place 
messages onto the JMS queue</p></td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p>jms bean</p></td><td colspan="1" rowspan="1" 
class="confluenceTd"><p>This initialises the Camel JMS component, allowing us 
to place messages onto the queue</p></td></tr></tbody></table></div><p>And the 
CamelClient source code:</p><div class="co
 de panel pdl" style="border-width: 1px;"><div class="codeContent panelContent 
pdl">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 public static void main(final String[] args) throws Exception {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -263,7 +263,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>The <code>ProducerTemplate</code> is retrieved from a Spring 
<code>ApplicationContext</code> and used to manually place a message on the 
"numbers" JMS queue. The <code>requestBody</code> method will use the exchange 
pattern InOut, which states that the call should be synchronous, and that the 
caller expects a response.</p><p>Before running the client be sure that both 
the ActiveMQ broker and the <code>CamelServer</code> are running.</p><h3 
id="Tutorial-JmsRemoting-ClientUsingSpringRemoting">Client Using Spring 
Remoting</h3><p><a shape="rect" href="spring-remoting.html">Spring Remoting</a> 
"eases the development of remote-enabled services". It does this by allowing 
you to invoke remote services through your regular Java interface, masking that 
a remote service is being called.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The <code>ProducerTemplate</code> is retrieved from a Spring 
<code>ApplicationContext</code> and used to manually place a message on the 
"numbers" JMS queue. The <code>requestBody</code> method will use the exchange 
pattern InOut, which states that the call should be synchronous, and that the 
caller expects a response.<p>Before running the client be sure that both the 
ActiveMQ broker and the <code>CamelServer</code> are running.</p><h3 
id="Tutorial-JmsRemoting-ClientUsingSpringRemoting">Client Using Spring 
Remoting</h3><p><a shape="rect" href="spring-remoting.html">Spring Remoting</a> 
"eases the development of remote-enabled services". It does this by allowing 
you to invoke remote services through your regular Java interface, masking that 
a remote service is being called.</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[
 &lt;!-- Camel proxy for a given service, in this case the JMS queue --&gt;
 &lt;camel:proxy
@@ -271,7 +271,7 @@ public static void main(final String[] a
   serviceInterface=&quot;org.apache.camel.example.server.Multiplier&quot;
   serviceUrl=&quot;jms:queue:numbers&quot;/&gt;
 ]]></script>
-</div></div><p>The snippet above only illustrates the different and how Camel 
easily can setup and use Spring Remoting in one line configurations.</p><p>The 
<strong>proxy</strong> will create a proxy service bean for you to use to make 
the remote invocations. The <strong>serviceInterface</strong> property details 
which Java interface is to be implemented by the proxy. 
<strong>serviceUrl</strong> defines where messages sent to this proxy bean will 
be directed. Here we define the JMS endpoint with the "numbers" queue we used 
when working with Camel template directly. The value of the <strong>id</strong> 
property is the name that will be the given to the bean when it is exposed 
through the Spring <code>ApplicationContext</code>. We will use this name to 
retrieve the service in our client. I have named the bean 
<em>multiplierProxy</em> simply to highlight that it is not the same multiplier 
bean as is being used by <code>CamelServer</code>. They are in completely 
independent contexts and
  have no knowledge of each other. As you are trying to mask the fact that 
remoting is being used in a real application you would generally not include 
proxy in the name.</p><p>And the Java client source code:</p><div class="code 
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>The snippet above only illustrates the different and how Camel 
easily can setup and use Spring Remoting in one line configurations.<p>The 
<strong>proxy</strong> will create a proxy service bean for you to use to make 
the remote invocations. The <strong>serviceInterface</strong> property details 
which Java interface is to be implemented by the proxy. 
<strong>serviceUrl</strong> defines where messages sent to this proxy bean will 
be directed. Here we define the JMS endpoint with the "numbers" queue we used 
when working with Camel template directly. The value of the <strong>id</strong> 
property is the name that will be the given to the bean when it is exposed 
through the Spring <code>ApplicationContext</code>. We will use this name to 
retrieve the service in our client. I have named the bean 
<em>multiplierProxy</em> simply to highlight that it is not the same multiplier 
bean as is being used by <code>CamelServer</code>. They are in completely 
independent contexts and have n
 o knowledge of each other. As you are trying to mask the fact that remoting is 
being used in a real application you would generally not include proxy in the 
name.</p><p>And the Java client source code:</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 static void main(final String[] args) {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -290,7 +290,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>Again, the client is similar to the original client, but with 
some important differences.</p><ol><li>The Spring context is created with the 
new <em>camel-client-remoting.xml</em></li><li>We retrieve the proxy bean 
instead of a <code>ProducerTemplate</code>. In a non-trivial example you would 
have the bean injected as in the standard Spring manner.</li><li>The multiply 
method is then called directly. In the client we are now working to an 
interface. There is no mention of Camel or JMS inside our Java 
code.</li></ol><h3 
id="Tutorial-JmsRemoting-ClientUsingMessageEndpointEIPPattern">Client Using 
Message Endpoint EIP Pattern</h3><p>This client uses the Message Endpoint EIP 
pattern to hide the complexity to communicate to the Server. The Client uses 
the same simple API to get hold of the endpoint, create an exchange that holds 
the message, set the payload and create a producer that does the send and 
receive. All done using the same neutral Camel API for <strong>all</strong
 > the components in Camel. So if the communication was socket TCP based you 
 > just get hold of a different endpoint and all the java code stays the same. 
 > That is really powerful.</p><p>Okay enough talk, show me the code!</p><div 
 > class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
 > panelContent pdl">
+</div></div>Again, the client is similar to the original client, but with some 
important differences.<ol><li>The Spring context is created with the new 
<em>camel-client-remoting.xml</em></li><li>We retrieve the proxy bean instead 
of a <code>ProducerTemplate</code>. In a non-trivial example you would have the 
bean injected as in the standard Spring manner.</li><li>The multiply method is 
then called directly. In the client we are now working to an interface. There 
is no mention of Camel or JMS inside our Java code.</li></ol><h3 
id="Tutorial-JmsRemoting-ClientUsingMessageEndpointEIPPattern">Client Using 
Message Endpoint EIP Pattern</h3><p>This client uses the Message Endpoint EIP 
pattern to hide the complexity to communicate to the Server. The Client uses 
the same simple API to get hold of the endpoint, create an exchange that holds 
the message, set the payload and create a producer that does the send and 
receive. All done using the same neutral Camel API for <strong>all</strong> the 
c
 omponents in Camel. So if the communication was socket TCP based you just get 
hold of a different endpoint and all the java code stays the same. That is 
really powerful.</p><p>Okay enough talk, show me the code!</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 static void main(final String[] args) throws Exception {
     System.out.println(&quot;Notice this client requires that the CamelServer 
is already running!&quot;);
@@ -329,7 +329,7 @@ public static void main(final String[] a
     IOHelper.close(context);
 }
 ]]></script>
-</div></div><p>Switching to a different component is just a matter of using 
the correct endpoint. So if we had defined a TCP endpoint as: 
<code>"mina:tcp://localhost:61610"</code> then its just a matter of getting 
hold of this endpoint instead of the JMS and all the rest of the java code is 
exactly the same.</p><h3 id="Tutorial-JmsRemoting-RuntheClients">Run the 
Clients</h3><p>The Clients is started using their main class 
respectively.</p><ul class="alternate"><li>as a standard java main application 
- just start their main class</li><li>using maven jave:exec</li></ul><p>In this 
sample we start the clients using maven:<br clear="none"> <code>mvn compile 
exec:java -PCamelClient</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientRemoting</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientEndpoint</code></p><p>Also see the Maven <code>pom.xml</code> file 
how the profiles for the clients is defined.</p><h2 
id="Tutorial-JmsRemoting-UsingtheCamelMavenPlugin">Usi
 ng the Camel Maven Plugin</h2><p>The <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> allows you to run your 
Camel routes directly from Maven. This negates the need to create a host 
application, as we did with Camel server, simply to start up the container. 
This can be very useful during development to get Camel routes running 
quickly.</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">
+</div></div>Switching to a different component is just a matter of using the 
correct endpoint. So if we had defined a TCP endpoint as: 
<code>"mina:tcp://localhost:61610"</code> then its just a matter of getting 
hold of this endpoint instead of the JMS and all the rest of the java code is 
exactly the same.<h3 id="Tutorial-JmsRemoting-RuntheClients">Run the 
Clients</h3><p>The Clients is started using their main class 
respectively.</p><ul class="alternate"><li>as a standard java main application 
- just start their main class</li><li>using maven jave:exec</li></ul><p>In this 
sample we start the clients using maven:<br clear="none"> <code>mvn compile 
exec:java -PCamelClient</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientRemoting</code><br clear="none"> <code>mvn compile exec:java 
-PCamelClientEndpoint</code></p><p>Also see the Maven <code>pom.xml</code> file 
how the profiles for the clients is defined.</p><h2 
id="Tutorial-JmsRemoting-UsingtheCamelMavenPlugin">Using the 
 Camel Maven Plugin</h2><p>The <a shape="rect" 
href="camel-maven-plugin.html">Camel Maven Plugin</a> allows you to run your 
Camel routes directly from Maven. This negates the need to create a host 
application, as we did with Camel server, simply to start up the container. 
This can be very useful during development to get Camel routes running 
quickly.</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">
 <script class="brush: java; gutter: false; theme: Default" 
type="syntaxhighlighter"><![CDATA[&lt;build&gt;
   &lt;plugins&gt;
     &lt;plugin&gt;
@@ -344,7 +344,7 @@ public static void main(final String[] a
 DefaultInstrumentationAgent    INFO  JMX connector thread started on 
service:jmx:rmi:///jndi/rmi://claus-acer:1099/jmxrmi/camel
 ...
 ]]></script>
-</div></div><p>In the screenshot below we can see the route and its 
performance metrics:<br clear="none"> <span 
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" 
src="tutorial-jmsremoting.data/jconsole_jms_tutorial.PNG" 
data-image-src="/confluence/download/attachments/82923/jconsole_jms_tutorial.PNG?version=1&amp;modificationDate=1214345078000&amp;api=v2"
 data-unresolved-comment-count="0" data-linked-resource-id="59672517" 
data-linked-resource-version="1" data-linked-resource-type="attachment" 
data-linked-resource-default-alias="jconsole_jms_tutorial.PNG" 
data-base-url="https://cwiki.apache.org/confluence"; 
data-linked-resource-content-type="image/png" 
data-linked-resource-container-id="82923" 
data-linked-resource-container-version="35"></span></p><h2 
id="Tutorial-JmsRemoting-SeeAlso">See Also</h2><ul><li><a shape="rect" 
class="external-link" href="http://aminsblog.wordpress.com/2008/05/06/15/"; 
rel="nofollow">Spring Remoting with JMS Example</a> on <a sh
 ape="rect" class="external-link" href="http://aminsblog.wordpress.com/"; 
rel="nofollow">Amin Abbaspour's Weblog</a></li></ul></div>
+</div></div><p>In the screenshot below we can see the route and its 
performance metrics:<br clear="none"> <span 
class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" 
src="tutorial-jmsremoting.data/jconsole_jms_tutorial.PNG" 
data-image-src="/confluence/download/attachments/82923/jconsole_jms_tutorial.PNG?version=1&amp;modificationDate=1214345078000&amp;api=v2"
 data-unresolved-comment-count="0" data-linked-resource-id="59672517" 
data-linked-resource-version="1" data-linked-resource-type="attachment" 
data-linked-resource-default-alias="jconsole_jms_tutorial.PNG" 
data-base-url="https://cwiki.apache.org/confluence"; 
data-linked-resource-content-type="image/png" 
data-linked-resource-container-id="82923" 
data-linked-resource-container-version="36"></span></p><h2 
id="Tutorial-JmsRemoting-SeeAlso">See Also</h2><ul><li><a shape="rect" 
class="external-link" href="http://aminsblog.wordpress.com/2008/05/06/15/"; 
rel="nofollow">Spring Remoting with JMS Example</a> on <a sh
 ape="rect" class="external-link" href="http://aminsblog.wordpress.com/"; 
rel="nofollow">Amin Abbaspour's Weblog</a></li></ul></div>
         </td>
         <td valign="top">
           <div class="navigation">


Reply via email to