Durable Group Subscriptions
See original GitHub issueHi, I’m attempting to set up a durable group subscription where N subscribers in a group can consume a queue, and if all N consumers crash (no unsubscribing or closing) when any new subscriber connects, it will start processing any message not ACK’d by any subscriber in the group
As far as I can tell this is not possible, due durable subscriptions using a combination of the clientId and durable name, and since you can’t have two consumers with the same client id, you can’t have two subscribers sharing the same durable queue…?
Here is my test publisher:
var stan = require('node-nats-streaming').connect('test-cluster', 'test-' + parseInt(Math.random() * 100000));
stan.on('connect', function () {
setInterval(function(){
stan.publish('foo', Date.now() + ' Hello node-nats-streaming!', function(err, guid){
if(err) {
return console.log('publish failed: ' + err);
}
console.log('published message with guid: ' + guid);
});
}, 1000)
});
And here is a test consumer that works with N subscribers, but does not get all messages:
var stan = require('node-nats-streaming').connect('test-cluster', 'test-' + parseInt(Math.random() * 100000));
stan.on('connect', function () {
var opts = stan.subscriptionOptions();
opts.setDeliverAllAvailable();
opts.setDurableName('durable-name');
var subscription = stan.subscribe('foo', 'group', opts);
subscription.on('message', function (msg) {
console.log('Received a message [' + msg.getSequence() + '] ' + msg.getData());
});
});
Changing the clientId to a static value results in a test consumer that works with only ONE subscriber, but DOES consume every event in order even if it is killed and restarted while messages are being added to the queue.
Let me know if I’m not being clear, I’m happy to set up a working git repo if that helps.
Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
@KoryNunn closing this issue, as it seems we have resolutions. Feel free to re-open/or open a new one if you have a more specific issue.
Yes it would. But I just created an issue for the server where I noticed a possible issue (https://github.com/nats-io/nats-streaming-server/issues/862)