02 May 2014

Fuse and expressions in properties files

Bambitroll @ 11:23
The problem:
When using properties files in Fuse/ServiceMix (which you deploy in $FUSE_HOME/etc), you can define a camel endpoint like this
my.file.endpoint=file:/var/tmp/in?move=/var/tmp/sent/${date:now:yyyyMMdd}-${file:name}

This will work fine if you define it as a properties in your camel context XML file, like this:
<cm:property-placeholder persistent-id="my.properties">
    <cm:default-properties>
        <cm:property name="my.file.endpoint" value="file:/var/tmp/in?move=/var/tmp/sent/${date:now:yyyyMMdd}-${file:name}"/>
    </cm:default-properties>
</cm:property-placeholder>

But if you use the same definition in your properties file, because you want a more environment specific value for each of your servers, you are out of luck.
All you will achieve is having your files moved to a folder called "-" under sent.
This is because everything within a ${} is interpreted as a variable and will be resolved (unsuccessfully) before being passed along.


The solution:
Use the simple language!

my.file.endpoint=file:/var/tmp/in?move=/var/tmp/sent/$simple{date:now:yyyyMMdd}-$simple{file:name}