Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-844

...

The Bean Integration rules are used to bind the Message Exchange to the method parameters; so you can annotate the bean to extract headers or other expressions such as XPath or XQuery from the message.

...

So you can bind parameters of the method to the Exchange, the Message or individual headers, properties, the body or other expressions.

Non registry beans

As of Camel 1.5 the Bean Language also supports invoking beans that isn't registered in the Registry. This is usable for quickly to invoke a bean from Java DSL where you don't need to register the bean in the Registry such as the Spring ApplicationContext.

Camel can instantiate the bean and invoke the method if given a class or invoke an already existing instance. This is illustrated from the example below:

Code Block
java
java

        from("activemq:OrdersTopic").
                filter().expression(bean(MyBean.class, "isGoldCustomer")).
                to("activemq:BigSpendersQueue");

The 2nd parameter isGoldCustomer is an optional parameter to explicit set the method name to invoke. If not provided Camel will try to invoke the best suited method. If case of ambiguity Camel will thrown an Exception. In these situations the 2nd parameter can solve this problem. Also the code is more readable if the method name is provided. The 1st parameter can also be an existing instance of a Bean such as:

Code Block
java
java

   private MyBean my;

        from("activemq:OrdersTopic").
                filter().expression(bean(my, "isGoldCustomer")).
                to("activemq:BigSpendersQueue");

Other examples

We have some test cases you can look at if it'll help

...