Problem with bean overloaded method invocation in route

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with bean overloaded method invocation in route

senthil.arumugam
Hi,

I am trying to invoke a method from my route configured with camel-spring to persist the consumed message to DB.

my route is like,
<camel:route>
  <camel:from uri="queue:foo" />
  <camel:bean ref="foo" method="save" />
  <camel:to uri="queue:foo-saved" />
</camel:route>

The bean class Foo has two methods, which are overloaded.

e.g.

public void save(Collection<Foo> foos) {}

public void save(Foo foo) {}

When the consumer starts listening to the message, I am getting AmbiguousCallException.

I can change my method name and make it works. But I would like to know if there were more elegant way to handle this.

Thanks in advance.

- SK
Reply | Threaded
Open this post in threaded view
|

Re: Problem with bean overloaded method invocation in route

Willem.Jiang
Administrator
Hi

You can add @Handle annotation to let camel know which method you want
it to pick.

You can find more detail information from the section4.4.2 of Camel in
Action.

Willem

senthil.arumugam wrote:

> Hi,
>
> I am trying to invoke a method from my route configured with camel-spring to
> persist the consumed message to DB.
>
> my route is like,
> <camel:route>
>   <camel:from uri="queue:foo" />
>   <camel:bean ref="foo" method="save" />
>   <camel:to uri="queue:foo-saved" />
> </camel:route>
>
> The bean class Foo has two methods, which are overloaded.
>
> e.g.
>
> public void save(Collection<Foo> foos) {}
>
> public void save(Foo foo) {}
>
> When the consumer starts listening to the message, I am getting
> AmbiguousCallException.
>
> I can change my method name and make it works. But I would like to know if
> there were more elegant way to handle this.
>
> Thanks in advance.
>
> - SK