The bean: component binds beans to Camel message exchanges.
Where beanID can be any string which is used to look up the bean in the Registry
The method name from the bean that will be invoked. If not provided, Camel will try to determine the method itself. In case of ambiguity an exception will be thrown. See Bean Binding for more details. From Camel 2.8 onwards you can specify type qualifiers to pin-point the exact method to use for overloaded methods. From Camel 2.9 onwards you can specify parameter values directly in the method syntax. See more details at Bean Binding.
How to treat the parameters which are passed from the message body; if it is
|Camel 2.17: To configure additional options on the create bean instance from the class name. For example to configure a foo option on the bean, use bean.foo=123.|
You can append query options to the URI in the following format,
The object instance that is used to consume messages must be explicitly registered with the Registry. For example, if you are using Spring you must define the bean in the Spring configuration,
spring.xml; or if you don't use Spring, by registering the bean in JNDI.
You can use the
createProxy() methods on ProxyHelper to create a proxy that will generate BeanExchanges and send them to any endpoint:
Bean as endpoint
Camel also supports invoking Bean as an Endpoint. In the route below:What happens is that when the exchange is routed to the
myBeanCamel will use the Bean Binding to invoke the bean.
The source for the bean is just a plain POJO: Camel will use Bean Binding to invoke the
sayHellomethod, by converting the Exchange's In body to the
Stringtype and storing the output of the method on the Exchange Out body.
Java DSL bean syntax
Java DSL comes with syntactic sugar for the Bean component. Instead of specifying the bean explicitly as the endpoint (i.e.
to("bean:beanName")) you can use the following syntax:
Instead of passing name of the reference to the bean (so that Camel will lookup for it in the registry), you can specify the bean itself:
How bean methods to be invoked are chosen (if they are not specified explicitly through the method parameter) and how parameter values are constructed from the Message are all defined by the Bean Binding mechanism which is used throughout all of the various Bean Integration mechanisms in Camel.