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://github.com/apache/camel/blob/80b92e3624ae5db59a1a24a441f1b10b39eaa1a5/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java#L885), by Claus in context of https://issues.apache.org/jira/browse/CAMEL-15270. ... 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 > > > > >