Skip to content

Support for Deleting a Durable Subscription #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Forusim opened this issue Jul 9, 2015 · 2 comments
Open

Support for Deleting a Durable Subscription #114

Forusim opened this issue Jul 9, 2015 · 2 comments

Comments

@Forusim
Copy link

Forusim commented Jul 9, 2015

In the latest 2.3.4 it is not possible to delete a durable subscription.
In the documentation for RabbitMQ or ActiveMQ it is said:
"To permanently delete a durable subscription, send an UNSUBSCRIBE frame for the subscription ID with the persistent header set to true."

The easiest way to this, would be to provide the subscription headers to the client.unsubscribe():

Client.prototype.subscribe = function(destination, callback, headers) {

...some code....

  return {
    id: headers.id,
    unsubscribe: function() {
      return client.unsubscribe(headers);
    }
  };
};

The client.unsubscribe() should be changed to this:

Client.prototype.unsubscribe = function(headers) {
  delete this.subscriptions[headers.id];
  return this._transmit("UNSUBSCRIBE", headers);
};
@fridgebuzz
Copy link

My JavaScript is extremely rusty, but should this not be:

  return {
    id: headers.id,
    unsubscribe: function(headers) {
      return client.unsubscribe(id, headers);
    }
  };

with client.unsubscribe() changed to:

Client.prototype.unsubscribe = function(id, headers) {
  delete this.subscriptions[id];
  if (headers == null) {
    headers = {};
  }
  headers.id = id;
  return this._transmit("UNSUBSCRIBE", headers);
};

so that subscription.unsubscribe() can be called with an optional 'headers' argument? If I'm wrong, corrections are very welcome!

@fridgebuzz
Copy link

Actually, I found an error myself. Let's try this again. I've tried this and it works, which doesn't mean that the OP's code does not also work.

return {
    id: headers.id,
    unsubscribe: function(hdrs) {
      return client.unsubscribe(headers.id, hdrs);
    }
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants