--- 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 > > > > >