MongoMQ icon indicating copy to clipboard operation
MongoMQ copied to clipboard

Multiple listener instance in the same process

Open ltozi opened this issue 10 years ago • 1 comments

Hi, I noticed some problem instantiating multiple listener in the same node process. In practice, i created 4 listener for different topic but only one (the last one, queue4 of example) works correctly, while the others do not apper to dequeue messages.

Why is this not allowed?

Example listeners.js:

var queue1 = new MongoMQ({ databaseName: "localDb", autoStart: true, }); var queue2 = new MongoMQ({ databaseName: "localDb", autoStart: true, }); var queue3 = new MongoMQ({ databaseName: "localDb", autoStart: true, }); var queue4 = new MongoMQ({ databaseName: "localDb", autoStart: true, });

queue1.on("type1", callback1....); queue2.on("type2", callback2....); queue3.on("type3", callback3....); queue4.on("type4", callback4....);

Thanks, Luigi

ltozi avatar Jan 26 '15 11:01 ltozi

Sorry for the late response, been really busy and haven't had a bunch of time to go through my Github stuff recently.

That should work just fine, though the Mongo driver will actually pool those connections into a single connection.

I'm actually starting to use MongoMQ in a project again and will be updating it to the latest node-mongo-native driver (2.x.x), when I do I'll add in a test case for this.

jdarling avatar Jan 31 '15 16:01 jdarling