Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Enable consumeBasic exclusive option through subscribe() method #145

Merged
merged 1 commit into from

2 participants

@doozr

The ability to request exclusive access to a queue that is not autodeleted is hidden behind the subscribeRaw function. It is a handy thing to have to automatic failover of listening clients. Only one can connect at a time, and if that one dies, another can immediately take over and be assured of exclusivity.

@postwait postwait merged commit af2db98 into postwait:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2012
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +7 −0 README.md
  2. +6 −1 amqp.js
View
7 README.md
@@ -200,6 +200,13 @@ thus adopting the parent connection's values (which default to false).
Setting these to true provide backward compability for older
applications.
+The 'exclusive' option will subscribe to the queue in exclusive mode. Only one
+subscriber is allowed at a time, and subsequent attempts to subscribe to the
+same queue will result in an exception. This option differes from the exclusive
+option passed when creating in a queue in that the queue itself is not exclusive,
+only the consumers. This means that long lived durable queues can be used
+as exclusive queues.
+
This method will emit `'basicQosOk'` when ready.
View
7 amqp.js
@@ -1638,11 +1638,16 @@ Queue.prototype.subscribe = function (/* options, messageListener */) {
options.deliveryTagInPayload = arguments[0].deliveryTagInPayload;
if (arguments[0].prefetchCount != undefined)
options.prefetchCount = arguments[0].prefetchCount;
+ if (arguments[0].exclusive)
+ options.exclusive = arguments[0].exclusive;
}
// basic consume
- var rawOptions = { noAck: !options.ack };
+ var rawOptions = {
+ noAck: !options.ack,
+ exclusive: options.exclusive
+ };
if (options.ack) {
rawOptions['prefetchCount'] = options.prefetchCount;
}
Something went wrong with that request. Please try again.