title: reading files from one folders through multiple instances
body: <p>I have a folder where an upstream system dumps the files which are input for my application. My application read those files, process them and then output in some directory. Since the number of input file is large, I decided to run multiple instances of my application and all the instances will read the same input directory for input files. Now, since multiple instances will read the same folder,  how can I prevent multiple instance from reading the same file at same time?</p>
  
  <p>PS: I thought of using Spring Integration with NIO lock, but once you lock the file even the same thread will not be able to read the file.
  Camel handles the lock but it locks the whole directory and also doesn't handle the scenarios for that fraction of time where 2 instances are trying to get the file which is not yet locked.</p>
  
  <p>Any suggestion will be helpful. </p>