1

I have one physical server where two Apache Camel instances a running on. Both contain the same integration artifacts. The task is to integrate files from the server's file system with Apache Camel's file component triggered by a cron job. The file handling should only take place once. Therefore, I use the idempotent pattern with a Jdbc repository on the same server.

In general, it works fine. But sometimes, in a few cases, both instances run and read the file, so that the file is handled twice. In the JDBC database, the key is inserted twice, too (even the timestamp of the creation is almost the same; it differs on the third digit of the milliseconds).

This is how I use the file consumer:

<from uri="file:{{property.file.directory}}?scheduler=quartz2
                    &;scheduler.cron={{property.file.cronjob}}?
                    &idempotent=true
                    &readLock=idempotent
                    &idempotentKey=${file:name}-${file:size}-${date:file:yyyy-MM}
                    &idempotentRepository=#idempotentRepository"/>

Does anybody know what I have to to that the file is ready only once??

Regards, ian

ian_eve
  • 97
  • 2
  • 8

1 Answers1

0

You can use clustered Quartz for your scenario. http://www.quartz-scheduler.org/documentation/quartz-1.8.6/configuration/ConfigJDBCJobStoreClustering.html

VarunKrish
  • 179
  • 1
  • 9