Hi Users

When i use the file component i want to filter on files that are older then
one month and only process those files.

I have been experimenting with:
filterFile=$simple{file:modified} < ${date:now}
and:
.filter(header("CamelFileLastModified").isLessThan("${date:now} -
$simple{header.ONE_MONTH}"))

what i would like to do is to offset ${date:now} with one month like

"${date:now-${header.ONE_MONTH}}"

The documentation for simple language for 'date:' variable says:
"Command accepts offsets such as: *now-24h* or *in.header.xxx+1h* or even
*now+1h30m-100*."
https://camel.apache.org/components/2.x/languages/simple-language.html

I have the constant ONE_MONTH with
private final long ONE_MONTH = 2592000000L;
and set the header with:
.setHeader("ONE_MONTH", constant(ONE_MONTH))

the only way i got it to work is with.

from("file:historyfolder?delete=true&filterFile=$simple{file:modified} <
${date:now - 2592000000}")
  .routeId("'remove old handled files'")
  .log("File is deleted: " + "file name: " + "${file:name}" + "
lastmodified: " + "${date:file:yyyy-MM-dd HH:mm:ss}");

But I want to get rid of that ugly long value and offset it with a constant
from a header or something similar instead.

How can I do this?

All the best!

/Daniel

Reply via email to