In our ESB project, we have a lot of routes reading files with file2
or ftp
protocol for further processing. Important to notice, that the files we read locally (file2
protocol) are mounted network shares via different protocols (NFS, SMB).
Now, we are facing issues with race conditions. Both servers read the file and process it. We have reduced the possibility of that by using the preMove
option, but from time to time the duplicate reading still occurs when both servers poll at the same millisecond. According to the documentation, an idempotentRepository
together with readLock=idempotent
could help, for example with HazelCast.
However, I'm wondering if this is a suitable solution for my issue as I don't really know if it will work in all cases. It is within milliseconds that both servers read the file, so the information that one server has already processed the file need to be available in the HazelCast grid at the point in time when the second server tries to read. Is that possible? What happens if there are minimal latencies (e.g. network related)?
In addition to that, the setting readLock=idempotent
is only available for file2
but not for ftp
. How to solve that issue there?
Again: The issue is not preventing dublicate files in general, it is solely about preventing the race condition.