Quantcast
Channel: Planet Apache
Viewing all articles
Browse latest Browse all 9364

Claus Ibsen: Camel 2.6 - Using done files with file/ftp components

$
0
0
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:

.to("file:reports?fileName=${date:now:yyyMMdd}-report.txt&doneFileName=${file:name}.done");

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:

from("file:reports?doneFileName=${file:name}.done")
    .to("bean:fileService");

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.

Viewing all articles
Browse latest Browse all 9364

Trending Articles