is there any way to implement the above requirement.?
Hi Dillip,
In order to process the notifications without any duplication, you would need to design the application/client side to behave this way.
The solution would depend on your environments and requirements. There are a few methods that you could try:
Create a worker pool, where you have only one instance listening to the Change Streams then delegate the task to the worker instances for processing. i.e. batch of 20 etc.
Add an aggregation filter to each of the instances i.e. $match pipeline stage. For example, one instance is only going to handle notification where user has a specific id, etc.
Each of the methods above have their own pros and cons depending on your application use case.
Regards,
Wan.