You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2022/01/19 19:42:00 UTC
[jira] [Resolved] (CAMEL-17516) Environment variables takes precedence over route template parameter
[ https://issues.apache.org/jira/browse/CAMEL-17516?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-17516.
---------------------------------
Resolution: Duplicate
> Environment variables takes precedence over route template parameter
> --------------------------------------------------------------------
>
> Key: CAMEL-17516
> URL: https://issues.apache.org/jira/browse/CAMEL-17516
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 3.11.1, 3.11.5
> Environment: Windows 10
> Java 8.0.282
> Reporter: Stefano Rocca
> Priority: Major
> Fix For: 3.14.0
>
> Attachments: sample_code.txt
>
>
> 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".
--
This message was sent by Atlassian Jira
(v8.20.1#820001)