You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2017/08/25 08:22:03 UTC

svn commit: r1017260 [11/40] - in /websites/production/camel/content: ./ cache/

Modified: websites/production/camel/content/book-quickstart.html
==============================================================================
--- websites/production/camel/content/book-quickstart.html (original)
+++ websites/production/camel/content/book-quickstart.html Fri Aug 25 08:22:01 2017
@@ -91,38 +91,8 @@
 
 <p>To start using Apache Camel quickly, you can read through some simple examples in this chapter. For readers who would like a more thorough introduction, please skip ahead to Chapter 3.</p>
 
-<h2 id="BookQuickstart-WalkthroughanExampleCode">Walk through an Example Code</h2><p>This mini-guide takes you through the source code of a <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java">simple example</a>.</p><p>Camel can be configured either by using <a shape="rect" href="spring.html">Spring</a> or directly in Java - which <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java">this example does</a>.</p><p>This example is available in the <code>examples\camel-example-jms-file</code> directory of the <a shape="rect" href="download.html">Camel distribution</a>.</p><p>We start with creating a <a shape="rect" href="camelcontext.html">CamelContext</a> - which is a container for <a shape="rect" href
 ="components.html">Components</a>, <a shape="rect" href="routes.html">Routes</a> etc:</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 context = new DefaultCamelContext();
-]]></script>
-</div></div>There is more than one way of adding a Component to the CamelContext. You can add components implicitly - when we set up the routing - as we do here for the <a shape="rect" href="file2.html">FileComponent</a>:<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[
-context.addRoutes(new RouteBuilder() {
-    public void configure() {
-        from(&quot;test-jms:queue:test.queue&quot;).to(&quot;file://test&quot;);
-    }
-});
-]]></script>
-</div></div>or explicitly - as we do here when we add the JMS Component:<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[
-ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(&quot;vm://localhost?broker.persistent=false&quot;);
-// Note we can explicit name the component
-context.addComponent(&quot;test-jms&quot;, JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
-]]></script>
-</div></div>The above works with any JMS provider. If we know we are using <a shape="rect" href="activemq.html">ActiveMQ</a> we can use an even simpler form using the <a shape="rect" class="external-link" href="http://activemq.apache.org/maven/5.5.0/activemq-camel/apidocs/org/apache/activemq/camel/component/ActiveMQComponent.html#activeMQComponent%28java.lang.String%29"><code>activeMQComponent()</code> method</a> while specifying the <a shape="rect" class="external-link" href="http://activemq.apache.org/configuring-transports.html">brokerURL</a> used to connect to ActiveMQ<p>In normal use, an external system would be firing messages or events directly into Camel through one if its <a shape="rect" href="components.html">Components</a> but we are going to use the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html">ProducerTemplate</a> which is a really easy way for testing your configuration:</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[
-ProducerTemplate template = context.createProducerTemplate();
-]]></script>
-</div></div>Next you <strong>must</strong> start the camel context. If you are using <a shape="rect" href="spring.html">Spring</a> to configure the camel context this is automatically done for you; though if you are using a pure Java approach then you just need to call the start() method<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.start();
-]]></script>
-</div></div><p>This will start all of the configured routing rules.</p><p>So after starting the <a shape="rect" href="camelcontext.html">CamelContext</a>, we can fire some objects into camel:</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[
-for (int i = 0; i &lt; 10; i++) {
-    template.sendBody(&quot;test-jms:queue:test.queue&quot;, &quot;Test Message: &quot; + i);
-}
-]]></script>
-</div></div><h2 id="BookQuickstart-Whathappens?">What happens?</h2><p>From the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html">ProducerTemplate</a> - we send objects (in this case text) into the <a shape="rect" href="camelcontext.html">CamelContext</a> to the Component <em>test-jms:queue:test.queue</em>. These text objects will be <a shape="rect" href="type-converter.html">converted automatically</a> into JMS Messages and posted to a JMS Queue named <em>test.queue</em>. When we set up the <a shape="rect" href="routes.html">Route</a>, we configured the <a shape="rect" href="file2.html">FileComponent</a> to listen off the <em>test.queue</em>.</p><p>The File <a shape="rect" href="file2.html">FileComponent</a> will take messages off the Queue, and save them to a directory named <em>test</em>. Every message will be saved in a file that corresponds to its destination and message id.</p><p>Finally,
  we configured our own listener in the <a shape="rect" href="routes.html">Route</a> - to take notifications from the <a shape="rect" href="file2.html">FileComponent</a> and print them out as text.</p><p><strong>That's it!</strong></p><p>If you have the time then use 5 more minutes to <a shape="rect" href="walk-through-another-example.html">Walk through another example</a> that demonstrates the Spring DSL (XML based) routing.</p>
+<h2 id="BookQuickstart-WalkthroughanExampleCode">Walk through an Example Code</h2><p>This mini-guide takes you through the source code of a <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java">simple example</a>.</p><p>Camel can be configured either by using <a shape="rect" href="spring.html">Spring</a> or directly in Java - which <a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java">this example does</a>.</p><p>This example is available in the <code>examples\camel-example-jms-file</code> directory of the <a shape="rect" href="download.html">Camel distribution</a>.</p><p>We start with creating a <a shape="rect" href="camelcontext.html">CamelContext</a> - which is a container for <a shape="rect" href
 ="components.html">Components</a>, <a shape="rect" href="routes.html">Routes</a> etc:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>There is more than one way of adding a Component to the CamelContext. You can add components implicitly - when we set up the routing - as we do here for the <a shape="rect" href="file2.html">FileComponent</a>:<plain-text-body>{snippet:id=e3|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>or explicitly - as we do here when we add the JMS Component:<plain-text-body>{snippet:id=e2|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>The above works with any JMS provider. If we know we are using <a shape="rect" href="active
 mq.html">ActiveMQ</a> we can use an even simpler form using the <a shape="rect" class="external-link" href="http://activemq.apache.org/maven/5.5.0/activemq-camel/apidocs/org/apache/activemq/camel/component/ActiveMQComponent.html#activeMQComponent%28java.lang.String%29"><code>activeMQComponent()</code> method</a> while specifying the <a shape="rect" class="external-link" href="http://activemq.apache.org/configuring-transports.html">brokerURL</a> used to connect to ActiveMQ</p><p>In normal use, an external system would be firing messages or events directly into Camel through one if its <a shape="rect" href="components.html">Components</a> but we are going to use the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html">ProducerTemplate</a> which is a really easy way for testing your configuration:<plain-text-body>{snippet:id=e4|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/
 org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body>Next you <strong>must</strong> start the camel context. If you are using <a shape="rect" href="spring.html">Spring</a> to configure the camel context this is automatically done for you; though if you are using a pure Java approach then you just need to call the start() method</p><plain-text-body>camelContext.start();
+</plain-text-body><p>This will start all of the configured routing rules.</p><p>So after starting the <a shape="rect" href="camelcontext.html">CamelContext</a>, we can fire some objects into camel:<plain-text-body>{snippet:id=e5|lang=java|url=camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java}</plain-text-body></p><h2 id="BookQuickstart-Whathappens?">What happens?</h2><p>From the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ProducerTemplate.html">ProducerTemplate</a> - we send objects (in this case text) into the <a shape="rect" href="camelcontext.html">CamelContext</a> to the Component <em>test-jms:queue:test.queue</em>. These text objects will be <a shape="rect" href="type-converter.html">converted automatically</a> into JMS Messages and posted to a JMS Queue named <em>test.queue</em>. When we set up the <a shape="rect" href="routes.html">Ro
 ute</a>, we configured the <a shape="rect" href="file2.html">FileComponent</a> to listen off the <em>test.queue</em>.</p><p>The File <a shape="rect" href="file2.html">FileComponent</a> will take messages off the Queue, and save them to a directory named <em>test</em>. Every message will be saved in a file that corresponds to its destination and message id.</p><p>Finally, we configured our own listener in the <a shape="rect" href="routes.html">Route</a> - to take notifications from the <a shape="rect" href="file2.html">FileComponent</a> and print them out as text.</p><p><strong>That's it!</strong></p><p>If you have the time then use 5 more minutes to <a shape="rect" href="walk-through-another-example.html">Walk through another example</a> that demonstrates the Spring DSL (XML based) routing.</p>
 <h2 id="BookQuickstart-Walkthroughanotherexample">Walk through another example</h2>
 
 <h3 id="BookQuickstart-Introduction">Introduction</h3>

Modified: websites/production/camel/content/book-tutorials.html
==============================================================================
--- websites/production/camel/content/book-tutorials.html (original)
+++ websites/production/camel/content/book-tutorials.html Fri Aug 25 08:22:01 2017
@@ -145,274 +145,8 @@ The tutorial has been designed in two pa
 <ul><li><a shape="rect" href="examples.html">Examples</a><br clear="none">
 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.rbtoc1501552077764 {padding: 0px;}
-div.rbtoc1501552077764 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1501552077764 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1501552077764">
-<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>
-<ul class="toc-indentation"><li><a shape="rect" href="#BookTutorials-CreatetheSpringService">Create the Spring Service</a></li><li><a shape="rect" href="#BookTutorials-DefinetheCamelRoutes">Define the Camel Routes</a></li><li><a shape="rect" href="#BookTutorials-ConfigureSpring">Configure Spring</a></li><li><a shape="rect" href="#BookTutorials-RuntheServer">Run the Server</a></li></ul>
-</li><li><a shape="rect" href="#BookTutorials-WritingTheClients">Writing The Clients</a>
-<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 Camel's 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 exchange 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: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, 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[
-&lt;!-- required by both client and server --&gt;
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
-  &lt;artifactId&gt;camel-core&lt;/artifactId&gt;
-&lt;/dependency&gt;
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
-  &lt;artifactId&gt;camel-jms&lt;/artifactId&gt;
-&lt;/dependency&gt;
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
-  &lt;artifactId&gt;camel-spring&lt;/artifactId&gt;
-&lt;/dependency&gt;
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
-  &lt;artifactId&gt;activemq-camel&lt;/artifactId&gt;
-&lt;/dependency&gt;
-&lt;dependency&gt;
-  &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
-  &lt;artifactId&gt;activemq-pool&lt;/artifactId&gt;
-&lt;/dependency&gt;
-]]></script>
-</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;
-  &lt;groupId&gt;org.apache.xbean&lt;/groupId&gt;
-  &lt;artifactId&gt;xbean-spring&lt;/artifactId&gt;
-&lt;/dependency&gt;
-]]></script>
-</div></div><h2 id="BookTutorials-WritingtheServer">Writing the Server</h2><h3 id="BookTutorials-CreatetheSpringService">Create the Spring Service</h3><p>For this example the Spring service (our business service) on the server will be a simple multiplier which trebles in the received value.</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 interface Multiplier {
-
-    /**
-     * Multiplies the given number by a pre-defined constant.
-     *
-     * @param originalNumber The number to be multiplied
-     * @return The result of the multiplication
-     */
-    int multiply(int originalNumber);
-
-}
-]]></script>
-</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 {
-
-    public int multiply(final int originalNumber) {
-        return originalNumber * 3;
-    }
-
-}
-]]></script>
-</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 {
-
-    @Override
-    public void configure() throws Exception {
-        // route from the numbers queue to our business that is a spring bean registered with the id=multiplier
-        // Camel will introspect the multiplier bean and find the best candidate of the method to invoke.
-        // You can add annotations etc to help Camel find the method to invoke.
-        // As our multiplier bean only have one method its easy for Camel to find the method to use.
-        from(&quot;jms:queue:numbers&quot;).to(&quot;multiplier&quot;);
-
-        // Camel has several ways to configure the same routing, we have defined some of them here below
-
-        // as above but with the bean: prefix
-        //from(&quot;jms:queue:numbers&quot;).to(&quot;bean:multiplier&quot;);
-
-        // bean is using explicit bean bindings to lookup the multiplier bean and invoke the multiply method
-        //from(&quot;jms:queue:numbers&quot;).bean(&quot;multiplier&quot;, &quot;multiply&quot;);
-
-        // the same as above but expressed as a URI configuration
-        //from(&quot;jms:queue:numbers&quot;).to(&quot;bean:multiplier?method=multiply&quot;);
-    }
-
-}
-]]></script>
-</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;
-       xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
-       xmlns:camel=&quot;http://camel.apache.org/schema/spring&quot;
-       xmlns:broker=&quot;http://activemq.apache.org/schema/core&quot;
-       xsi:schemaLocation=&quot;
-         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
-         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>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>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;
-&lt;camel:camelContext id=&quot;camel-server&quot;&gt;
-  &lt;camel:package&gt;org.apache.camel.example.server&lt;/camel:package&gt;
-  &lt;!-- enable JMX connector so we can connect to the server and browse mbeans --&gt;
-  &lt;!-- Camel will log at INFO level the service URI to use for connecting with jconsole --&gt;
-  &lt;camel:jmxAgent id=&quot;agent&quot; createConnector=&quot;true&quot;/&gt;
-&lt;/camel:camelContext&gt;
-]]></script>
-</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;
-  &lt;broker:transportConnectors&gt;
-    &lt;!-- expose a VM transport for in-JVM transport between AMQ and Camel on the server side --&gt;
-    &lt;broker:transportConnector name=&quot;vm&quot; uri=&quot;vm://myBroker&quot;/&gt;
-    &lt;!-- expose a TCP transport for clients to use --&gt;
-    &lt;broker:transportConnector name=&quot;tcp&quot; uri=&quot;tcp://localhost:${tcp.port}&quot;/&gt;
-  &lt;/broker:transportConnectors&gt;
-&lt;/broker:broker&gt;
-]]></script>
-</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;connectionFactory&quot;&gt;
-    &lt;bean class=&quot;org.apache.activemq.spring.ActiveMQConnectionFactory&quot;&gt;
-      &lt;property name=&quot;brokerURL&quot; value=&quot;vm://myBroker&quot;/&gt;
-      &lt;property name=&quot;trustAllPackages&quot; value=&quot;true&quot;/&gt;
-    &lt;/bean&gt;
-  &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
-</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;
-       xmlns:camel=&quot;http://camel.apache.org/schema/spring&quot;
-       xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
-       xsi:schemaLocation=&quot;
-         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
-         http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd&quot;&gt;
-]]></script>
-</div></div><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:camelContext id=&quot;camel-client&quot;&gt;
-  &lt;camel:template id=&quot;camelTemplate&quot;/&gt;
-&lt;/camel:camelContext&gt;
-]]></script>
-</div></div><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 JMSProducer to be able to send messages to a remote Active MQ server --&gt;
-&lt;bean id=&quot;jms&quot; class=&quot;org.apache.activemq.camel.component.ActiveMQComponent&quot;&gt;
-  &lt;property name=&quot;connectionFactory&quot;&gt;
-    &lt;bean class=&quot;org.apache.activemq.spring.ActiveMQConnectionFactory&quot;&gt;
-      &lt;property name=&quot;brokerURL&quot; value=&quot;tcp://localhost:${tcp.port}&quot;/&gt;
-      &lt;property name=&quot;trustAllPackages&quot; value=&quot;true&quot;/&gt;
-    &lt;/bean&gt;
-  &lt;/property&gt;
-&lt;/bean&gt;
-]]></script>
-</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;);
-
-    AbstractApplicationContext context = new ClassPathXmlApplicationContext(&quot;camel-client.xml&quot;);
-
-    // get the camel template for Spring template style sending of messages (= producer)
-    ProducerTemplate camelTemplate = context.getBean(&quot;camelTemplate&quot;, ProducerTemplate.class);
-
-    System.out.println(&quot;Invoking the multiply with 22&quot;);
-    // as opposed to the CamelClientRemoting example we need to define the service URI in this java code
-    int response = (Integer)camelTemplate.sendBody(&quot;jms:queue:numbers&quot;, ExchangePattern.InOut, 22);
-    System.out.println(&quot;... the result is: &quot; + response);
-
-    // we&#39;re done so let&#39;s properly close the application context
-    IOHelper.close(context);
-}
-]]></script>
-</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
-  id=&quot;multiplierProxy&quot;
-  serviceInterface=&quot;org.apache.camel.example.server.Multiplier&quot;
-  serviceUrl=&quot;jms:queue:numbers&quot;/&gt;
-]]></script>
-</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. The&#160;<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 a
 nd 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">
-<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;);
-
-    AbstractApplicationContext context = new ClassPathXmlApplicationContext(&quot;camel-client-remoting.xml&quot;);
-    // just get the proxy to the service and we as the client can use the &quot;proxy&quot; as it was
-    // a local object we are invoking. Camel will under the covers do the remote communication
-    // to the remote ActiveMQ server and fetch the response.
-    Multiplier multiplier = context.getBean(&quot;multiplierProxy&quot;, Multiplier.class);
-
-    System.out.println(&quot;Invoking the multiply with 33&quot;);
-    int response = multiplier.multiply(33);
-    System.out.println(&quot;... the result is: &quot; + response);
-
-    // we&#39;re done so let&#39;s properly close the application context
-    IOHelper.close(context);
-}
-]]></script>
-</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;);
-
-    AbstractApplicationContext context = new ClassPathXmlApplicationContext(&quot;camel-client.xml&quot;);
-    CamelContext camel = context.getBean(&quot;camel-client&quot;, CamelContext.class);
-
-    // get the endpoint from the camel context
-    Endpoint endpoint = camel.getEndpoint(&quot;jms:queue:numbers&quot;);
-
-    // create the exchange used for the communication
-    // we use the in out pattern for a synchronized exchange where we expect a response
-    Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
-    // set the input on the in body
-    // must be correct type to match the expected type of an Integer object
-    exchange.getIn().setBody(11);
-
-    // to send the exchange we need an producer to do it for us
-    Producer producer = endpoint.createProducer();
-    // start the producer so it can operate
-    producer.start();
-
-    // let the producer process the exchange where it does all the work in this oneline of code
-    System.out.println(&quot;Invoking the multiply with 11&quot;);
-    producer.process(exchange);
-
-    // get the response from the out body and cast it to an integer
-    int response = exchange.getOut().getBody(Integer.class);
-    System.out.println(&quot;... the result is: &quot; + response);
-
-    // stopping the JMS producer has the side effect of the &quot;ReplyTo Queue&quot; being properly
-    // closed, making this client not to try any further reads for the replies from the server
-    producer.stop();
-
-    // we&#39;re done so let&#39;s properly close the application context
-    IOHelper.close(context);
-}
-]]></script>
-</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;
+<h2 id="BookTutorials-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</h2><p>&#160;</p><parameter ac:name="title">Thanks</parameter><rich-text-body><p>This tutorial was kindly donated to Apache Camel by Martin Gilday.</p></rich-text-body><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></p><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-A
 bout">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 chan
 nel 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 a
 chieved with Camel's 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 exchange 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="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><rich-text-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></rich-text-body><plain-text-body>mvn archetype:generate -DgroupId=org.example -DartifactId=CamelWithJmsAndSpring
+</plain-text-body><h3 id="BookTutorials-UpdatethePOMwithDependencies">Update the POM with Dependencies</h3><p>First we need to have dependencies for the core Camel jars, spring, jms components, and finally ActiveMQ as the message broker.<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/pom.xml}</plain-text-body>As we use spring xml configuration for the ActiveMQ JMS broker we need this dependency:<plain-text-body>{snippet:id=e2|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/pom.xml}</plain-text-body></p><h2 id="BookTutorials-WritingtheServer">Writing the Server</h2><h3 id="BookTutorials-CreatetheSpringService">Create the Spring Service</h3><p>For this example the Spring service (our business service) on the server will be a simple multiplier which trebles in the received value.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/Multiplier.java}</
 plain-text-body>And the implementation of this service is:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/Treble.java}</plain-text-body>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><p><plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java}</plain-text-body>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 <str
 ong>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.<pl
 ain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml}</plain-text-body>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:<plain-text-body>{snippet:id=e2|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml}</plain-text-body>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.<plain-text-body>{snippet:id=e3|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml}</plain-text-body>The ActiveMQ JMS broker i
 s also configured in this xml file. We set it up to listen on TCP port 61610.<plain-text-body>{snippet:id=e4|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml}</plain-text-body>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:<plain-text-body>{snippet:id=e5|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml}</plain-text-body><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 arbitrar
 y 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 "multiplier" 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>Crea
 tes 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 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>CamelC
 lient 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.<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml}</plain-text-body><plain-text-body>{snippet:id=e2|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml}</plain-text-body><plain-text-body>{snippet:id=e3|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml}</plain-text-body>The client will not use th
 e <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:<plain-text-body>{snippet:id=e1|lang=java|url=camel/
 trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java}</plain-text-body>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.<plain-text-body>{snippet:id=e1|lang=xml|url=camel/trunk/examples/camel-example-spring-jms/src/ma
 in/resources/camel-client-remoting.xml}</plain-text-body>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. The&#160;<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</cod
 e>. 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:<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java}</plain-text-body>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-ClientUsingMess
 ageEndpointEIPPattern">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!<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java}</plain-text-body>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 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 applic
 ation, 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><parameter ac:name="title">pom.xml</parameter><plain-text-body>&lt;build&gt;
   &lt;plugins&gt;
     &lt;plugin&gt;
       &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
@@ -420,13 +154,10 @@ public static void main(final String[] a
     &lt;/plugin&gt;
   &lt;/plugins&gt;
 &lt;/build&gt;
-]]></script>
-</div></div><p>All that is required is a new plugin definition in your Maven POM. As we have already placed our Camel config in the default location (camel-server.xml has been placed in META-INF/spring/) we do not need to tell the plugin where the route definitions are located. Simply run <code>mvn camel:run</code>.</p><h2 id="BookTutorials-UsingCamelJMX">Using Camel JMX</h2><p>Camel has extensive support for JMX and allows us to inspect the Camel Server at runtime. As we have enabled the JMXAgent in our tutorial we can fire up the jconsole and connect to the following service URI: <code>service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel</code>. Notice that Camel will log at INFO level the JMX Connector URI:</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[...
+</plain-text-body><p>All that is required is a new plugin definition in your Maven POM. As we have already placed our Camel config in the default location (camel-server.xml has been placed in META-INF/spring/) we do not need to tell the plugin where the route definitions are located. Simply run <code>mvn camel:run</code>.</p><h2 id="BookTutorials-UsingCamelJMX">Using Camel JMX</h2><p>Camel has extensive support for JMX and allows us to inspect the Camel Server at runtime. As we have enabled the JMXAgent in our tutorial we can fire up the jconsole and connect to the following service URI: <code>service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel</code>. Notice that Camel will log at INFO level the JMX Connector URI:</p><plain-text-body>...
 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="42"></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>
+</plain-text-body><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="43"></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="re
 ct" class="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>
 
@@ -2265,11 +1996,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.rbtoc1501552077925 {padding: 0px;}
-div.rbtoc1501552077925 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1501552077925 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1503649191585 {padding: 0px;}
+div.rbtoc1503649191585 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1503649191585 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style><div class="toc-macro rbtoc1501552077925">
+/*]]>*/</style><div class="toc-macro rbtoc1503649191585">
 <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.