Here's a file source endpoint definition:
String uri = "file:files" +
"?initialDelay=3000" +
"&delay=1000" +
"&useFixedDelay=true" +
"&include=.*[.]xml" +
"&move=backup/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.xml" +
"&moveFailed=files/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.xml.error";
So consider this route:
from(uri).process(someProcessor).to("someBean");
With file endpoint definition above, it means, that with consume the files from some directory called "files", the initial delay for the files polling is 3 seconds, and we will poll with fixed intervals - 1 second, filtering out non-xml files.
In addition to that, if a file is processed successfully, it is being moved to a "backup" directory appending a time stamp in the file's name.
A new feature is a moveFailure attribute, which in case of failure in someProcessor or in the target endpoint ("someBean") allows you to handle the failed files, e.g. renaming or moving to another directory. At the time of writing the feature is available in snapshot version of Camel.
2 comments:
Hi Anton
Nice little wrapup of the move options on the file component.
And credit to you for bring out in the light we needed the new movedFailed option.
Thx Claus!
I have also a solution for the synchronization problem between the routes in my next post...
Post a Comment