You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rafal Janik <ra...@softwaremind.pl> on 2010/11/03 15:46:46 UTC

Ambiguous method invocations in bean binding

Hi,

I have a question regarding bean binding in camel 
(http://camel.apache.org/bean-binding.html).

In my code there are two methods:

String methodA (String string);
String methodA (InputStream is);

I camel the stream is sent to bean:beanA?method=methodA

with result :

Ambiguous method invocations possible.

I can't (don't want to) annotate method with @Handler, probably the best 
way to do it is to use bean/processor.

Why camel can't match the best method?

regards,


rafal







Re: Ambiguous method invocations in bean binding

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I created a ticket to track this
https://issues.apache.org/activemq/browse/CAMEL-3311

2010/11/4 Paweł Wesołowski <pa...@softwaremind.pl>:
> Hi,
>
> As a user I would like to see both features in camel.
>
> Camel should choose the most obvious method to invoke, the one that doesn't
> need to convert payload, on his own. However, there are situation when it is
> needed to explicitly pick the method to call and if I had to choose from the
> two options given by Claus the one with type=java.io.InputStream is better
> in my opinion.
>
> --
> Paweł Wesołowski
>
> W dniu 11/04/2010 09:36 AM, Christian Müller pisze:
>>
>> Hello!
>>
>> I made the tests and the patch against the latest version (2.6-SNAPSHOT).
>> You will still receive this exception...
>> I'm not sure which way we want to go (because of the note from Claus) -
>> maybe both?
>>
>> Christian
>>
>>
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Ambiguous method invocations in bean binding

Posted by Paweł Wesołowski <pa...@softwaremind.pl>.
Hi,

As a user I would like to see both features in camel.

Camel should choose the most obvious method to invoke, the one that 
doesn't need to convert payload, on his own. However, there are 
situation when it is needed to explicitly pick the method to call and if 
I had to choose from the two options given by Claus the one with 
type=java.io.InputStream is better in my opinion.

--
Paweł Wesołowski

W dniu 11/04/2010 09:36 AM, Christian Müller pisze:
> Hello!
>
> I made the tests and the patch against the latest version (2.6-SNAPSHOT).
> You will still receive this exception...
> I'm not sure which way we want to go (because of the note from Claus) -
> maybe both?
>
> Christian
>
>    


Re: Ambiguous method invocations in bean binding

Posted by Christian Müller <ch...@gmail.com>.
Hello!

I made the tests and the patch against the latest version (2.6-SNAPSHOT).
You will still receive this exception...
I'm not sure which way we want to go (because of the note from Claus) -
maybe both?

Christian

Re: Ambiguous method invocations in bean binding

Posted by Rafal Janik <ra...@softwaremind.pl>.
Thanks a lot,
I'm using camel in fuse 4.2.0.
In version 4.3 there is camel 2.4(.0-fuse) so i will check it.
regards,
rafal
>
>
> On Thu, Nov 4, 2010 at 9:09 AM, Rafal Janik 
> <rafal.janik@softwaremind.pl <ma...@softwaremind.pl>> wrote:
>
>     Hi,
>
>     thanks a lot for all answers!
>
>     Sorry Christian, I forgot about it:
>
>     camel-core (2.2.0)
>     activemq-camel (5.3.0)
>     jdk 1.6.0.21
>          
>
>
>
>
> Camel 2.4 and 2.5 is much better at picking among ambiguous methods. 
> So please consider upgrading.
>
>     regards
>
>     rafal
>
>
>          
>
>
>>     On Thu, Nov 4, 2010 at 12:28 AM, Christian Müller
>>     <ch...@gmail.com>  <ma...@gmail.com>  wrote:
>>        
>>>     Hello Rafal!
>>>
>>>     Please provide more details like the Camel version you are using in further
>>>     questions. Please have a look here:
>>>     http://camel.apache.org/how-can-i-get-help.html
>>>
>>>     However, I assume you have a String as payload in your message. The default
>>>     Camel type converter mechanism is able to convert this payload also into an
>>>     InputStream. This is the reason, why this is ambiguous for Camel...
>>>
>>>     I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
>>>     which fixes this issue. We check whether the message payload is an instance
>>>     of the bean method argument. If so, we will use this method and don't
>>>     convert the body. Any objections?
>>>
>>>          
>>     Camel already has this logic. Its just that the payload most likely
>>     isn't neither an InputStream type or a String type.
>>     And the payload is both convertable to InputStream and String. Hence
>>     Camel don't know which type your prefer.
>>
>>     What we should maybe allow is to end user to specify that
>>
>>     .to("bean:foo?method=methodA&type=java.io.InputStream")
>>
>>     Or like
>>     .to("bean:foo?method=methodA(java.io.InputStream)")
>>
>>
>>
>>
>>        
>>>     Cheers,
>>>     Christian
>>>
>>>          
>>        
>
>
>     -- 
>     Software Mind 	
>
>     *Rafal Janik*
>     Software Engineer
>     *Software Mind S.A.*
>     ul. Bociana 22A
>     31-231 Krakow
>     Poland
>
>     	Tel. +48 12 252 34 00
>     Fax: +48 12 252 34 01
>     Mobile:+48 668 483 613
>     rafal.janik@softwaremind.pl <ma...@softwaremind.pl>
>     www.softwaremind.pl <http://www.softwaremind.pl>
>
>     This email may contain confidential and privileged material for
>     the sole use of the intended recipient(s). Any review, use,
>     retention, distribution or disclosure by others is strictly
>     prohibited. If you are not the intended recipient (or authorized
>     to receive for the recipient), please contact the sender by reply
>     email and delete all copies of this message. Also, email is
>     susceptible to data corruption, interception, tampering,
>     unauthorized amendment and viruses. We only send and receive
>     emails on the basis that we are not liable for any such
>     corruption, interception, tampering, amendment or viruses or any
>     consequence thereof.
>
>
>
>
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com <ma...@fusesource.com>
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
>


-- 
Software Mind 	

*Rafal Janik*
Software Engineer
*Software Mind S.A.*
ul. Bociana 22A
31-231 Krakow
Poland

	Tel. +48 12 252 34 00
Fax: +48 12 252 34 01
Mobile:+48 668 483 613
rafal.janik@softwaremind.pl <ma...@softwaremind.pl>
www.softwaremind.pl <http://www.softwaremind.pl>

This email may contain confidential and privileged material for the sole 
use of the intended recipient(s). Any review, use, retention, 
distribution or disclosure by others is strictly prohibited. If you are 
not the intended recipient (or authorized to receive for the recipient), 
please contact the sender by reply email and delete all copies of this 
message. Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive 
emails on the basis that we are not liable for any such corruption, 
interception, tampering, amendment or viruses or any consequence thereof.


Re: Ambiguous method invocations in bean binding

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Nov 4, 2010 at 9:09 AM, Rafal Janik <ra...@softwaremind.pl>wrote:

>  Hi,
>
> thanks a lot for all answers!
>
> Sorry Christian, I forgot about it:
>
> camel-core (2.2.0)
> activemq-camel (5.3.0)
> jdk 1.6.0.21
>
>
>


Camel 2.4 and 2.5 is much better at picking among ambiguous methods. So
please consider upgrading.



>  regards
>
> rafal
>
>
>
>
>  On Thu, Nov 4, 2010 at 12:28 AM, Christian Müller<ch...@gmail.com> <ch...@gmail.com> wrote:
>
>
>  Hello Rafal!
>
> Please provide more details like the Camel version you are using in further
> questions. Please have a look here:http://camel.apache.org/how-can-i-get-help.html
>
> However, I assume you have a String as payload in your message. The default
> Camel type converter mechanism is able to convert this payload also into an
> InputStream. This is the reason, why this is ambiguous for Camel...
>
> I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
> which fixes this issue. We check whether the message payload is an instance
> of the bean method argument. If so, we will use this method and don't
> convert the body. Any objections?
>
>
>
>  Camel already has this logic. Its just that the payload most likely
> isn't neither an InputStream type or a String type.
> And the payload is both convertable to InputStream and String. Hence
> Camel don't know which type your prefer.
>
> What we should maybe allow is to end user to specify that
>
> .to("bean:foo?method=methodA&type=java.io.InputStream")
>
> Or like
> .to("bean:foo?method=methodA(java.io.InputStream)")
>
>
>
>
>
>
>  Cheers,
> Christian
>
>
>
>
>
> --
>   [image: Software Mind]
>
> *Rafal Janik*
> Software Engineer   *Software Mind S.A.*
> ul. Bociana 22A
> 31-231 Krakow
> Poland
>
>  Tel. +48 12 252 34 00
> Fax: +48 12 252 34 01
> Mobile:+48 668 483 613
> rafal.janik@softwaremind.pl
> www.softwaremind.pl
>
>   This email may contain confidential and privileged material for the sole
> use of the intended recipient(s). Any review, use, retention, distribution
> or disclosure by others is strictly prohibited. If you are not the intended
> recipient (or authorized to receive for the recipient), please contact the
> sender by reply email and delete all copies of this message. Also, email is
> susceptible to data corruption, interception, tampering, unauthorized
> amendment and viruses. We only send and receive emails on the basis that we
> are not liable for any such corruption, interception, tampering, amendment
> or viruses or any consequence thereof.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Ambiguous method invocations in bean binding

Posted by Rafal Janik <ra...@softwaremind.pl>.
Hi,

thanks a lot for all answers!

Sorry Christian, I forgot about it:

camel-core (2.2.0)
activemq-camel (5.3.0)
jdk 1.6.0.21


regards

rafal




> On Thu, Nov 4, 2010 at 12:28 AM, Christian Müller
> <ch...@gmail.com>  wrote:
>    
>> Hello Rafal!
>>
>> Please provide more details like the Camel version you are using in further
>> questions. Please have a look here:
>> http://camel.apache.org/how-can-i-get-help.html
>>
>> However, I assume you have a String as payload in your message. The default
>> Camel type converter mechanism is able to convert this payload also into an
>> InputStream. This is the reason, why this is ambiguous for Camel...
>>
>> I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
>> which fixes this issue. We check whether the message payload is an instance
>> of the bean method argument. If so, we will use this method and don't
>> convert the body. Any objections?
>>
>>      
> Camel already has this logic. Its just that the payload most likely
> isn't neither an InputStream type or a String type.
> And the payload is both convertable to InputStream and String. Hence
> Camel don't know which type your prefer.
>
> What we should maybe allow is to end user to specify that
>
> .to("bean:foo?method=methodA&type=java.io.InputStream")
>
> Or like
> .to("bean:foo?method=methodA(java.io.InputStream)")
>
>
>
>
>    
>> Cheers,
>> Christian
>>
>>      
>
>
>    


-- 
Software Mind 	

*Rafal Janik*
Software Engineer
*Software Mind S.A.*
ul. Bociana 22A
31-231 Krakow
Poland

	Tel. +48 12 252 34 00
Fax: +48 12 252 34 01
Mobile:+48 668 483 613
rafal.janik@softwaremind.pl <ma...@softwaremind.pl>
www.softwaremind.pl <http://www.softwaremind.pl>

This email may contain confidential and privileged material for the sole 
use of the intended recipient(s). Any review, use, retention, 
distribution or disclosure by others is strictly prohibited. If you are 
not the intended recipient (or authorized to receive for the recipient), 
please contact the sender by reply email and delete all copies of this 
message. Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive 
emails on the basis that we are not liable for any such corruption, 
interception, tampering, amendment or viruses or any consequence thereof.


Re: Ambiguous method invocations in bean binding

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Nov 4, 2010 at 12:28 AM, Christian Müller
<ch...@gmail.com> wrote:
> Hello Rafal!
>
> Please provide more details like the Camel version you are using in further
> questions. Please have a look here:
> http://camel.apache.org/how-can-i-get-help.html
>
> However, I assume you have a String as payload in your message. The default
> Camel type converter mechanism is able to convert this payload also into an
> InputStream. This is the reason, why this is ambiguous for Camel...
>
> I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
> which fixes this issue. We check whether the message payload is an instance
> of the bean method argument. If so, we will use this method and don't
> convert the body. Any objections?
>

Camel already has this logic. Its just that the payload most likely
isn't neither an InputStream type or a String type.
And the payload is both convertable to InputStream and String. Hence
Camel don't know which type your prefer.

What we should maybe allow is to end user to specify that

.to("bean:foo?method=methodA&type=java.io.InputStream")

Or like
.to("bean:foo?method=methodA(java.io.InputStream)")




> Cheers,
> Christian
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Ambiguous method invocations in bean binding

Posted by Hadrian Zbarcea <hz...@gmail.com>.
It is a good improvement, +1 from me too. Christian, go for it!
Hadrian

On Nov 3, 2010, at 11:40 PM, Willem Jiang wrote:

> It makes sense, +1 for the change.
> 
> On 11/4/10 7:28 AM, Christian Müller wrote:
>> Hello Rafal!
>> 
>> Please provide more details like the Camel version you are using in
>> further questions. Please have a look here:
>> http://camel.apache.org/how-can-i-get-help.html
>> 
>> However, I assume you have a String as payload in your message. The
>> default Camel type converter mechanism is able to convert this payload
>> also into an InputStream. This is the reason, why this is ambiguous for
>> Camel...
>> 
>> I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
>> which fixes this issue. We check whether the message payload is an
>> instance of the bean method argument. If so, we will use this method and
>> don't convert the body. Any objections?
>> 
>> Cheers,
>> Christian
> 
> 
> -- 
> Willem
> ----------------------------------
> FuseSource
> Web: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: willemjiang


Re: Ambiguous method invocations in bean binding

Posted by Willem Jiang <wi...@gmail.com>.
It makes sense, +1 for the change.

On 11/4/10 7:28 AM, Christian Müller wrote:
> Hello Rafal!
>
> Please provide more details like the Camel version you are using in
> further questions. Please have a look here:
> http://camel.apache.org/how-can-i-get-help.html
>
> However, I assume you have a String as payload in your message. The
> default Camel type converter mechanism is able to convert this payload
> also into an InputStream. This is the reason, why this is ambiguous for
> Camel...
>
> I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
> which fixes this issue. We check whether the message payload is an
> instance of the bean method argument. If so, we will use this method and
> don't convert the body. Any objections?
>
> Cheers,
> Christian


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Re: Ambiguous method invocations in bean binding

Posted by Christian Müller <ch...@gmail.com>.
Hello Rafal!

Please provide more details like the Camel version you are using in further
questions. Please have a look here:
http://camel.apache.org/how-can-i-get-help.html

However, I assume you have a String as payload in your message. The default
Camel type converter mechanism is able to convert this payload also into an
InputStream. This is the reason, why this is ambiguous for Camel...

I wondering, if we SHOULD make Camel a bit smarter here. I made a patch
which fixes this issue. We check whether the message payload is an instance
of the bean method argument. If so, we will use this method and don't
convert the body. Any objections?

Cheers,
Christian