2

I have a spring batch integration where multiple servers are polling a single file directory. This causes a problem where a file can be processed up by more than one. I have attempted to add a nio-lock onto the file once a server has got it but this locks the file for processing so it can't read the contents of the file.

Is there a spring batch/integration solution to this problem or is there a way to rename the file as soon as it is picked up by a node?

1 Answers1

0

Consider to use FileSystemPersistentAcceptOnceFileListFilter with the shared MetadataStore: http://docs.spring.io/spring-integration/reference/html/system-management-chapter.html#metadata-store

So, only one instance of your application will be able to pick up a file.

Even if we find a solution for nio-lock, you should understand that lock means "do not touch until freed". Therefore when one instance has done its work, another one is ready to pick up the file. I guess that isn't your goal.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118