# notifme-sdk-queue-rabbitmq

> RabbitMQ plugin for Notif.me SDK

Latest version **4.0.0** (published 2017-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install notifme-sdk-queue-rabbitmq
pnpm add notifme-sdk-queue-rabbitmq
yarn add notifme-sdk-queue-rabbitmq
bun add notifme-sdk-queue-rabbitmq
```

## 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 | 4.0.0 |
| Published | 2017-08-23 |
| First published | 2017-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Notif.me |
| Maintainers | bdav24 |

## Links

- npm: https://www.npmjs.com/package/notifme-sdk-queue-rabbitmq
- Repository: https://github.com/notifme/notifme-sdk-queue-rabbitmq
- Homepage: https://github.com/notifme/notifme-sdk-queue-rabbitmq#readme
- Issues: https://github.com/notifme/notifme-sdk-queue-rabbitmq/issues
- npm.io page: https://npm.io/package/notifme-sdk-queue-rabbitmq

## Dependencies (2)

- [amqplib](https://npm.io/package/amqplib.md) ^0.5.1
- [babel-runtime](https://npm.io/package/babel-runtime.md) ^6.26.0

## Recent versions

- 4.0.0 (latest) — 2017-08-23
- 3.0.1 — 2017-08-19
- 3.0.0 — 2017-08-19
- 2.0.0 — 2017-08-16
- 1.0.1 — 2017-08-16

## README

<p align="center">
  <a href="https://www.notif.me">
    <img alt="Notif.me" src="https://notifme.github.io/notifme-sdk/img/logo.png" />
  </a>
</p>

<p align="center">
  RabbitMQ plugin for <a href="https://github.com/notifme/notifme-sdk">Notif.me SDK</a>.
</p>

<p align="center">
  <a href="https://www.npmjs.com/package/notifme-sdk-queue-rabbitmq"><img alt="npm-status" src="https://img.shields.io/npm/v/notifme-sdk-queue-rabbitmq.svg?style=flat" /></a>
  <a href="https://github.com/standard/standard"><img alt="js-standard-style" src="https://img.shields.io/badge/codestyle-standard-brightgreen.svg?style=flat" /></a>
  <a href="https://flow.org/"><img alt="flow-typed" src="https://img.shields.io/badge/typing-Flow_Type-brightgreen.svg?style=flat" /></a>
  <a href="https://github.com/notifme/notifme-sdk-queue-rabbitmq/blob/master/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-MIT_License-blue.svg?style=flat" /></a>
</p>

- [Features](#features)
- [Getting started](#getting-started)
- [How to use](#how-to-use)
- [Contributing](#contributing)
- [Need help? Found a bug?](#need-help-found-a-bug)

## Features

* **Easy integration** — Just plug and play.

* **Breakdown management** — Try to reconnect automatically if connection to queue is lost, and let you choose what to do with notification requests in the meantime.

* **MIT license** — Use it like you want.

## Getting Started

### In your application

```shell
$ yarn add notifme-sdk-queue-rabbitmq
```

```javascript
import NotifmeRabbitMqProducer from 'notifme-sdk-queue-rabbitmq/lib/producer'

const notificationService = new NotifmeRabbitMqProducer({
  url: 'amqp://localhost'
})

notificationService.enqueueNotification({
  sms: {from: '+15000000000', to: '+15000000001', text: 'Hello, how are you?'}
}).catch(console.error)
```

### In your worker

```shell
$ yarn add notifme-sdk notifme-sdk-queue-rabbitmq
```

```javascript
import NotifmeSdk from 'notifme-sdk'
import NotifmeRabbitMqConsumer from 'notifme-sdk-queue-rabbitmq/lib/consumer'

const notifmeSdk = new NotifmeSdk({
  /*
   * Define all your providers here.
   * (see documentation: https://github.com/notifme/notifme-sdk#2-providers)
   */
})

const notifmeWorker = new NotifmeRabbitMqConsumer(notifmeSdk, {
  url: 'amqp://localhost'
})

notifmeWorker.run(async (request) => {
  const result = await notifmeSdk.send(request)
  if (result.status === 'error') {
    /*
     * Some channels of this request have errors.
     * Which means all your providers failed for these channels.
     * Do you want to retry failing channels by enqueing to a delayed queue?
     */
  }
})
```

See a [complete working example](https://github.com/notifme/notifme-sdk-queue-rabbitmq/tree/master/example) for more details.

## How to use

### Producer options

```javascript
new NotifmeRabbitMqProducer({
  keepRequestsInMemoryWhileConnecting: ...,
  url: ...,
  amqpOptions: ...,
  queueName: ...,
  isPersistent: ...,
  reconnectDelaySecond: ...
})
```

| Option name | Type | Default | Description |
| --- | --- | --- | --- |
| `keepRequestsInMemoryWhileConnecting` | `boolean` | `false` | Should the requests be kept in memory while queue is (re)connecting? If set to `true`, may cause memory overflow. |
| `url` | `string` | `'amqp://localhost'` | RabbitMQ URL. See [amqplib documentation](http://www.squaremobius.net/amqp.node/channel_api.html#connect). |
| `amqpOptions` | `Object` | `{}` | Connection options. See [amqplib documentation](http://www.squaremobius.net/amqp.node/channel_api.html#connect). |
| `queueName` | `string` | `'notifme:request'` | Name of the queue to use. |
| `isPersistent` | `boolean` | `true` | Is the queue persistent? |
| `reconnectDelaySecond` | `number` | `30` | Time in second to wait between two reconnection tries. |

### Consumer options

```javascript
new NotifmeRabbitMqConsumer({
  url: ...,
  amqpOptions: ...,
  queueName: ...,
  isPersistent: ...,
  reconnectDelaySecond: ...
})
```

| Option name | Type | Default | Description |
| --- | --- | --- | --- |
| `url` | `string` | `'amqp://localhost'` | RabbitMQ URL. See [amqplib documentation](http://www.squaremobius.net/amqp.node/channel_api.html#connect). |
| `amqpOptions` | `Object` | `{}` | Connection options. See [amqplib documentation](http://www.squaremobius.net/amqp.node/channel_api.html#connect). |
| `queueName` | `string` | `'notifme:request'` | Name of the queue to use. |
| `isPersistent` | `boolean` | `true` | Is the queue persistent? |
| `reconnectDelaySecond` | `number` | `30` | Time in second to wait between two reconnection tries. |

## Contributing

Contributions are very welcome!

To get started: [fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device.

```shell
$ git clone git@github.com:[YOUR_USERNAME]/notifme-sdk-queue-rabbitmq.git && cd notifme-sdk-queue-rabbitmq
$ yarn install
```

## Need Help? Found a bug?

[Submit an issue](https://github.com/notifme/notifme-sdk-queue-rabbitmq/issues) to the project Github if you need any help.
And, of course, feel free to submit pull requests with bug fixes or changes.

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