rabbit.js
rabbit.js copied to clipboard
Fixes #63: Updated PubSocket connect to accept a durable parameter
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.
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)
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.
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).
Fair enough. I hadn't considered that people may already be passing persistent
through as an option to the PubSocket
and SubSocket
constructors.
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 ?
Hello! Do we have any updates on this PR? Is there some changes needed to make it possible to configure durable queue?
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.
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?
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)