You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christoph Burmeister <ch...@googlemail.com> on 2012/01/18 10:34:28 UTC
using values from a properties-file in setHeader-method
hi,
how can I set a header with a value from a properties-file using
spring-xml?
Doing this with the const-tag is no problem, but then the value has to be
directly written in the camel.xml:
<setHeader>
<const>foobar</const>
</setHeader>
I like to use something like this:
environment.properties:
-----------------------------
header.value=foobar
camel.xml
---------------
<beans>
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>environment.properties</value>
<value>another-file.properties</value>
</list>
</property>
</bean>
<route>
...
<setHeader>
${header.value}
</setHeader>
...
</route>
</beans>
Is there a solution for camel 2.7 ?
best,
christoph
Re: using values from a properties-file in setHeader-method
Posted by Bilgin Ibryam <bi...@gmail.com>.
My guess is that something like this should work:
<setHeader headerName="myHeader">
<simple>${properties:key}</simple>
</setHeader>
Bilgin
On 18 January 2012 09:34, Christoph Burmeister
<ch...@googlemail.com> wrote:
> hi,
>
> how can I set a header with a value from a properties-file using
> spring-xml?
> Doing this with the const-tag is no problem, but then the value has to be
> directly written in the camel.xml:
>
> <setHeader>
> <const>foobar</const>
> </setHeader>
>
> I like to use something like this:
>
> environment.properties:
> -----------------------------
> header.value=foobar
>
> camel.xml
> ---------------
> <beans>
> <bean id="placeholderConfig"
>
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> <property name="locations">
> <list>
> <value>environment.properties</value>
> <value>another-file.properties</value>
> </list>
> </property>
> </bean>
>
>
> <route>
> ...
> <setHeader>
> ${header.value}
> </setHeader>
> ...
> </route>
> </beans>
>
> Is there a solution for camel 2.7 ?
>
> best,
> christoph
Re: using values from a properties-file in setHeader-method
Posted by Christian Müller <ch...@gmail.com>.
Does this solve your needs: http://camel.apache.org/constant.html
<from uri="seda:a"/>
<setHeader headerName="theKey">
<constant>theValue</constant>
</setHeader>
Best,
Christian
On Wed, Jan 18, 2012 at 10:34 AM, Christoph Burmeister <
chburmeister@googlemail.com> wrote:
> hi,
>
> how can I set a header with a value from a properties-file using
> spring-xml?
> Doing this with the const-tag is no problem, but then the value has to be
> directly written in the camel.xml:
>
> <setHeader>
> <const>foobar</const>
> </setHeader>
>
> I like to use something like this:
>
> environment.properties:
> -----------------------------
> header.value=foobar
>
> camel.xml
> ---------------
> <beans>
> <bean id="placeholderConfig"
>
>
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
> <property name="locations">
> <list>
> <value>environment.properties</value>
> <value>another-file.properties</value>
> </list>
> </property>
> </bean>
>
>
> <route>
> ...
> <setHeader>
> ${header.value}
> </setHeader>
> ...
> </route>
> </beans>
>
> Is there a solution for camel 2.7 ?
>
> best,
> christoph
>
Re: using values from a properties-file in setHeader-method
Posted by ebinsingh <eb...@VerizonWireless.com>.
I see something strange here.
If I have the below to routes, the logginf works perfectly.
<route>
<from ref="acquireltel2" />
<setHeader headerName="pathName"><simple>${file:path}</simple></setHeader>
<log message="set header pathName to ${file:path}" loggingLevel="INFO"/>
<setHeader headerName="fileName"><simple>${file:name}</simple></setHeader>
<log message="set header fileName to ${file:name}" loggingLevel="INFO"/>
<setHeader headerName="fileType"><constant>ltel2</constant></setHeader>
<log message="set header fileType to ltel2" loggingLevel="INFO"/>
<to ref="producerQueue"/>
</route>
<route>
<from ref="producerQueue"/>
<log message="Processing messege out of producerQueue ${file:name}
${file:path}" loggingLevel="INFO"/>
<to uri="jms:queue:test_request_2"/>
</route>
But *NOT* if I have the second route as below. Do not know what difference
it makes in the flow.
I am not seeing any of the logs.
<route>
<from ref="producerQueue"/>
<log message="Processing messege out of producerQueue"
loggingLevel="INFO"/>
<choice>
<when>
<simple>${header.fileType} == "ltel2"</simple>
<log message="processing ltel2 file type" loggingLevel="INFO" />
<threads executorServiceRef="ltel2threadpool1">
<bean ref="ltel2Consumer" method="doConsume" />
</threads>
</when>
</choice>
</route>
Also please adive if the above Choice evaluation is correct.
--
View this message in context: http://camel.465427.n5.nabble.com/using-values-from-a-properties-file-in-setHeader-method-tp5154287p5157928.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: using values from a properties-file in setHeader-method
Posted by Claus Ibsen <cl...@gmail.com>.
Put the <log> outside the <setHeader>.
On Thu, Jan 19, 2012 at 3:56 PM, ebinsingh
<eb...@verizonwireless.com> wrote:
> Hi All,
>
> I am trying to set few header's, but does not seem to work.
> I guess I am missing something but not able to find that out.
> The below logs age not printted in the log file.
>
> <route>
> <from ref="acquireltel2" />
> <setHeader
> headerName="pathName"><simple>${file:path}</simple></setHeader>
> <log message="set header pathName to ${file:path}"
> loggingLevel="INFO"/>
> <setHeader
> headerName="fileName"><simple>${file:name}</simple></setHeader>
> <log message="set header fileName to ${file:name}"
> loggingLevel="INFO"/>
> <setHeader headerName="fileType"><constant>ltel2</constant></setHeader>
> <log message="set header fileType to ltel2" loggingLevel="INFO"/>
> <to ref="producerQueue"/>
> </route>
>
> Appriciate your help.
>
> Ebe
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/using-values-from-a-properties-file-in-setHeader-method-tp5154287p5157868.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: using values from a properties-file in setHeader-method
Posted by ebinsingh <eb...@VerizonWireless.com>.
Hi All,
I am trying to set few header's, but does not seem to work.
I guess I am missing something but not able to find that out.
The below logs age not printted in the log file.
<route>
<from ref="acquireltel2" />
<setHeader
headerName="pathName"><simple>${file:path}</simple></setHeader>
<log message="set header pathName to ${file:path}"
loggingLevel="INFO"/>
<setHeader
headerName="fileName"><simple>${file:name}</simple></setHeader>
<log message="set header fileName to ${file:name}"
loggingLevel="INFO"/>
<setHeader headerName="fileType"><constant>ltel2</constant></setHeader>
<log message="set header fileType to ltel2" loggingLevel="INFO"/>
<to ref="producerQueue"/>
</route>
Appriciate your help.
Ebe
--
View this message in context: http://camel.465427.n5.nabble.com/using-values-from-a-properties-file-in-setHeader-method-tp5154287p5157868.html
Sent from the Camel - Users mailing list archive at Nabble.com.