[ 
https://issues.apache.org/jira/browse/CAMEL-20890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17856227#comment-17856227
 ] 

Raymond commented on CAMEL-20890:
---------------------------------

A sidenote:

In the reproducer I get the following error message:


Failed to create route deux from template myTemplate because of duplicate id 
detected: \{{name}}.

But when loading a kamelet I got something like the following error message



 
{code:java}
Failed to create route deux from template setbody-action because of duplicate 
id detected: one.{code}
 


This puzzled me a bit, because the id "one" doesn't exist on route deux. Not as 
template parameter or value. It seems like it interpolates the parameter the 
first time, but then keeps it in memory somehow and use it again the second 
time.

It was also not fully clear that the id of the step was meant, instead of 
another id (like the route id). It would be nice to give a bit more information 
something like:



 
{code:java}
Failed to create route deux from template setbody-action because of duplicate 
id detected.
Details:
id: one
node: step
route: deux
already used in route: one
{code}
 









 

> Use Step ID's in routeTemplate
> ------------------------------
>
>                 Key: CAMEL-20890
>                 URL: https://issues.apache.org/jira/browse/CAMEL-20890
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 4.6.0
>            Reporter: Raymond
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.7.0
>
>         Attachments: routetemplate-xml.zip
>
>
> I like to use steps in my routeTemplates. This works, however when I want to 
> specify the ID I cannot use template parameter:
> {code:java}
> <routeTemplates id="camel" xmlns="http://camel.apache.org/schema/spring";>
>     <!-- create a route template with the given name -->
>     <routeTemplate id="myTemplate">
>         <!-- here we define the required input parameters (can have default 
> values) -->
>         <templateParameter name="name"/>
>         <templateParameter name="greeting"/>
>         <templateParameter name="myPeriod" defaultValue="3s"/>
>         <route>
>             <from uri="timer:{{name}}?period={{myPeriod}}"/>
>             <step id="{{name}}">
>                 <setBody>
>                     <simple>{{greeting}} {{name}}</simple>
>                 </setBody>
>                 <log message="${body}"/>
>             </step>
>         </route>
>     </routeTemplate>
> </routeTemplates> {code}
> When I create 2 routes with the above template I get the following error:
> {code:java}
> java.lang.reflect.InvocationTargetException
>     at jdk.internal.reflect.DirectMethodHandleAccessor.invoke 
> (DirectMethodHandleAccessor.java:118)
>     at java.lang.reflect.Method.invoke (Method.java:580)
>     at org.apache.camel.maven.RunMojo$1.run (RunMojo.java:402)
>     at java.lang.Thread.run (Thread.java:1583)
> Caused by: org.apache.camel.FailedToCreateRouteFromTemplateException: Failed 
> to create route deux from template myTemplate because of duplicate id 
> detected: {{name}}. Please correct ids to be unique among all your routes.
>     at org.apache.camel.impl.DefaultModel.addRouteFromTemplate 
> (DefaultModel.java:518)
>     at org.apache.camel.impl.DefaultModel.addRouteFromTemplatedRoute 
> (DefaultModel.java:566)
>     at org.apache.camel.impl.DefaultCamelContext.addRouteFromTemplatedRoute 
> (DefaultCamelContext.java:384)
>     at org.apache.camel.model.Model.addRouteFromTemplatedRoutes 
> (Model.java:275)
>     at org.apache.camel.builder.RouteBuilder.populateTemplatedRoutes 
> (RouteBuilder.java:822)
>     at org.apache.camel.builder.RouteBuilder.addTemplatedRoutesToCamelContext 
> (RouteBuilder.java:678)
>     at org.apache.camel.impl.engine.AbstractCamelContext.addTemplatedRoutes 
> (AbstractCamelContext.java:993)
>     at org.apache.camel.main.RoutesConfigurer.addDiscoveredRoutes 
> (RoutesConfigurer.java:259)
>     at org.apache.camel.main.RoutesConfigurer.configureRoutes 
> (RoutesConfigurer.java:236)
>     at org.apache.camel.main.BaseMainSupport.configureRoutes 
> (BaseMainSupport.java:613)
>     at org.apache.camel.main.BaseMainSupport.postProcessCamelContext 
> (BaseMainSupport.java:693)
>     at org.apache.camel.main.MainSupport.initCamelContext 
> (MainSupport.java:339)
>     at org.apache.camel.main.Main.doInit (Main.java:133)
>     at org.apache.camel.support.service.BaseService.init (BaseService.java:78)
>     at org.apache.camel.main.MainSupport.run (MainSupport.java:84)
>     at org.apache.camel.main.MainCommandLineSupport.run 
> (MainCommandLineSupport.java:237)
>     at org.apache.camel.example.MyApplication.main (MyApplication.java:41)
>     at jdk.internal.reflect.DirectMethodHandleAccessor.invoke 
> (DirectMethodHandleAccessor.java:103)
>     at java.lang.reflect.Method.invoke (Method.java:580)
>     at org.apache.camel.maven.RunMojo$1.run (RunMojo.java:402)
>     at java.lang.Thread.run (Thread.java:1583)
>  {code}
> The step ID doesn't get interpolated and is used a the literal "\{{name}}". I 
> need to set the step id myself to get information about the specific route.
> Note that I run into when I was using kamelets with the step EIP, but this is 
> a smaller example.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to