We have two nodes in a cluster. Whenever a new file comes in a DROP folder a onUpdatePolicy runs and move the document to the appropriate folder.
We have metadata called caseNumber. So if the caseNumber is 12345678 then the onUpdatePolicy will create a folder structure like 12->123->12345->12345678->abc.pdf.
We have to bulk import around 50 documents with the same caseNumber 12345678.
During the bulk import if two documents comes at the same time in the DROP folder, the policy will run on both the nodes and it creates a race condition between two threads or nodes and one thread/node is throwing duplicate folder exception.
For the time being I have written a Scheduler that moves the documents at certain interval. But I would like to know if there is a better way to do this with policy.