[
https://issues.apache.org/jira/browse/CAMEL-15087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17113358#comment-17113358
]
Andreu Font Bardolet commented on CAMEL-15087:
----------------------------------------------
Sorry, I had problems writing an example in Jira it autoremoved some
characters, I just discovered it has a codeblock funcion:
In response of your question, it is:
{code:java}
<toD uri="{{example}}"/>
{code}
To give more clarity, here is a full rewrite of the example I have post the
first time:
In a etc/uri.properties file:
{code:java}
example=http://${headers.url}
{code}
In camel context xml:
{code:java}
<camelContext id="example" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="myProperties"
location="classpath:etc/uri.properties"/>
<route id="test">
<from uri="timer:hello?period=3000"/>
<setHeader name="url"><constant>www.google.es</constant></setHeader>
<log message="{{example}}"/>
<!-- it logs: http://www.google.es -->
<toD uri="{{example}}"/>
<!-- It resolves: http://${headers.url} -->
</route>
</camelContext>
{code}
A way to workarround the issue, is making a camel context like this:
{code:java}
<camelContext id="example" xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder id="myProperties"
location="classpath:etc/uri.properties"/>
<route id="test">
<from uri="timer:hello?period=3000"/>
<setHeader name="url"><constant>www.google.es</constant></setHeader>
<log message="{{example}}"/>
<!-- it logs: http://www.google.es -->
<setHeader name="workarround"><simple>{{example}}</simple></setHeader>
<toD uri="${headers.workarround}"/>
<!-- It resolves: http://www.google.es -->
</route>
</camelContext>
{code}
Sorry for the poor fisrst message, It was my first time :P
> toD doesn't resolve ${headers} if they come from a propertyPlaceholders
> -----------------------------------------------------------------------
>
> Key: CAMEL-15087
> URL: https://issues.apache.org/jira/browse/CAMEL-15087
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Affects Versions: 3.1.0, 3.2.0, 3.3.0
> Reporter: Andreu Font Bardolet
> Priority: Major
> Fix For: 3.4.0
>
>
> From camel 3.1 and up, I have detected that <doD/> doesn't resolve variables
> in propertyPlaceholders.
> For example:
> if i have an etc/uri.properties with:
> {{example=http://${headers.url}}}
>
>
>
> And in camel Context xml:
>
> ...
>
> <camelContext id="example"
> xmlns="http://camel.apache.org/schema/spring">\{{}}
> <propertyPlaceholder id="myProperties"
> location="classpath:etc/uri.properties"/>
> <route id="test">
> <from uri="timer:hello?period=3000"/>
> <setHeader name="url"><constant>www.google.es</constant></setHeader>
> <log message="{{example}}"/>
> <!-- It logs: [http://www.google.es/] -->
> <toD uri="{{example}}"/>
> <!-- It resolves: [http://$|http://%24/]{headers.url}
> instead of [http://www.google.es/] -->
> {{ </route>}}
> {{</camelContext>}}
>
>
> {{But if i do a kind of a workarround like this, it works:}}
> {{...}}
> {{<camelContext id="example"
> xmlns="http://camel.apache.org/schema/spring">}}{{}}
> <propertyPlaceholder id="myProperties"
> location="classpath:etc/uri.properties"/>
> <route id="test">
> <from uri="timer:hello?period=3000"/>
> <setHeader name="url"><constant>www.google.es</constant></setHeader>
> <setHeader
> name="workarround"><simple>{{{{example}}}}</simple></setHeader>
> <toD uri="${headers.workarround}"/>
> <!-- It resolves: [http://www.google.es|http://www.google.es/] -->
> {{ </route>}}
> {{</camelContext>}}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)