You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by edhansen42 <ed...@vsp.com> on 2014/12/02 05:28:39 UTC

Seeking understanding of Parameter Binding in Bean invocation

I've read the following wiki page on Bean Binding:
https://cwiki.apache.org/confluence/display/CAMEL/Bean+Binding

Which was helpful, but still left me with a question.  I'm using Camel
version 2.11.1.

I've got a beanRef in my route like this:
.beanRef("myBean", "retrieve(${header.field1}, ${header.field2},
${header.field3})")

My bean method signature is like this:
public MyObject retrieve(String field1, String field2, String field3)

There are two cases that are causing me grief.  

First, if the three fields are null, the headers are null, and the body of
the in message contains a MessageContentsList with a value of [null, null,
null].  In this case it looks like Camel is fine with the second two
parameters being null, but really wants to pass a String in the first
parameter.  The field1 header value is null, so it tries to get a String
from the body.  The MessageContentsList from the body doesn't contain a
String, so Camel throws an error saying it can't convert a
MessageContentsList to a String.

Second, if field1 and field2 are null, but field3 contains a value, Camel
pulls the value from the field3 header and passes it to the bean method as
the third parameter.  But Camel still really wants to pass a String for the
first parameter, so it goes through the MessageContentsList in the body and
finds a String, which in this case happens to be the third value (field3). 
So the bean method gets passed the field3 value for the first and third
parameters and null for the second parameter.

What I want to have happen is to just pass what comes through in the headers
as I've expressed in the route.  Is that possible? 



--
View this message in context: http://camel.465427.n5.nabble.com/Seeking-understanding-of-Parameter-Binding-in-Bean-invocation-tp5759896.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Seeking understanding of Parameter Binding in Bean invocation

Posted by edhansen42 <ed...@vsp.com>.
Thanks Taariq - I'll give 2.14.0 a try!



--
View this message in context: http://camel.465427.n5.nabble.com/Seeking-understanding-of-Parameter-Binding-in-Bean-invocation-tp5759896p5760336.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Seeking understanding of Parameter Binding in Bean invocation

Posted by taariq <ta...@gmail.com>.
Hi

I've attached a test that reproduces this in 2.11.1, but not in 2.14.0
Are you able to upgrade?

BeanBindingTest.java
<http://camel.465427.n5.nabble.com/file/n5760124/BeanBindingTest.java>  



--
View this message in context: http://camel.465427.n5.nabble.com/Seeking-understanding-of-Parameter-Binding-in-Bean-invocation-tp5759896p5760124.html
Sent from the Camel - Users mailing list archive at Nabble.com.