JSPM

  • Created
  • Published
  • Downloads 1720970
  • Score
    100M100P100Q186860F
  • License MIT

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

Package Exports

  • amqplib
  • amqplib/channel_api
  • amqplib/lib/channel_model
  • amqplib/lib/connection

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (amqplib) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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
  • Ports of the RabbitMQ tutorials as examples

Not yet:

  • Measured test coverage
  • Completely stable APIs
  • Comprehensive documentation
  • Known to be used in production (if anyone is 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.assertQueue(q);
    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.assertQueue(q);
    ch.consume(q, function(msg) {
      if (msg !== null) {
        console.log(msg.content.toString());
        ch.ack(msg);
      }
    });
  });
  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://dev.rabbitmq.com npm test

NB You may experience test failures due to timeouts if using the dev.rabbitmq.com 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