# amqp-receiver

> API to receive AMQP messages with persistence transparently

Latest version **1.0.1** (published 2018-08-26) · MIT license · 0 weekly downloads

## Install

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

## 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.0.1 |
| Published | 2018-08-26 |
| First published | 2018-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Marc Solé Fonte |
| Maintainers | wolfylpdc |
| Keywords | amqp, receiver, messaging, rabbitmq, persistence, amqp api |

## Links

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

## Dependencies (1)

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

## Recent versions

- 1.0.1 (latest) — 2018-08-26
- 1.0.0 — 2018-08-26

## README

# 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](https://github.com/squaremo/amqp.node) - To interact with the AMQP Server

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

```js
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:
 * [starting_server.js](https://github.com/WolfyLPDC/AMQPReceiver/blob/master/tests/starting_server.js) - Example of 
 showing on console messages received from a default RabbitMQ Server
 * [stoping_server.js](https://github.com/WolfyLPDC/AMQPReceiver/blob/master/tests/stoping_server.js) - Example of 
 starting and clossing a connection to a default RabbitMQ Server
 * [using_custom_amqp_server.js](https://github.com/WolfyLPDC/AMQPReceiver/blob/master/tests/using_custom_amqp_server.js) - 
 Example of showing on console messages received from a custom AMQP Server
 * [using_logger.js](https://github.com/WolfyLPDC/AMQPReceiver/blob/master/tests/using_logger.js) - Example of 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/AMQPReceiver/blob/master/LICENSE.md) file for details

## Acknowledgments

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

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