1.2.1 • Published 6 years ago

amqp-sender v1.2.1

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

AMQPSender 1.2.0 library for Node.js

AMQPSender is a library that allows developers to send 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

AMQPSender requires the packages:

  • amqplib - To interact with the AMQP Server
  • lowdb - To store the messages locally
  • shortid - To identify the stored messages

Optional

  • winston - To add a log to AMQPSender. 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-sender

Usage

The recommended way to use amqp-sender is to create your own sender. You can send messages and you should try to send pending messages periodically

const AMQPSender = require('amqp-sender');
const sender = new AMQPSender('foo', 'bar', 'foo.bar.*', './output_queue.json');

sender.send_message({
    "from": "mike",
    "to": "jessie",
    "content": "How are you?",
    "date": 1535214220074
})
    .then((message) => {
        // Message sent correctly
        console.log(message);
    })
    .catch((reason) => {
        // Fail sending the message
        console.warn(reason);
    });

Running the tests

If you want to execute tests to try AMQPSender you have the folder ./tests/ which includes four 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, lowdb and shortid
  • Thanks to all the people that have helped or supported me during this development

Changelog

  • 1.0.0 - 24/08/2018 - Initial release.
  • 1.1.0 - 27/08/2018 - Now, methods of the API send_message() and send_pending_messages() implement a Promise
  • 1.2.0 - 27/08/2018 - Now, sent messages are not stringified
  • 1.2.1 - 02/09/2018 - Solves a bug with concurrency