camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ee7arh <>
Subject Re: Is it possible to overload a bean method?
Date Thu, 05 Mar 2009 08:40:37 GMT

Thanks for the feedback,

It looks like we are talking about the same use case. In my example, all my
methods had the same name, but each method had a different parameter
(Object1, 2 and 3). Each of these parameter types inheritted from "Objectn".
So each method did have a different concrete sub-type although all are
instances of Objectn. In your example, your 3rd method has a different
name... was that a typo?

I could certainly use different method names, it would just mean I have to
have some more logic in my RouteBuilder. At the moment, I just send objects
off the queue to the same bean method and ask it to take care of selecting
the correct one by overloading.

Thanks and Regards

ee7arh wrote:
> Hi,
> I have a bean defined which has 3 methods all with same name but with
> different arguements. I would like to route messages from a queue to this
> bean and depending on the object type I was hoping that the correct method
> would get called by overloading.
> Instead i get the error:
> org.apache.camel.NoTypeConversionAvailableException: No type converter
> available to convert from type:.....
> I noticed that the first method defined in my bean caused this error so it
> looks like Camel takes the 1st method and tries (and fails) to convert the
> message.
> here is my bean definition:
> @Service(value = "serviceEventGenerator")
> public class ServiceEventGenerator {
>     public ArrayList<ServiceEvent> generateServiceEvents(Object1 event) {}
>     public ArrayList<ServiceEvent> generateServiceEvents(Object2 event) {}
>     public ArrayList<ServiceEvent> generateServiceEvents(Object3 event) {}
> }
> (Incidentally in my example, Object 1,2 and 3 all extend from a parent
> class "Objectn".)
> And my route:
> from("jms:queue:unmarshalledEventsQueue")
>             .to("log:unmarshalledEventLogger?level=INFO")
> .to("bean:serviceEventGenerator?methodName=generateServiceEvents")
> Thanks in advance for any help
> Andrew

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message