Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a header to a value from a properties file in Apache Camel

Is it possible to set a message header to a value read from a properties file, using the camel Properties Component? I can set such properties to URI options, but I'm unable to set them as a header values.

I need something like this:

<camel:setHeader headerName="actionId">
    <camel:constant>{{onus.transPosting.RtSFailed}}</camel:constant>
</camel:setHeader>

where onus.transPosting.RtSFailed is a property key set on a file imported using camel Properties Component.

Note: I'm using Apache Camel 2.10.1

UPDATE

Using the <propertyPlaceholder> as suggested by this discussion did not work and it causes an exception:

Caused by: org.apache.camel.language.simple.types.SimpleParserException: Unknown function: onus.transPosting.RtSFailed

like image 923
Ahmad Y. Saleh Avatar asked Dec 26 '12 09:12

Ahmad Y. Saleh


1 Answers

Yes you can, use the simple language which has a properties function: http://camel.apache.org/simple

<camel:setHeader headerName="actionId">
    <camel:simple>${properties:onus.transPosting.RtSFailed}</camel:simple>
</camel:setHeader>

Though I think we have fixed in latest Camel releases that < camel:constant > will resolve property placeholders as well.

like image 84
Claus Ibsen Avatar answered Nov 15 '22 02:11

Claus Ibsen