rabbit.js icon indicating copy to clipboard operation
rabbit.js copied to clipboard

Fixes #63: Updated PubSocket connect to accept a durable parameter

Open stephenmuss opened this issue 10 years ago • 9 comments

Fixes #63

I've made a small change to allow for durable connections in the PubSocket.

Let me know your thoughts and if you think anything should change or if we need to do something similar elsewhere.

stephenmuss avatar Jun 29 '14 23:06 stephenmuss

I am thinking that a 'persistent' socket, either set in the constructor or by setsockopt, should declare its exchange to be durable. Does that break anything? (except backwards compatibility)

squaremo avatar Jul 02 '14 22:07 squaremo

Does it break backwards compatibility? From what I can tell it should be backwards compatible.

I'm happy to make any changes you see fit. This was more to get your thoughts.

stephenmuss avatar Jul 02 '14 22:07 stephenmuss

Does it break backwards compatibility?

In the sense that someone already using a "persistent" PUB or SUB socket will encounter breakages, since rabbit.js will try to re-declare the exchanges involved with a different 'durable' property (AMQP doesn't like this).

squaremo avatar Jul 02 '14 22:07 squaremo

Fair enough. I hadn't considered that people may already be passing persistent through as an option to the PubSocket and SubSocket constructors.

stephenmuss avatar Jul 02 '14 22:07 stephenmuss

This seems sound to me. A major version bump should be reasonable for this change as it would not affect anyone using it in this way. Semver to the rescue :). Thoughts @squaremo ?

jcrugzz avatar Dec 31 '14 03:12 jcrugzz

Hello! Do we have any updates on this PR? Is there some changes needed to make it possible to configure durable queue?

dev-tim avatar Feb 20 '15 14:02 dev-tim

Update with durable queue issue. You can't just make queue durable in this case. The reason behind it is that in PubSocket you are not supposed to manage queues at all, here you should use topics instead.

Moreover in rabbit.js while creating SUB socket amqp.node's assertQueue method is used which creates new random queue on each subscribe:

ch.assertQueue('', {
      exclusive: true, autoDelete: true
  })

which can be potentially a leak if you make you queues durable.

So if you want to have durable queues you also want to specify queue name explicitly, event if it breaks concept PUB/SUB managed by topic.

I'll propose another PR.

dev-tim avatar Feb 23 '15 11:02 dev-tim

We have an existing AMQP exchange with python/Java, etc bindings that is setup with durable=True. I want to interface this using rabbit.js / PubSocket but cannot since durable is hardcoded to False. I found the following to fix my problem: In SubSocket.prototype.connect, change: ch.assertExchange(source, this.options.routing || 'fanout', {durable: false, autoDelete: false}) to ch.assertExchange(source, this.options.routing || 'fanout', {durable: this.options.persistent, autoDelete: false}) Should I create a pull request or will this have any negative side-effects?

johanzander avatar Jul 02 '15 10:07 johanzander

I may be running into this as well:

Error: Channel closed by server: 406 (PRECONDITION-FAILED) with message "PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'PullData.Response' in vhost '/': received 'false' but current is 'true'"
  at Channel.C.accept (/Users/collumj/work/alpha/node_modules/rabbit.js/node_modules/amqplib/lib/channel.js:398:24)

jcollum avatar Jul 02 '15 15:07 jcollum