Skip to content

Commit

Permalink
Use correct names for arguments fields
Browse files Browse the repository at this point in the history
Extensions tend to go in the arguments table, which is serialised
as-is rather than going through name translation. Most of these
(except 'alternate-exchange') have an 'x-' prefix.

I'd also forgotten to include 'x-message-ttl', and I was mutating the
passed-in arguments object.
  • Loading branch information
squaremo committed Aug 1, 2013
1 parent 10bd4fe commit 3749c66
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/channel_api.js
Expand Up @@ -82,15 +82,18 @@ C.assertQueue = function(queue, options) {
queue = queue || '';
options = options || {};
var args;
if (options.expires ||
if (options.messageTtl ||
options.expires ||
options.deadLetterExchange ||
options.deadLetterRoutingKey ||
options.maxLength) {
args = options.arguments || {};
args.expires = options.expires;
args.deadLetterExchange = options.deadLetterExchange;
args.deadLetterRoutingKey = options.deadLetterRoutingKey;
args.maxLength = options.maxLength;
args = (options.arguments) ?
Object.create(options.arguments) : {};
args['x-expires'] = options.expires;
args['x-message-ttl'] = options.messageTtl;
args['x-dead-letter-exchange'] = options.deadLetterExchange;
args['x-dead-letter-routing-key'] = options.deadLetterRoutingKey;
args['x-max-length'] = options.maxLength;
}

var fields = {
Expand Down Expand Up @@ -165,8 +168,10 @@ C.assertExchange = function(exchange, type, options) {
options = options || {};
var args;
if (options.alternateExchange) {
args = options.arguments || {};
args.alternateExchange = options.alternateExchange;
args = (options.arguments) ?
Object.create(options.arguments) : {};
// NB no 'x-' prefix for some reason
args['alternate-exchange'] = options.alternateExchange;
}
var fields = {
exchange: exchange,
Expand Down

3 comments on commit 3749c66

@martijndeh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just discovered the issue in Channel#assertQueue (re. DLX) and noticed it was already fixed over here but not pushed to npm yet. Thank you for your work.

@squaremo
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already fixed over here but not pushed to npm yet

I'm considering putting a v0.0.2 up soon.

@martijndeh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if you'd push v0.0.2 to npm.

Please sign in to comment.