apache-camelspring-camelapache-camel-file

How to say Camel file route to wait for another file route that is slow?


I have a route that moves files to the destination directory. The route works this way - it does preMove to the processing folder, and when all is okay, it moves the file to the .done directory.

If the route fails, I have a list of all files that should have been moved to the .done folder, but the Camel file route is slow in writing them. I am getting in the situation when the Camel file route is still writing files to a directory while I am moving it to another folder in another route in the processor.

What is the most Camel way to fix it?

I know files. I know directories files will be eventually written to.

UPDATE 1: I have in my first file route these params:

readLock=idempotent-changed&readLockMinAge=3s

The question is, should I wait for 3s to make route trigger and then move files?


Solution

  • From this section

    ... The best approach is however to write to another folder and after the write move the file in the drop folder. ... You may also want to look at the doneFileName option, which uses a marker file (done file) to signal when a file is done and ready to be consumed.


    Write a marker file in the producer route and read data file in consumer route when related marker file exist.