Socket
Socket
Sign inDemoInstall

amqp-connection-manager

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqp-connection-manager - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

6

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc