Hi

What you do with <to> is correct. You specify the method signature that
Camel should call.
The bean component is able to adapt to this.

Using toD is not needed and it has a different purpose here. The <toD> will
calculate a literal uri string ahead of time.
This means the simple expression values are added together as a string.



On Mon, Feb 10, 2025 at 7:59 AM logesh <logeshro...@gmail.com> wrote:

> In that case are we isolating  just to string based methods for toD and
> custom wont me supported?
>
> On Mon, Feb 10, 2025, 1:05 PM Claus Ibsen <claus.ib...@gmail.com> wrote:
>
> > Hi
> >
> > This is as designed when you use toD then you use the simple language
> that
> > are literal/string based.
> > Avoid all the method overload complexity and just use a new method name.
> >
> >
> >
> > On Mon, Feb 10, 2025 at 8:08 AM logesh <logeshro...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > We have another issue with camel bean and methid invocation  but this
> > time
> > > its on the bean menthod invocation  thats done thru toD uri. Calling a
> > bean
> > > method using the below snippet works when access the header stored
> > > properties .the property1 in headers gets resolved to the custom class
> > type
> > > and gets called to the correct overloaded method  in the bean.
> > >  <bean ref="bean-ref" method="method1(${body}, <custom class
> type>.class
> > > ${headers[property1]})">
> > >
> > > But when the same bean is called thru the
> > > The below snippet the property1 under headers is always resolved as
> > string
> > > and it ends up being called as a string parameter there by throwing
> > method
> > > invocation error.
> > > <toD uri="bean-ref?method1(${body}, <custom class type>.class
> > > ${headers[property1]})">
> > >
> > > The very purpose we are using toD  is for Dynamic routing to the
> required
> > > bean reference there by limiting us to just configurations on the route
> > > DSL.Any advise on this issue or fix is highly  appreciated.
> > >
> > > *Camel version:4.8.1*
> > > *Springboot based app: 3.3.5*
> > >
> > > Thanks
> > > Logeshwaran Devakar
> > >
> > >
> > > On Fri, Jul 5, 2024, 9:02 PM logesh <logeshro...@gmail.com> wrote:
> > >
> > > > I am trying to use bean with reference and method call.The bean has
> > > > overloaded methods and hence it is being called in this way.The below
> > > > method call was populated with parameter type and value in reference
> to
> > > the
> > > > guidanct provided in  here.
> > > >
> > > >
> > >
> >
> https://camel.apache.org/manual/bean-binding.html#_declaring_parameter_type_and_value
> > > >
> > > > My bean spring DSL looks as below
> > > >
> > > > <bean ref=bean1 method="Sendmsg(java.lang.String.class ${body},
> > > > Java.lang.String.class {{appsproperty.value}})"
> > > >
> > > > I get  ambiguous method invocation possible exception.
> > > > On investigating further this was drilled down to issue happening
> > during
> > > > the matchmethod call in BeanInfo class under
> > org.apache.camel.component.
> > > >
> > > > The matchmethod was calling the method splitsafequote method with 4
> > > > parameters (input seperator trime:true and keepquote:true) in
> > > > strignquotehelper class under org.apache.camel.util which splits the
> > > > parameters and types.The problem was isolated to the type and value
> > > > concatenated with space between them ignored.The flag
> > > skipleadingwhitespace
> > > > is set to true and is never changed which ignores the space and is
> > missed
> > > > in the parsing logic.
> > > > This in turn breaks at the match method which looks for the
> indexof(32)
> > > > which is for a whitespace and since it's not there it returns -1 and
> > > there
> > > > by breaking the whole purpose of passing parameter type and value.
> > > >
> > > > Camel version used :4.5.0
> > > > Camel components:camel-bean and camel-util
> > > >
> > > > Please let know if this is a bug or if any missing configuration
> > from.my
> > > > side
> > > >
> > > > PS:I changed the flag to false and it works fine with the above bean
> > > > method call
> > > >
> > > > Thanks
> > > > Logeshwaran Devakar
> > > >
> > > >
> > > >
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to