# amqp-sender

> API to send AMQP messages with persistence transparently

Latest version **1.2.1** (published 2018-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install amqp-sender
pnpm add amqp-sender
yarn add amqp-sender
bun add amqp-sender
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2018-09-02 |
| First published | 2018-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 21 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Marc Solé Fonte |
| Maintainers | wolfylpdc |
| Keywords | amqp, sender, messaging, rabbitmq, persistence, amqp api |

## Links

- npm: https://www.npmjs.com/package/amqp-sender
- Homepage: https://github.com/WolfyLPDC/AMQPSender
- Issues: https://github.com/WolfyLPDC/AMQPSender/issues
- npm.io page: https://npm.io/package/amqp-sender

## Dependencies (3)

- [lowdb](https://npm.io/package/lowdb.md) ^1.0.0
- [amqplib](https://npm.io/package/amqplib.md) ^0.5.2
- [shortid](https://npm.io/package/shortid.md) ^2.2.13

## Recent versions

- 1.2.1 (latest) — 2018-09-02

## README

# 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](https://github.com/squaremo/amqp.node) - To interact with the AMQP Server
- [lowdb](https://github.com/typicode/lowdb) - To store the messages locally
- [shortid](https://github.com/dylang/shortid) - To identify the stored messages

[Optional]
- [winston](https://github.com/winstonjs/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

```js
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:
 * [send_json_default.js](https://github.com/WolfyLPDC/AMQPSender/blob/master/tests/send_json_default.js) - Example of 
 sending a JSON to a default RabbitMQ Server
 * [send_multiple_jsons.js](https://github.com/WolfyLPDC/AMQPSender/blob/master/tests/send_multiple_jsons.js) - Example 
 of sending multiple JSONs
 * [using_custom_amqp.js](https://github.com/WolfyLPDC/AMQPSender/blob/master/tests/using_custom_amqp_server.js) - 
 Example of sending a JSON to a custom AMQP Server
 * [using_logger.js](https://github.com/WolfyLPDC/AMQPSender/blob/master/tests/using_logger.js) - Example of sending a 
 JSON logging using a Winston logger
 
**__IMPORTANT!!__** To test `using_logger.js` you have to install Winston which is not a dependence by default

## Authors

* **Marc Solé Fonte** - *Initial work* - [WolfyLPDC](https://github.com/WolfyLPDC/)

## License

This project is licensed under the MIT License - see the 
[LICENSE.md](https://github.com/WolfyLPDC/AMQPSender/blob/master/LICENSE.md) file for details

## Acknowledgments

* Thanks to the authors and contributors of [amqplib](https://github.com/squaremo/amqp.node), 
[lowdb](https://github.com/typicode/lowdb) and [shortid](https://github.com/dylang/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

---
_Source: https://npm.io/package/amqp-sender · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
