You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jörg Jansen <ja...@gmail.com> on 2021/01/26 20:20:32 UTC

parameter types in RouteTemplateDefinition

Hi all,

I’ve a Question About the usage of Route templates (Camel-3.7.0).
As far as I see, it is possible to provide every kind of object as a paramter.

But within the template, it seems to me, that those Parameters are
only processed as Strings.

So my question:
Is there a way/best practice to provide object parameters, to e.g. a
startup order or route configurable error handler could be provided?
Maybe I miss something, but I could not find anything about it within
the documentation
(https://camel.apache.org/manual/latest/route-template.html)?


Btw: Using the route templates is a really great feature!

Thanks,
Joerg

Re: parameter types in RouteTemplateDefinition

Posted by Jörg Jansen <ja...@gmail.com>.
Hi Claus,

thanks, your provided solution seems to work fine for me :-)

Thank,
Joerg

Am Mo., 1. Feb. 2021 um 14:20 Uhr schrieb Claus Ibsen <cl...@gmail.com>:
>
> Hi
>
> Making it nicer with errorHandler(ref) in the next release
> https://issues.apache.org/jira/browse/CAMEL-16126
>
> On Mon, Feb 1, 2021 at 2:09 PM Claus Ibsen <cl...@gmail.com> wrote:
> >
> > Hi Jorg
> >
> > Yeah that is a good question. At first route templates is designed to
> > be simple from the beginning.
> >
> > Can you try with
> >
> > errorHandler(new ErrorHandlerBuilderRef("{{my-error-handler-ref}}"));
> >
> >
> > On Mon, Feb 1, 2021 at 11:48 AM Jörg Jansen <ja...@gmail.com> wrote:
> > >
> > > Hi Claus,
> > >
> > > thanks for your response.
> > > I agree, just to use String literals.
> > >
> > > But maybe you can tell me what's the best way to add a route-specific
> > > errorhandler?
> > >
> > > I solved my issue by doing it the following way:
> > >
> > >     ModelCamelContext modelCamelContext =
> > > camelContext.adapt(ModelCamelContext.class);
> > >     RouteDefinition routeDefinition =
> > > modelCamelContext.getRouteDefinition("my-templated-route-id");
> > >     if (routeDefinition != null)
> > >       routeDefinition.setErrorHandlerRef("my-error-handler-ref");
> > >
> > > This seems to me, quite complicate, so maybe there is a better way to
> > > do, which I'm not aware of?
> > >
> > > Or maybe it would be a good improvement (handle this like the routeId)
> > > for an upcoming release?
> > >
> > > Kind regards,
> > > Jörg
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Re: parameter types in RouteTemplateDefinition

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

Making it nicer with errorHandler(ref) in the next release
https://issues.apache.org/jira/browse/CAMEL-16126

On Mon, Feb 1, 2021 at 2:09 PM Claus Ibsen <cl...@gmail.com> wrote:
>
> Hi Jorg
>
> Yeah that is a good question. At first route templates is designed to
> be simple from the beginning.
>
> Can you try with
>
> errorHandler(new ErrorHandlerBuilderRef("{{my-error-handler-ref}}"));
>
>
> On Mon, Feb 1, 2021 at 11:48 AM Jörg Jansen <ja...@gmail.com> wrote:
> >
> > Hi Claus,
> >
> > thanks for your response.
> > I agree, just to use String literals.
> >
> > But maybe you can tell me what's the best way to add a route-specific
> > errorhandler?
> >
> > I solved my issue by doing it the following way:
> >
> >     ModelCamelContext modelCamelContext =
> > camelContext.adapt(ModelCamelContext.class);
> >     RouteDefinition routeDefinition =
> > modelCamelContext.getRouteDefinition("my-templated-route-id");
> >     if (routeDefinition != null)
> >       routeDefinition.setErrorHandlerRef("my-error-handler-ref");
> >
> > This seems to me, quite complicate, so maybe there is a better way to
> > do, which I'm not aware of?
> >
> > Or maybe it would be a good improvement (handle this like the routeId)
> > for an upcoming release?
> >
> > Kind regards,
> > Jörg
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



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

Re: parameter types in RouteTemplateDefinition

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

Yeah that is a good question. At first route templates is designed to
be simple from the beginning.

Can you try with

errorHandler(new ErrorHandlerBuilderRef("{{my-error-handler-ref}}"));


On Mon, Feb 1, 2021 at 11:48 AM Jörg Jansen <ja...@gmail.com> wrote:
>
> Hi Claus,
>
> thanks for your response.
> I agree, just to use String literals.
>
> But maybe you can tell me what's the best way to add a route-specific
> errorhandler?
>
> I solved my issue by doing it the following way:
>
>     ModelCamelContext modelCamelContext =
> camelContext.adapt(ModelCamelContext.class);
>     RouteDefinition routeDefinition =
> modelCamelContext.getRouteDefinition("my-templated-route-id");
>     if (routeDefinition != null)
>       routeDefinition.setErrorHandlerRef("my-error-handler-ref");
>
> This seems to me, quite complicate, so maybe there is a better way to
> do, which I'm not aware of?
>
> Or maybe it would be a good improvement (handle this like the routeId)
> for an upcoming release?
>
> Kind regards,
> Jörg



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

Re: parameter types in RouteTemplateDefinition

Posted by Jörg Jansen <ja...@gmail.com>.
Hi Claus,

thanks for your response.
I agree, just to use String literals.

But maybe you can tell me what's the best way to add a route-specific
errorhandler?

I solved my issue by doing it the following way:

    ModelCamelContext modelCamelContext =
camelContext.adapt(ModelCamelContext.class);
    RouteDefinition routeDefinition =
modelCamelContext.getRouteDefinition("my-templated-route-id");
    if (routeDefinition != null)
      routeDefinition.setErrorHandlerRef("my-error-handler-ref");

This seems to me, quite complicate, so maybe there is a better way to
do, which I'm not aware of?

Or maybe it would be a good improvement (handle this like the routeId)
for an upcoming release?

Kind regards,
Jörg

Re: parameter types in RouteTemplateDefinition

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

The template parameters are intended as text based placeholders,eg for
string, numbers, booleans, etc.
If you need to pass in objects, then it should be as reference to
objects to use in the registry via their bean id.


On Tue, Jan 26, 2021 at 9:20 PM Jörg Jansen <ja...@gmail.com> wrote:
>
> Hi all,
>
> I’ve a Question About the usage of Route templates (Camel-3.7.0).
> As far as I see, it is possible to provide every kind of object as a paramter.
>
> But within the template, it seems to me, that those Parameters are
> only processed as Strings.
>
> So my question:
> Is there a way/best practice to provide object parameters, to e.g. a
> startup order or route configurable error handler could be provided?
> Maybe I miss something, but I could not find anything about it within
> the documentation
> (https://camel.apache.org/manual/latest/route-template.html)?
>
>
> Btw: Using the route templates is a really great feature!
>
> Thanks,
> Joerg



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