Sure, Luca. 
It's CAMEL-16552.

Best Regards
Andreas

-----Original Message-----
From: Luca Burgazzoli <lburgazz...@gmail.com> 
Sent: Montag, 26. April 2021 09:54
To: users@camel.apache.org
Subject: Re: Route templates: How to set custom route id

ok, can you open an issue ?

---
Luca Burgazzoli


On Mon, Apr 26, 2021 at 9:51 AM Klug Andreas (CI/OSI3) 
<andreas.kl...@de.bosch.com.invalid> wrote:

> Hello Luca,
>
> I tried that, but unfortunately without success...
>
> I'm not sure, but I guess the relevant code part is in 
> BaseMainSupport.java ( 
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Fapache%2Fcamel%2Fblob%2F80b92e3624ae5db59a1a24a441f1b10b39eaa
> 1a5%2Fcore%2Fcamel-main%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fcamel%2Fm
> ain%2FBaseMainSupport.java%23L885&amp;data=04%7C01%7CAndreas.Klug2%40d
> e.bosch.com%7C0faea1d485ec4ab56b7308d90888873d%7C0ae51e1907c84e4bbb6d6
> 48ee58410f4%7C0%7C0%7C637550204736658073%7CUnknown%7CTWFpbGZsb3d8eyJWI
> joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&a
> mp;sdata=pFnoUSwmifdC2kOeTdbHX92jpPG8WR8PzUA%2Fnuj8KA4%3D&amp;reserved
> =0), by Claus in context of 
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FCAMEL-15270&amp;data=04%7C01%7CAndreas.Klug2%40de.bosch.com%7C0faea1d485ec4ab56b7308d90888873d%7C0ae51e1907c84e4bbb6d648ee58410f4%7C0%7C0%7C637550204736667978%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=6%2FwNOATql38HSmkLjhDxRTQoaGTyd5nPfdOlH3ZG%2BXw%3D&amp;reserved=0.
> ...
> String id = StringHelper.between(entry.getKey(), "[", "]"); ...
> source.addParameter(id, key, entry.getValue()); ...
>
> Later on the id seems to be used as route id for the instantiated route.
> This is for .properties files, but it seems to break with .yml; at 
> least I can't figure out how model it in YAML.
>
> My attempts are shown in the two YAML excepts below, which will cause 
> "binding to target [Bindable@7af327e3 type = 
> java.util.List<java.util.Map<java.lang.String, java.lang.String>> failed".
> The first example results in properties generated i. e.
> camel.route-template.config[4][0].auto-start, as I can't get around 
> the yaml list.
>
> 1)
> camel:
>     route-template:
>         config:
>             "[4]":
>                 - template-id:   "template-route"
>                   ...
> 2)
> camel:
>     route-template:
>         config:
>             "[4]":
>                 template-id:   "template-route"
>                 ...
>
>
> Best Regards
> Andreas
>
> -----Original Message-----
> From: Luca Burgazzoli <lburgazz...@gmail.com>
> Sent: Freitag, 23. April 2021 18:31
> To: users@camel.apache.org
> Subject: Re: Route templates: How to set custom route id
>
> ---
> Luca Burgazzoli
>
>
> On Fri, Apr 23, 2021 at 6:04 PM Klug Andreas (CI/OSI3) < 
> andreas.kl...@de.bosch.com.invalid> wrote:
>
> > Hello Luca,
> >
> > Thanks for the quick reply - my fault, I forgot to mention that I'm 
> > using a yaml-based Spring Boot configuration:
> >
> > route-template:
> >         config:
> >             - template-id: "myTemplate"
> >               auto-start:    true
> >               ...
> >
> > This probably means that the addRouteFromTemplate call is done 
> > automatically for me without being able to interfere here, or did I 
> > miss something?
> >
> >
> I have not tested but did you try to add
>
>     route-id: "my-id"
>
> to the yaml ?
>
>
>
>
>
> > Best Regards
> > Andreas
> >
> > -----Original Message-----
> > From: Luca Burgazzoli <lburgazz...@gmail.com>
> > Sent: Freitag, 23. April 2021 17:34
> > To: andreas.kl...@de.bosch.com.invalid
> > Cc: users@camel.apache.org
> > Subject: Re: Route templates: How to set custom route id
> >
> > The signature for the method addRouteFromTemplate is:
> >
> >     String addRouteFromTemplate(String routeId, String 
> > routeTemplateId, Map< String, Object> parameters) throws Exception;
> >
> > And the first argument is the route id, if null, then an auto 
> > generated one will be used
> >
> > ---
> > Luca Burgazzoli
> >
> >
> > On Fri, Apr 23, 2021 at 5:26 PM Klug Andreas (CI/OSI3) < 
> > andreas.kl...@de.bosch.com.invalid> wrote:
> >
> > > Hello community,
> > >
> > > It might be a stupid question, but, for Camel 3.7.3, how do I set 
> > > the route id for routes being created from route templates?
> > > The route templates are working fine, routes are getting created 
> > > with route ids 0, 1, 2, and so on …, but e. g. for logging or 
> > > monitoring purposes it’s very hard to work with this indices.
> > > I tried so far:
> > > 1) adding a route template parameter “route-id” and adding a
> > > .routeId(“{{route-id}}”) statement in the template definition
> > > 2) adding a addRouteTemplateDefinitionConverter hook and setting 
> > > the route id
> > >
> > >
> > >
> > defaultContext.addRouteTemplateDefinitionConverter(templateDef.getId
> > ()
> > ,(template,params)->{
> > >                 final RouteDefinition def=template.asRouteDefinition();
> > >                 if(params.containsKey(("route-id"))){
> > >                     def.setCustomId(false);
> > >                     def.routeId("{{route-id}}");
> > >                 }
> > >
> > > I’m using a similar way to set the startup-order on def, which 
> > > works fine, but for the route id it doesn’t seem to work. Without 
> > > the
> > > setCustomId() an exception is thrown (You can only set routeId one 
> > > time
> > per route).
> > >
> > > Best Regards,
> > > Andreas
> > >
> > >
> >
>

Reply via email to