3

I am putting a document in MongoDB with a TTL (Time to Live) and then listen for the delete event using the MongoDB change stream. However, if multiple instances of my NodeJS are deployed in GCP Cloud Run, the event will be received & consumed by all the running instances. How do I ensure that the consumption happens exactly once?

We are using MongoDB Atlas as the database provider here.

retr0
  • 644
  • 6
  • 16
  • 1
    How do you currently coordinate between all the running instances? – Joe Mar 11 '23 at 14:03
  • I don't have mechanism for that currently. Would love some recommendations if you have any, first time I am encountering this situation. – retr0 Mar 11 '23 at 17:52
  • Maybe this question is similar https://stackoverflow.com/questions/63399261/change-stream-duplication-if-microservices-instance-got-replicated – Katya Kamenieva Mar 23 '23 at 21:06

0 Answers0