Camel - Bean: Look up bean and invoke
Camel acts as a service activator using the bean component, which sits between the caller and the bean. At compile time, there are no direct bindings, and the JVM can’t link the caller to the bean; Camel must resolve this at runtime.
Figure below shows how the bean component uses the registry to look up the bean to invoke.
At runtime, a Camel exchange is routed, and at a given point in the route, it reaches the bean component. The bean component (BeanProcessor) then processes the exchange, performing these general steps:
- Looks up the bean in the registry
- Selects the method to invoke on the bean
- Binds to the parameters of the selected method (for example, using the body of the input message as a parameter)
- Invokes the method
- Handles any invocation errors that occur (any exceptions thrown from the bean will be set on the Camel exchange for further error handling)
- Sets the method’s reply (if there is one) as the body on the output message on the Camel exchange