An AMQP 0-9-1 (e.g., RabbitMQ) library and client.

npm install amqplib
20 downloads in the last day
892 downloads in the last week
2 890 downloads in the last month

AMQP 0-9-1 library and client for Node.JS

Build Status

npm install amqplib

A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1 client for Node.JS v0.8, v0.9, v0.10, and v0.11.

Project status:

  • Expected to work
  • Complete high-level and low-level APIs (i.e., all bits of the protocol)
  • A fair few tests
  • Measured test coverage
  • Ports of the RabbitMQ tutorials as examples

Still working on:

  • Getting to 100% (or very close to 100%) test coverage
  • Settling on completely stable APIs
  • Establishing a long history of battle-testing in production (if anyone has been using it in production, do let me know)

Client API example

var q = 'tasks';

var open = require('amqplib').connect('amqp://localhost');

// Publisher
open.then(function(conn) {
  var ok = conn.createChannel();
  ok = ok.then(function(ch) {
    ch.sendToQueue(q, new Buffer('something to do'));
  return ok;
}).then(null, console.warn);

// Consumer
open.then(function(conn) {
  var ok = conn.createChannel();
  ok = ok.then(function(ch) {
    ch.consume(q, function(msg) {
      if (msg !== null) {
  return ok;
}).then(null, console.warn);

Running tests

npm test

Best run with a locally-installed RabbitMQ, but you can point it at another using the environment variable URL; e.g.,

URL=amqp:// npm test

NB You may experience test failures due to timeouts if using the instance.

You can run it under different versions of Node.JS using nave:

nave use 0.8 npm test

or run the tests on all supported versions of Node.JS in one go:

make test-all-nodejs

(which also needs nave installed, of course).

Lastly, setting the environment variable LOG_ERRORS will cause the tests to output error messages encountered, to the console; this is really only useful for checking the kind and formatting of the errors.

LOG_ERRORS=true npm test

Test coverage

make coverage
open file://`pwd`/coverage/lcov-report/index.html
npm loves you