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