I would like to know if we can lock the documents in Mongo. We have a .NET service which has 3 different instances of itself. It looks into a collection and gets the document from Mongo.
What we want is, if the first instance of the service gets the Document-1 from the collection, then the second instance should not be able to get the same document (Document-1) as it is being processed by another instance. The second instance should get next available document (e.g Document-2). Same with third instance, it should not be able to find the Document-1 or Document-2. It should pick Document-3. But if the first document is not processed correctly, then the lock from that document should be released and the next available service instance should pick it up.
Please help. Thank you.