Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-17516

Environment variables takes precedence over route template parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.11.1, 3.11.5
    • 3.14.0
    • came-core
    • None
    • Windows 10
      Java 8.0.282

    • Unknown

    Description

      While setting up a route template, if you use a parameter named like an environment variable, camel resolves first the environment variable and ignores the value of the parameter set using the TemplateRouteBuilder.

      Here follows a short program that exhibit this behaviour (this code is also attached to this issue as "sample_code.txt")

      import org.apache.camel.CamelContext;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.builder.TemplatedRouteBuilder;
      import org.apache.camel.main.ConfigureRouteTemplates;
      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;

      public class Main {
          
          public static final Logger LOG = LoggerFactory.getLogger(Main.class);
          
          public static class MyRouteBuilder extends RouteBuilder {
              
              public void configure() throws Exception {
                  routeTemplate("myTemplate")
                      .templateParameter("name")
                      .templateParameter("path")
                      .templateParameter("myPeriod", "3s")
                      .from("timer:{{name}}?period={{myPeriod}}")
                          .log("{{path}}");
              }
          }

          public static class MyTemplateBuilder implements ConfigureRouteTemplates {
              public void configure(CamelContext context)

      {             TemplatedRouteBuilder.builder(context, "myTemplate")                 .parameter("name", "one")                 .parameter("path", "test path")             .add();         }

          }
          public static void main(String[] args) throws Exception

      {         org.apache.camel.main.Main m = new org.apache.camel.main.Main();         m.configure().addRoutesBuilder(MyRouteBuilder.class);         m.bind("myTemplateBuilder", new MyTemplateBuilder());         m.run(args);     }

      }

      This sample code, when run with Camell 3.11.1 or 3.11.5, outputs the content of the PATH variable.
      If you run it with Camel 3.14.0, it outputs "test path".

      Attachments

        1. sample_code.txt
          1 kB
          Stefano Rocca

        Issue Links

          Activity

            People

              Unassigned Unassigned
              s.rocca@oandsi.it Stefano Rocca
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: