Open robertsLando opened 4 years ago
Is this fixed?
Nope, this is an idea for a future development based on the question I linked in previous comment.
Tailable cursors may not be the best solution with MONGODB SHARED CLUSTERS
My PR has fixed mqemitter when using with NODEJS CLUSTERS.
Daniel - Software Engineer
Support me at: Github sponsors
On 23 Apr 2020, at 19:59, Matteo Collina notifications@github.com wrote:
Is this fixed?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
I don't know if it's possible to use something else on top of mongo. Go ahead and write another package if it would be a total rewrite of this one.
@mcollina Yes, sure :+1: Keep this open in the meanwhile
@mcollina @robertsLando I tried to start two node services to connect to the same mongo client. I found that the latest task will be consumed twice. Is this normal? How can I solve it?
Code snippet to reproduce the issue?
You can try to pull the code to execute locally
git clone git@github.com:1977744311/issue-mq.git
And you can do:
npm install
npm run issue
Then you can see two services in pm2, You can visit the address of one of the services http://127.0.0.1:3000/api/emit, you can find the result of two emits in pm2 logs
How should I avoid this, or is this package not supporting different instances connecting to the same database
I found that the latest task will be consumed twice. Is this normal? How can I solve it?
What do you mean with 'consumed twice' ? Do you mean that both services receive it once or that each service receive it twice?
both services receive it once
both services receive it once
That's the expected behaviour so. mqemitter is used exactly for that purpose, share messages across multiple instances. If you don't want all instances to receive a specific message you should create your own logic
both services receive it once
That's the expected behaviour so. mqemitter is used exactly for that purpose, share messages across multiple instances. If you don't want all instances to receive a specific message you should create your own logic
okey,thanks for your answer
Consider this question: https://developer.mongodb.com/community/forums/t/mongodb-pub-sub-using-tailable-cursors-in-nodejs-with-clusters/3027/4
This package could have some problems when using mongodb running on shared clusters.
In the question linked there are all the tips to use to make the support, maybe a new mqemitter packege could be created for that instead of making this supporting both