Bean and method bindings
During step 2, when the BeanProcessor
selects the method to invoke, the message/method bindings can occur in different ways. Camel tries the following steps to resolve the bean method:
- If the incoming message (
in
message) contains theCamelBeanMethodName
header, then this method is invoked, converting thein
message body to the type of the method's argument. - You can specify the method name directly in the route definition (on the bean endpoint).
- If the bean contains a method annotated with
@Handler
, then this method is invoked. - If the bean can be converted to a processor (containing the
process()
method), we fall back to the regular processor usage as seen in the previous chapter. - If the body of the in message can be converted to a
org.apache.camel.component.bean.BeanInvocation
component, then it's the result of thegetMethod()
method, which is used as the method name. - Otherwise, the body type of the in message is used to find a matching method.
Several exceptions...