Camel 2.6 - Using done files with file/ftp components

The upcoming 2.6 release of Apache Camel now supports using "done files" with the file/ftp components. The "done file" is a marker file which signals that the target file is ready for the consumer. You can use this when exchanging data using files and want to avoid the consumer to pickup the target file before its ready (= done).

Mind that Camel also has a number of other features
for detecting if a file is ready,
 which you can read about the readLock option.

For example if write a file with the name yyyyMMdd-report.txt and want to write a done file using the syntax file name .done, then you can do as follows:


Notice the new doneFileName option where we define the pattern of done file. It supports two dynamic placeholders which is ${file:name} and ${file:name.noext}. The latter is the file name without the extension.

The "done file" must be located in the same directory as the target file.

On the consumer side we can do as follows:


Which tells Camel to only pickup files if a done file exists with that given name pattern.

And all this works as well with the FTP components.


chermonder said...

Does it possible to not remove "done" file after exchange?

chermonder said...

Does it possible to not remove done file after exchange?

chermonder said...

Does it possible to not remove done file after exchange?

Claus Ibsen said...

No the done file is automatic deleted AFAIR. Fell free to request for an enhancement at the Apache Camel project. Read more here: http://camel.apache.org/support

chermonder said...

Thank you for your answer.

Sundar said...

I am trying to set the doneFileName using the below

in spring dsl , all I get is name.done file , can anyone help me here
Sundar M R

GangaGyanMandir said...

This solution works pretty fine when there is a single output file created, I have a scenario where I need to create 3 output files from a single input file based on some transformation on the data. In such a scenario how do I identify the file processing is DONE?