Search code examples
javaspringintegrationspring-integrationfileserver

Avoid same file of File server been picked up from different services


I have a file server and two integration servers. Each integration server has the same task. It will pick up file from "incoming" folder of the file server, and then will process it. This service use Spring Integration. Two servers' services work at the same time, which would ensure that even one integration server fails, the other will keep working. Because these two are independent from each other, my question is how can I make sure that both services don't pick up the same file from file server Also master-slave approach is not what I am looking for.


Solution

  • Looks like you can use a file locker. Some thing like this

     <file:inbound-channel-adapter id="filesIn"
           directory="file:${input.directory}" prevent-duplicates="true">
        <file:nio-locker/>
      </file:inbound-channel-adapter>
    

    Check this documentation