question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Durable Group Subscriptions

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aricartcommented, Jul 8, 2019

@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.

1reaction
kozloviccommented, Jun 28, 2019

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Durable Subscriptions with Multiple Clients
When you define a shared durable subscription, Universal Messaging maintains a copy of all of the events of the durable subscription in an...
Read more >
Durable - NATS Docs
Once unsubscribed, the state is removed and it is then possible to re-use the durable name, but it will be considered a brand...
Read more >
Durable Subscriptions attributes - IBM
A durable subscription can be used to preserve messages published on a topic while the subscriber is not active. The attributes within this...
Read more >
Durable Subscribers for Topics - TIBCO Product Documentation
Durable subscribers can receive messages from a durable subscription even if the subscriber was not available when the message was originally delivered. When...
Read more >
Durable subscriptions - Progress Documentation
Durable subscriptions provide a mechanism to save messages for an unavailable client. Whenever a subscriber reconnects to the topic under the name it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found