How we can trigger change stream event from primary node only?

Hello team can you help me how we can trigger change stream event from primary node only
this is because because I move to production server to achieve high ability of server
I have deploy same code over 4 server when i perform any CRUD operation in any of one server the change stream trigger from all the 4 server so what i want to be it should be trigger from the same server where operation are perform or it should be trigger form primary node
Can any one help me to how to go with this issue
Thanks in advanced

Hi Neeraj,

Welcome to the MongoDB community!

If you have deployed four copies of your code watching the same change stream, it is expected that all will get the same events.

Your application logic needs to coordinate how concurrent watchers should interact. For example, you could have only one watcher actively processing at any given point or perhaps push unique change events onto a distributed work queue where multiple workers could process events.

Change streams are designed to be resumable, so you can use the resume token (_id of the change stream event document) to resume notifications after a failover or restart of your watcher application.


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.