Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amqplib

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqplib - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

16

CHANGELOG.md
# Change log for amqplib
## Changes in v0.9.1
git log v0.9.0..v0.9.1
* Assorted readme changes
* Use Array.prototype.push.apply instead of concat in Mux ([PR
658](https://github.com/squaremo/amqp.node/pull/658), thank you
@Uzlopak and @kibertoad)
* Use Map instead of Object for BaseChannel.consumers ([PR
660](https://github.com/squaremo/amqp.node/pull/660), thank you
@Uzlopak)
* Delete consumer callback after cancellation to free memory ([PR
659](https://github.com/squaremo/amqp.node/pull/659), thank you
@Uzlopak and @kibertoad)
## Changes in v0.9.0

@@ -4,0 +20,0 @@

12

lib/channel.js

@@ -463,3 +463,3 @@ //

Channel.call(this, connection);
this.consumers = {};
this.consumers = new Map();
}

@@ -473,7 +473,7 @@ inherits(BaseChannel, Channel);

BaseChannel.prototype.registerConsumer = function(tag, callback) {
this.consumers[tag] = callback;
this.consumers.set(tag, callback);
};
BaseChannel.prototype.unregisterConsumer = function(tag) {
delete this.consumers[tag];
this.consumers.delete(tag);
};

@@ -483,3 +483,3 @@

var consumerTag = fields.consumerTag;
var consumer = this.consumers[consumerTag];
var consumer = this.consumers.get(consumerTag);
if (consumer) {

@@ -499,3 +499,5 @@ return consumer(message);

BaseChannel.prototype.handleCancel = function(fields) {
return this.dispatchMessage(fields, null);
var result = this.dispatchMessage(fields, null);
this.unregisterConsumer(fields.consumerTag);
return result;
};

@@ -11,3 +11,2 @@ //

var inherits = require('util').inherits;
var assert = require('assert');

@@ -51,3 +50,2 @@

var self = this;
var accepting = true;

@@ -84,3 +82,3 @@ var out = this.out;

assert(this.newStreams.length > 0, "Expect some new streams to remain");
this.oldStreams = this.oldStreams.concat(this.newStreams);
Array.prototype.push.apply(this.oldStreams, this.newStreams);
this.newStreams = [];

@@ -87,0 +85,0 @@ }

{
"name": "amqplib",
"homepage": "http://squaremo.github.io/amqp.node/",
"homepage": "http://amqp-node.github.io/amqplib/",
"main": "./channel_api.js",
"version": "0.9.0",
"version": "0.9.1",
"description": "An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",
"repository": {
"type": "git",
"url": "https://github.com/squaremo/amqp.node.git"
"url": "https://github.com/amqp-node/amqplib.git"
},

@@ -11,0 +11,0 @@ "engines": {

# AMQP 0-9-1 library and client for Node.JS
[![Build Status](https://travis-ci.org/squaremo/amqp.node.png)](https://travis-ci.org/squaremo/amqp.node)
[![NPM version](https://img.shields.io/npm/v/amqplib.svg?style=flat-square)](https://www.npmjs.com/package/amqplib)
[![NPM downloads](https://img.shields.io/npm/dm/amqplib.svg?style=flat-square)](https://www.npmjs.com/package/amqplib)
[![Node.js CI](https://github.com/amqp-node/amqplib/workflows/Node.js%20CI/badge.svg)](https://github.com/amqp-node/amqplib/actions?query=workflow%3A%22Node.js+CI%22)
[![amqplib](https://snyk.io/advisor/npm-package/amqplib/badge.svg)](https://snyk.io/advisor/npm-package/amqplib)

@@ -10,4 +13,6 @@ npm install amqplib

* [API reference][gh-pages-apiref]
* [Troubleshooting][gh-pages-trouble]
* [Examples from RabbitMQ tutorials][tutes]
A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1 client for Node.JS v10+.

@@ -36,71 +41,67 @@

```javascript
var q = 'tasks';
const amqplib = require('amqplib/callback_api');
const queue = 'tasks';
function bail(err) {
console.error(err);
process.exit(1);
}
amqplib.connect('amqp://localhost', (err, conn) => {
if (err) throw err;
// Publisher
function publisher(conn) {
conn.createChannel(on_open);
function on_open(err, ch) {
if (err != null) bail(err);
ch.assertQueue(q);
ch.sendToQueue(q, Buffer.from('something to do'));
}
}
// Listener
conn.createChannel((err, ch2) => {
if (err) throw err;
// Consumer
function consumer(conn) {
var ok = conn.createChannel(on_open);
function on_open(err, ch) {
if (err != null) bail(err);
ch.assertQueue(q);
ch.consume(q, function(msg) {
ch2.assertQueue(queue);
ch2.consume(queue, (msg) => {
if (msg !== null) {
console.log(msg.content.toString());
ch.ack(msg);
ch2.ack(msg);
} else {
console.log('Consumer cancelled by server');
}
});
}
}
});
require('amqplib/callback_api')
.connect('amqp://localhost', function(err, conn) {
if (err != null) bail(err);
consumer(conn);
publisher(conn);
// Sender
conn.createChannel((err, ch1) => {
if (err) throw err;
ch1.assertQueue(queue);
setInterval(() => {
ch1.sendToQueue(queue, Buffer.from('something to do'));
}, 1000);
});
});
```
## Promise API example
## Promise/Async API example
```javascript
var q = 'tasks';
const amqplib = require('amqplib');
var open = require('amqplib').connect('amqp://localhost');
(async () => {
const queue = 'tasks';
const conn = await amqplib.connect('amqp://localhost');
// Publisher
open.then(function(conn) {
return conn.createChannel();
}).then(function(ch) {
return ch.assertQueue(q).then(function(ok) {
return ch.sendToQueue(q, Buffer.from('something to do'));
const ch1 = await conn.createChannel();
await ch1.assertQueue(queue);
// Listener
ch1.consume(queue, (msg) => {
if (msg !== null) {
console.log('Recieved:', msg.content.toString());
ch1.ack(msg);
} else {
console.log('Consumer cancelled by server');
}
});
}).catch(console.warn);
// Consumer
open.then(function(conn) {
return conn.createChannel();
}).then(function(ch) {
return ch.assertQueue(q).then(function(ok) {
return ch.consume(q, function(msg) {
if (msg !== null) {
console.log(msg.content.toString());
ch.ack(msg);
}
});
});
}).catch(console.warn);
// Sender
const ch2 = await conn.createChannel();
setInterval(() => {
ch2.sendToQueue(queue, Buffer.from('something to do'));
}, 1000);
})();
```

@@ -132,3 +133,3 @@

nave use 0.8 npm test
nave use 10 npm test

@@ -152,8 +153,9 @@ or run the tests on all supported versions of Node.JS in one go:

[gh-pages]: http://www.squaremobius.net/amqp.node/
[gh-pages-apiref]: http://www.squaremobius.net/amqp.node/channel_api.html
[gh-pages]: https://amqp-node.github.io/amqplib/
[gh-pages-apiref]: https://amqp-node.github.io/amqplib/channel_api.html
[gh-pages-trouble]: https://amqp-node.github.io/amqplib/#troubleshooting
[nave]: https://github.com/isaacs/nave
[tutes]: https://github.com/squaremo/amqp.node/tree/main/examples/tutorials
[tutes]: https://github.com/amqp-node/amqplib/tree/main/examples/tutorials
[rabbitmq-tutes]: http://www.rabbitmq.com/getstarted.html
[changelog]: https://github.com/squaremo/amqp.node/blob/main/CHANGELOG.md
[changelog]: https://github.com/amqp-node/amqplib/blob/main/CHANGELOG.md
[docker]: https://www.docker.com/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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