Author: buildbot Date: Tue Sep 6 03:27:28 2016 New Revision: 996761 Log: Production update by buildbot for camel
Modified: websites/production/camel/content/bean-binding.html websites/production/camel/content/book-cookbook.html websites/production/camel/content/book-in-one-page.html websites/production/camel/content/cache/main.pageCache websites/production/camel/content/spring-remoting.html Modified: websites/production/camel/content/bean-binding.html ============================================================================== --- websites/production/camel/content/bean-binding.html (original) +++ websites/production/camel/content/bean-binding.html Tue Sep 6 03:27:28 2016 @@ -86,7 +86,13 @@ <tbody> <tr> <td valign="top" width="100%"> -<div class="wiki-content maincontent"><h2 id="BeanBinding-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="BeanBinding-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (se e below for more details).</li></ul></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return val ue is set on the outbound message body.</p><h3 id="BeanBinding-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bi nd the body of the <a shape="rect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<div class="wiki-content maincontent"><h2 id="BeanBinding-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="BeanBinding-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (se e below for more details).</li></ul></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return val ue is set on the outbound message body. </p><h3 id="BeanBinding-Asynchronousprocessing">Asynchronous processing</h3><p>From <strong>Camel 2.18</strong> onwards you can return a CompletionStage implementation (e.g. a CompletableFuture) to implement asynchronous processing.</p><p>Please be sure to properly complete the CompletionStage with the result or exception, including any timeout handling. Exchange processing would wait for completion and would not impose any timeouts automatically. It's extremely useful to monitor <a shape="rect" class="external-link" href="https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/InflightRepository.html">Inflight repository</a> for any hanging messages.</p><p>Note that completing with "null" won't set outbody message body to null, but would keep message intact. This is useful to support methods that don't modify exchange and return CompletableFuture<Void>. To set body to null, just add Exchange me thod parameter and directly modify exchange messages.</p><p>Examples:</p><p>Simple asynchronous processor, modifying message body.</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 CompletableFuture<String> doSomethingAsync(String body)]]></script> +</div></div><p>Composite processor that do not modify exchange</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 CompletableFuture<Void> doSomethingAsync(String body) { + return CompletableFuture.allOf(doA(body), doB(body), doC()); +}]]></script> +</div></div><h3 id="BeanBinding-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape="re ct" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</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 String doSomething(String body) ]]></script> </div></div><p>In the following sample we got one of the automatically-bound types as well - for instance, a <code>Registry</code> that we can use to lookup beans.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -203,19 +209,19 @@ public static final class MyBean { } ]]></script> -</div></div><p>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> +</div></div>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(String,String)") .to("mock:result"); ]]></script> -</div></div><p>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> +</div></div>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(*,*)") .to("mock:result"); ]]></script> -</div></div><p>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ .bean(OrderService.class, "doSomething(com.foo.MyOrder)") ]]></script> </div></div><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>Camel currently only supports either specifying parameter binding or type per parameter in the method name option. You <strong>cannot</strong> specify both at the same time, such as</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> Modified: websites/production/camel/content/book-cookbook.html ============================================================================== --- websites/production/camel/content/book-cookbook.html (original) +++ websites/production/camel/content/book-cookbook.html Tue Sep 6 03:27:28 2016 @@ -213,7 +213,13 @@ public class MySimpleIdGenerator { </div></div> <p>Groovy supports GStrings that is like a template where we can insert $ placeholders that will be evaluated by Groovy.</p> -<h2 id="Bookcookbook-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="Bookcookbook-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li></ul> </li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/maven /current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound message bo dy.</p><h3 id="Bookcookbook-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape="rect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<h2 id="Bookcookbook-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="Bookcookbook-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li></ul> </li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/maven /current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound message bo dy. </p><h3 id="Bookcookbook-Asynchronousprocessing">Asynchronous processing</h3><p>From <strong>Camel 2.18</strong> onwards you can return a CompletionStage implementation (e.g. a CompletableFuture) to implement asynchronous processing.</p><p>Please be sure to properly complete the CompletionStage with the result or exception, including any timeout handling. Exchange processing would wait for completion and would not impose any timeouts automatically. It's extremely useful to monitor <a shape="rect" class="external-link" href="https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/InflightRepository.html">Inflight repository</a> for any hanging messages.</p><p>Note that completing with "null" won't set outbody message body to null, but would keep message intact. This is useful to support methods that don't modify exchange and return CompletableFuture<Void>. To set body to null, just add Exchange method parameter and directly modify exchange messages.</p><p>Examples:</p><p>Simple asynchronous processor, modifying message body.</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 CompletableFuture<String> doSomethingAsync(String body)]]></script> +</div></div><p>Composite processor that do not modify exchange</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 CompletableFuture<Void> doSomethingAsync(String body) { + return CompletableFuture.allOf(doA(body), doB(body), doC()); +}]]></script> +</div></div><h3 id="Bookcookbook-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape="r ect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</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 String doSomething(String body) ]]></script> </div></div><p>In the following sample we got one of the automatically-bound types as well - for instance, a <code>Registry</code> that we can use to lookup beans.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -330,19 +336,19 @@ public static final class MyBean { } ]]></script> -</div></div><p>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> +</div></div>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(String,String)") .to("mock:result"); ]]></script> -</div></div><p>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> +</div></div>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(*,*)") .to("mock:result"); ]]></script> -</div></div><p>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ .bean(OrderService.class, "doSomething(com.foo.MyOrder)") ]]></script> </div></div><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>Camel currently only supports either specifying parameter binding or type per parameter in the method name option. You <strong>cannot</strong> specify both at the same time, such as</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> Modified: websites/production/camel/content/book-in-one-page.html ============================================================================== --- websites/production/camel/content/book-in-one-page.html (original) +++ websites/production/camel/content/book-in-one-page.html Tue Sep 6 03:27:28 2016 @@ -1275,7 +1275,13 @@ public class MySimpleIdGenerator { </div></div> <p>Groovy supports GStrings that is like a template where we can insert $ placeholders that will be evaluated by Groovy.</p> -<h2 id="BookInOnePage-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="BookInOnePage-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li></u l></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/mav en/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound message body.</p><h3 id="BookInOnePage-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape="rec t" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<h2 id="BookInOnePage-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="BookInOnePage-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li></u l></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/mav en/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound message body. </p><h3 id="BookInOnePage-Asynchronousprocessing">Asynchronous processing</h3><p>From <strong>Camel 2.18</strong> onwards you can return a CompletionStage implementation (e.g. a CompletableFuture) to implement asynchronous processing.</p><p>Please be sure to properly complete the CompletionStage with the result or exception, including any timeout handling. Exchange processing would wait for completion and would not impose any timeouts automatically. It's extremely useful to monitor <a shape="rect" class="external-link" href="https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/InflightRepository.html">Inflight repository</a> for any hanging messages.</p><p>Note that completing with "null" won't set outbody message body to null, but would keep message intact. This is useful to support methods that don't modify exchange and return CompletableFuture<Void>. To set body to null, just add Exchange method parameter and directly modi fy exchange messages.</p><p>Examples:</p><p>Simple asynchronous processor, modifying message body.</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 CompletableFuture<String> doSomethingAsync(String body)]]></script> +</div></div><p>Composite processor that do not modify exchange</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 CompletableFuture<Void> doSomethingAsync(String body) { + return CompletableFuture.allOf(doA(body), doB(body), doC()); +}]]></script> +</div></div><h3 id="BookInOnePage-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape=" rect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</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 String doSomething(String body) ]]></script> </div></div><p>In the following sample we got one of the automatically-bound types as well - for instance, a <code>Registry</code> that we can use to lookup beans.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -1392,19 +1398,19 @@ public static final class MyBean { } ]]></script> -</div></div><p>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> +</div></div>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(String,String)") .to("mock:result"); ]]></script> -</div></div><p>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> +</div></div>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(*,*)") .to("mock:result"); ]]></script> -</div></div><p>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ .bean(OrderService.class, "doSomething(com.foo.MyOrder)") ]]></script> </div></div><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>Camel currently only supports either specifying parameter binding or type per parameter in the method name option. You <strong>cannot</strong> specify both at the same time, such as</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -3619,11 +3625,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="BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</h2><p> </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="BookInOnePage-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.rbtoc1472732282314 {padding: 0px;} -div.rbtoc1472732282314 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1472732282314 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1473131969937 {padding: 0px;} +div.rbtoc1473131969937 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1473131969937 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1472732282314"> +/*]]>*/</style></p><div class="toc-macro rbtoc1473131969937"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</a></li><li><a shape="rect" href="#BookInOnePage-Preface">Preface</a></li><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-About">About</a></li><li><a shape="rect" href="#BookInOnePage-CreatetheCamelProject">Create the Camel Project</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-UpdatethePOMwithDependencies">Update the POM with Dependencies</a></li></ul> </li><li><a shape="rect" href="#BookInOnePage-WritingtheServer">Writing the Server</a> @@ -5738,11 +5744,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.rbtoc1472732282548 {padding: 0px;} -div.rbtoc1472732282548 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1472732282548 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1473131970228 {padding: 0px;} +div.rbtoc1473131970228 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1473131970228 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style><div class="toc-macro rbtoc1472732282548"> +/*]]>*/</style><div class="toc-macro rbtoc1473131970228"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialusingAxis1.4withApacheCamel">Tutorial using Axis 1.4 with Apache Camel</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-Introduction">Introduction</a></li><li><a shape="rect" href="#BookInOnePage-SettinguptheprojecttorunAxis">Setting up the project to run Axis</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Maven2">Maven 2</a></li><li><a shape="rect" href="#BookInOnePage-wsdl">wsdl</a></li><li><a shape="rect" href="#BookInOnePage-ConfiguringAxis">Configuring Axis</a></li><li><a shape="rect" href="#BookInOnePage-RunningtheExample">Running the Example</a></li></ul> @@ -17169,11 +17175,11 @@ template.send("direct:alias-verify& ]]></script> </div></div><p></p><h3 id="BookInOnePage-SeeAlso.28">See Also</h3> <ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul><ul><li><a shape="rect" href="crypto.html">Crypto</a> Crypto is also available as a <a shape="rect" href="data-format.html">Data Format</a></li></ul> <h2 id="BookInOnePage-CXFComponent">CXF Component</h2><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using CXF as a consumer, the <a shape="rect" href="cxf-bean-component.html">CXF Bean Component</a> allows you to factor out how message payloads are received from their processing as a RESTful or SOAP web service. This has the potential of using a multitude of transports to consume web services. The bean component's configuration is also simpler and provides the fastest method to implement web services using Camel and CXF.</p></div></div><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using CXF in streaming modes (see DataFormat option), then also read about <a shape="rect" href="stream-caching.html">Stream caching</a>.</p></div></div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1472732286766 {padding: 0px;} -div.rbtoc1472732286766 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1472732286766 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1473132008847 {padding: 0px;} +div.rbtoc1473132008847 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1473132008847 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1472732286766"> +/*]]>*/</style></p><div class="toc-macro rbtoc1473132008847"> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-CXFComponent">CXF Component</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-URIformat">URI format</a></li><li><a shape="rect" href="#BookInOnePage-Options">Options</a> <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Thedescriptionsofthedataformats">The descriptions of the dataformats</a> Modified: websites/production/camel/content/cache/main.pageCache ============================================================================== Binary files - no diff available. Modified: websites/production/camel/content/spring-remoting.html ============================================================================== --- websites/production/camel/content/spring-remoting.html (original) +++ websites/production/camel/content/spring-remoting.html Tue Sep 6 03:27:28 2016 @@ -164,7 +164,13 @@ <p>For more details see <a shape="rect" href="using-exchange-pattern-annotations.html">Using Exchange Pattern Annotations</a></p> -<h2 id="SpringRemoting-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="SpringRemoting-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li>< /ul></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/m aven/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound messag e body.</p><h3 id="SpringRemoting-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape=" rect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</code>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<h2 id="SpringRemoting-BeanBinding">Bean Binding</h2><p>Bean Binding in Camel defines both which methods are invoked and also how the <a shape="rect" href="message.html">Message</a> is converted into the parameters of the method when it is invoked.</p><h3 id="SpringRemoting-Choosingthemethodtoinvoke">Choosing the method to invoke</h3><p>The binding of a Camel <a shape="rect" href="message.html">Message</a> to a bean method call can occur in different ways, in the following order of importance:</p><ul><li>if the message contains the header <strong>CamelBeanMethodName</strong> then that method is invoked, converting the body to the type of the method's argument.<ul><li>From <strong>Camel 2.8</strong> onwards you can qualify parameter types to select exactly which method to use among overloads with the same name (see below for more details).</li><li>From <strong>Camel 2.9</strong> onwards you can specify parameter values directly in the method option (see below for more details).</li>< /ul></li><li>you can explicitly specify the method name in the <a shape="rect" href="dsl.html">DSL</a> or when using <a shape="rect" href="pojo-consuming.html">POJO Consuming</a> or <a shape="rect" href="pojo-producing.html">POJO Producing</a></li><li>if the bean has a method marked with the <code>@Handler</code> annotation, then that method is selected</li><li>if the bean can be converted to a <a shape="rect" href="processor.html">Processor</a> using the <a shape="rect" href="type-converter.html">Type Converter</a> mechanism, then this is used to process the message. The <a shape="rect" href="activemq.html">ActiveMQ</a> component uses this mechanism to allow any JMS MessageListener to be invoked directly by Camel without having to write any integration glue code. You can use the same mechanism to integrate Camel into any other messaging/remoting frameworks.</li><li>if the body of the message can be converted to a <a shape="rect" class="external-link" href="http://camel.apache.org/m aven/current/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html">BeanInvocation</a> (the default payload used by the <a shape="rect" class="external-link" href="http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html">ProxyHelper</a>) component - then that is used to invoke the method and pass its arguments</li><li>otherwise the type of the body is used to find a matching method; an error is thrown if a single method cannot be chosen unambiguously.</li><li>you can also use Exchange as the parameter itself, but then the return type must be void.</li><li>if the bean class is private (or package-private), interface methods will be preferred (from <strong>Camel 2.9</strong> onwards) since Camel can't invoke class methods on such beans</li></ul><p>In cases where Camel cannot choose a method to invoke, an <code>AmbiguousMethodCallException</code> is thrown.</p><p>By default the return value is set on the outbound messag e body. </p><h3 id="SpringRemoting-Asynchronousprocessing">Asynchronous processing</h3><p>From <strong>Camel 2.18</strong> onwards you can return a CompletionStage implementation (e.g. a CompletableFuture) to implement asynchronous processing.</p><p>Please be sure to properly complete the CompletionStage with the result or exception, including any timeout handling. Exchange processing would wait for completion and would not impose any timeouts automatically. It's extremely useful to monitor <a shape="rect" class="external-link" href="https://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/spi/InflightRepository.html">Inflight repository</a> for any hanging messages.</p><p>Note that completing with "null" won't set outbody message body to null, but would keep message intact. This is useful to support methods that don't modify exchange and return CompletableFuture<Void>. To set body to null, just add Exchange method parameter and directly m odify exchange messages.</p><p>Examples:</p><p>Simple asynchronous processor, modifying message body.</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 CompletableFuture<String> doSomethingAsync(String body)]]></script> +</div></div><p>Composite processor that do not modify exchange</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 CompletableFuture<Void> doSomethingAsync(String body) { + return CompletableFuture.allOf(doA(body), doB(body), doC()); +}]]></script> +</div></div><h3 id="SpringRemoting-Parameterbinding">Parameter binding</h3><p>When a method has been chosen for invocation, Camel will bind to the parameters of the method.</p><p>The following Camel-specific types are automatically bound:</p><ul class="alternate"><li><code>org.apache.camel.Exchange</code></li><li><code>org.apache.camel.Message</code></li><li><code>org.apache.camel.CamelContext</code></li><li><code>org.apache.camel.TypeConverter</code></li><li><code>org.apache.camel.spi.Registry</code></li><li><code>java.lang.Exception</code></li></ul><p>So, if you declare any of these types, they will be provided by Camel. <strong>Note that <code>Exception</code> will bind to the caught exception of the <a shape="rect" href="exchange.html">Exchange</a></strong> - so it's often usable if you employ a <a shape="rect" href="pojo.html">Pojo</a> to handle, e.g., an <code>onException</code> route.</p><p>What is most interesting is that Camel will also try to bind the body of the <a shape= "rect" href="exchange.html">Exchange</a> to the first parameter of the method signature (albeit not of any of the types above). So if, for instance, we declare a parameter as <code>String body</code>, then Camel will bind the IN body to this type. Camel will also automatically convert to the type declared in the method signature.</p><p>Let's review some examples:</p><p>Below is a simple method with a body binding. Camel will bind the IN body to the <code>body</code> parameter and convert it to a <code>String</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 String doSomething(String body) ]]></script> </div></div><p>In the following sample we got one of the automatically-bound types as well - for instance, a <code>Registry</code> that we can use to lookup beans.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> @@ -281,19 +287,19 @@ public static final class MyBean { } ]]></script> -</div></div><p>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> +</div></div>Then the <code>MyBean</code> has 2 overloaded methods with the names <code>hello</code> and <code>times</code>. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(String,String)") .to("mock:result"); ]]></script> -</div></div><p>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> +</div></div>We can also use a <code>*</code> as wildcard so we can just say we want to execute the method with 2 parameters we do<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Invoke 2 parameter method using wildcard</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ from("direct:start") .bean(MyBean.class, "hello(*,*)") .to("mock:result"); ]]></script> -</div></div><p>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div>By default Camel will match the type name using the simple name, e.g. any leading package name will be disregarded. However if you want to match using the FQN, then specify the FQN type and Camel will leverage that. So if you have a <code>com.foo.MyOrder</code> and you want to match against the FQN, and <strong>not</strong> the simple name "MyOrder", then follow this example:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ .bean(OrderService.class, "doSomething(com.foo.MyOrder)") ]]></script> </div></div><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>Camel currently only supports either specifying parameter binding or type per parameter in the method name option. You <strong>cannot</strong> specify both at the same time, such as</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">