...
By default the return value is set on the outbound message body.
Asynchronous processing
From Camel 2.18 onwards you can return a CompletionStage implementation (e.g. a CompletableFuture) to implement asynchronous processing.
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 Inflight repository for any hanging messages.
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.
Examples:
Simple asynchronous processor, modifying message body.
Code Block | ||
---|---|---|
| ||
public CompletableFuture<String> doSomethingAsync(String body) |
Composite processor that do not modify exchange
Code Block | ||
---|---|---|
| ||
public CompletableFuture<Void> doSomethingAsync(String body) {
return CompletableFuture.allOf(doA(body), doB(body), doC());
} |
Parameter binding
When a method has been chosen for invocation, Camel will bind to the parameters of the method.
...
If you have a Bean with overloaded methods, you can now specify parameter types in the method name so Camel can match the method you intend to use.
Given the following bean:
Wiki Markup |
---|
{snippet:id=e1|lang=java|title=MyBean|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanOverloadedMethodTest.java} |
MyBean
has 2 overloaded methods with the names hello
and times
. So if we want to use the method which has 2 parameters we can do as follows in the Camel route:Wiki Markup |
---|
{snippet:id=e2|lang=java|title=Invoke 2 parameter method|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanOverloadedMethodTest.java} |
*
as wildcard so we can just say we want to execute the method with 2 parameters we doWiki Markup |
---|
{snippet:id=e3|lang=java|title=Invoke 2 parameter method using wildcard|url=camel/trunk/camel-core/src/test/java/org/apache/camel/component/bean/BeanOverloadedMethodTest.java} |
com.foo.MyOrder
and you want to match against the FQN, and not the simple name "MyOrder", then follow this example:...