简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM