amqp-connection-manager
Advanced tools
Comparing version 1.3.4 to 1.3.5
{ | ||
"name": "amqp-connection-manager", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"description": "Auto-reconnect and round robin support for amqplib.", | ||
@@ -8,4 +8,4 @@ "main": "lib/index.js", | ||
"es6-promise": "^3.0.2", | ||
"lodash": "^3.10.1", | ||
"promise-breaker": "^2.0.3", | ||
"lodash": "^4.15.0", | ||
"promise-breaker": "^3.0.0", | ||
"when": "^3.7.3" | ||
@@ -12,0 +12,0 @@ }, |
@@ -43,25 +43,27 @@ [![Build Status](https://travis-ci.org/benbria/node-amqp-connection-manager.svg?branch=master)](https://travis-ci.org/benbria/node-amqp-connection-manager) | ||
var amqp = require('amqp-connection-manager'); | ||
```js | ||
var amqp = require('amqp-connection-manager'); | ||
// Create a new connection manager | ||
var connection = amqp.connect(['amqp://localhost'], {json: true}); | ||
// Create a new connection manager | ||
var connection = amqp.connect(['amqp://localhost'], {json: true}); | ||
// Ask the connection manager for a ChannelWrapper. Specify a setup function to run every time we reconnect | ||
// to the broker. | ||
var channelWrapper = connection.createChannel({ | ||
setup: function(channel) { | ||
// `channel` here is a regular amqplib `ConfirmChannel`. | ||
return channel.assertQueue('rxQueueName', {durable: true}), | ||
} | ||
}); | ||
// Ask the connection manager for a ChannelWrapper. Specify a setup function to run every time we reconnect | ||
// to the broker. | ||
var channelWrapper = connection.createChannel({ | ||
setup: function(channel) { | ||
// `channel` here is a regular amqplib `ConfirmChannel`. | ||
return channel.assertQueue('rxQueueName', {durable: true}), | ||
} | ||
}); | ||
// Send some messages to the queue. If we're not currently connected, these will be queued up in memory | ||
// until we connect. Note that `sendToQueue()` and `publish()` return a Promise which is fulfilled or rejected | ||
// when the message is actually sent (or not sent.) | ||
channelWrapper.sendToQueue('rxQueueName', {hello: 'world'}) | ||
.then(function() { | ||
return console.log("Message was sent! Hooray!"); | ||
}).catch(function(err) { | ||
return console.log("Message was rejected... Boo!"); | ||
}); | ||
// Send some messages to the queue. If we're not currently connected, these will be queued up in memory | ||
// until we connect. Note that `sendToQueue()` and `publish()` return a Promise which is fulfilled or rejected | ||
// when the message is actually sent (or not sent.) | ||
channelWrapper.sendToQueue('rxQueueName', {hello: 'world'}) | ||
.then(function() { | ||
return console.log("Message was sent! Hooray!"); | ||
}).catch(function(err) { | ||
return console.log("Message was rejected... Boo!"); | ||
}); | ||
``` | ||
@@ -72,9 +74,11 @@ Sometimes it's handy to modify a channel at run time. For example, suppose you have a channel that's listening to | ||
channelWrapper.addSetup(function(channel) { | ||
Promise.all([ | ||
channel.assertQueue("my-queue", { exclusive: true, autoDelete: true }), | ||
channel.bindQueue("my-queue", "my-exchange", "create"), | ||
channel.consume("my-queue", handleMessage) | ||
]) | ||
}); | ||
```js | ||
channelWrapper.addSetup(function(channel) { | ||
Promise.all([ | ||
channel.assertQueue("my-queue", { exclusive: true, autoDelete: true }), | ||
channel.bindQueue("my-queue", "my-exchange", "create"), | ||
channel.consume("my-queue", handleMessage) | ||
]) | ||
}); | ||
``` | ||
@@ -81,0 +85,0 @@ `addSetup()` returns a Promise which resolves when the setup function is finished (or immediately, if the underlying |
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
179
26914
+ Addedlodash@4.17.21(transitive)
+ Addedpromise-breaker@3.0.0(transitive)
- Removedlodash@3.10.1(transitive)
- Removedpromise-breaker@2.2.1(transitive)
Updatedlodash@^4.15.0
Updatedpromise-breaker@^3.0.0