amqplib-easy
Advanced tools
Comparing version 4.0.0 to 4.1.0
14
API.md
@@ -29,3 +29,3 @@ - [`Create(amqpUrl)`](#createamqpurl-socketoptions---amqp) | ||
that exchange with routing key, `key` and `options` (if they exist) as in | ||
[amqplib](http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_60). | ||
[amqplib](http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish). | ||
If message is a `Buffer`, it is sent as is, otherwise, it is serialized to JSON | ||
@@ -37,3 +37,3 @@ and sent. | ||
queue with `options` (if they exist) as in | ||
[amqplib](http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_60). | ||
[amqplib](http://www.squaremobius.net/amqp.node/channel_api.html#channel_sendToQueue). | ||
If message is a `Buffer`, it is sent as is, otherwise, it is serialized to JSON | ||
@@ -44,3 +44,3 @@ and sent. | ||
Returns [`amqplib` connection] | ||
(http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_11) | ||
(http://www.squaremobius.net/amqp.node/channel_api.html#models) | ||
for handling use cases not covered by this library, e.g., deleting queues. | ||
@@ -52,3 +52,3 @@ | ||
- `exchangeOptions`: (object) of options supported by | ||
[amqplib](http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_45). | ||
[amqplib](http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertExchange). | ||
Defaults to `{ durable: true }` | ||
@@ -59,3 +59,3 @@ - `exchangeType`: (string) | ||
- `messageOptions`: (object) of options supported by | ||
[amqplib](http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_60). | ||
[amqplib](http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish). | ||
Defaults to an empty object | ||
@@ -67,4 +67,6 @@ - `parse`: (function) parse string content of message. Defaults to `JSON.parse` | ||
- `queueOptions`: (object) of options supported by | ||
[amqplib](http://www.squaremobius.net/amqp.node/doc/channel_api.html#toc_27). | ||
[amqplib](http://www.squaremobius.net/amqp.node/channel_api.html#channel_assertQueue). | ||
Defaults to `{ durable: true }` | ||
- `topics`: (array of strings) topics to bind to the queue from the exchange. | ||
Only for `topic` exchanges. | ||
- `retry`: (boolean or object) if false, disable retry via | ||
@@ -71,0 +73,0 @@ [amqplib-retry](https://www.npmjs.com/package/amqplib-retry). An object with |
@@ -104,2 +104,4 @@ 'use strict'; | ||
}); | ||
} else if (options.exchangeType === 'fanout') { | ||
return ch.bindQueue(options.queue, options.exchange, '', options.arguments); | ||
} | ||
@@ -106,0 +108,0 @@ }) |
{ | ||
"name": "amqplib-easy", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Simplified API for interacting with AMQP", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,4 +25,3 @@ /*globals it:false*/ | ||
]) | ||
.catch(function (err) { | ||
console.log('boom', err); | ||
.catch(function () { | ||
//the queue doesn't exist, so w/e | ||
@@ -150,4 +149,53 @@ return; | ||
}); | ||
describe('fanout exchange', function () { | ||
function deleteCat() { | ||
return amqp.connect() | ||
.then(function (connection) { | ||
return connection.createChannel() | ||
.then(function (channel) { | ||
channel.checkExchange('cat') | ||
.then( | ||
function () { | ||
channel.deleteExchange('cat'); | ||
}, | ||
function () { /* NBD it doesn't exist */ } | ||
); | ||
}); | ||
}); | ||
} | ||
beforeEach(deleteCat); | ||
afterEach(deleteCat); | ||
it('should publish via fanout', function (done) { | ||
amqp.consume( | ||
{ | ||
exchange: 'cat', | ||
exchangeType: 'fanout', | ||
queue: 'found_cats' | ||
}, | ||
function (cat) { | ||
var name = cat.json.name; | ||
try { | ||
name.should.equal('Sally'); | ||
done(); | ||
} catch (err) { done(err); } | ||
} | ||
) | ||
.then(function (c) { | ||
cancel = c; | ||
return amqp.publish( | ||
{ exchange: 'cat', exchangeType: 'fanout' }, | ||
'found.tawny', | ||
{ name: 'Sally' } | ||
); | ||
}) | ||
.catch(done); | ||
}); | ||
}); | ||
}); | ||
it('should cancel consumer', function (done) { | ||
@@ -154,0 +202,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22953
451