1.0.1 • Published 6 years ago

amqp-receiver v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

AMQPReceiver 1.0.1 library for Node.js

AMQPReceiver is a library that allows developers to receive AMQP messages with persistence transparently

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system

Dependences

AMQPReceiver requires the packages:

  • amqplib - To interact with the AMQP Server

Optional

  • winston - To add a log to AMQPReceiver. By default there is no log

Installing

If you already have Node.js and npm on your system you can install the library simply by downloading the distribution, unpack it and install in the usual fashion:

npm install amqp-receiver

Usage

The recommended way to use amqp-receiver is to create your own receiver. You have to start the receiver to start receiving messages and it is going to reconnect automatically and to execute a callback every time a message is received

const AMQPReceiver = require('amqp-receiver');
const receiver = new AMQPReceiver('foo', 'bar', 'foo.bar.*');

receiver.start((message) => {
    console.log(message);
})

IMPORTANT!! Executing the AMQPReceiver creates a persistent queue on the AMQP Server that ensures persistence of messages. However, persistence can not be ensured if AMQPReceiver has not been executed before, so messages received before the initialization can be lost.

Running the tests

If you want to execute tests to try AMQPReceiver you have the folder ./tests/ which includes two tests:

IMPORTANT!! To test using_logger.js you have to install Winston which is not a dependence by default

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Thanks to the authors and contributors of amqplib
  • Thanks to all the people that have helped or supported me during this development

Changelog

  • 1.0.0 - 27/08/2018 - Initial release
  • 1.0.1 - 27/08/2018 - Solves a minor bug with the logger