...
Code Block |
---|
|
from("activemq:topic:OrdersTopic").
filter().expression(BeanLanguage(MyBean.class, "isGoldCustomer")).
to("activemq:BigSpendersQueue");
|
There is a nicer way of doing the above as we can leverage the fact the bean
is included in the RouteBuilder
. However this only works when referring to either a reference or a class name of the bean. The example below you have to use the BeanLanguage.bean
. This is due to java cannot distinguish between a String and Object parameter when you either want to use a reference or a instance. 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 |
---|
|
private MyBean my;
from("activemq:topic:OrdersTopic").
filter().expression(BeanLanguage.bean(MyBean.classmy, "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 In Camel 2.2 onwards you can avoid the BeanLanguage
and have it just as:
Code Block |
---|
|
private MyBean my;
from("activemq:topic:OrdersTopic").
filter().expression(BeanLanguage.bean(my, "isGoldCustomer")).
to("activemq:BigSpendersQueue");
|
...