# egg-rabbitmqjs

> rabbitmq plgin for egg.js

Latest version **1.0.12** (published 2021-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-rabbitmqjs
pnpm add egg-rabbitmqjs
yarn add egg-rabbitmqjs
bun add egg-rabbitmqjs
```

## 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.12 |
| Published | 2021-04-16 |
| First published | 2019-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 3 |
| Unpacked size | 13.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | maq |
| Maintainers | stonem2017 |
| Keywords | egg, eggPlugin, egg-plugin |

## Links

- npm: https://www.npmjs.com/package/egg-rabbitmqjs
- Repository: https://github.com/stoneM2017/egg-rabbitmq
- Homepage: https://github.com/stoneM2017/egg-rabbitmq#readme
- Issues: https://github.com/stoneM2017/egg-rabbitmq/issues
- npm.io page: https://npm.io/package/egg-rabbitmqjs

## Dependencies (3)

- [amqplib](https://npm.io/package/amqplib.md) ^0.5.3
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.3
- [aliyun-amqp-node-cli](https://npm.io/package/aliyun-amqp-node-cli.md) ^1.0.0

## Recent versions

- 1.0.12 (latest) — 2021-04-16
- 1.0.11 — 2020-09-24
- 1.0.10 — 2020-05-08
- 1.0.9 — 2020-04-30
- 1.0.8 — 2020-04-01
- 1.0.7 — 2020-04-01
- 1.0.6 — 2020-03-13
- 1.0.5 — 2020-03-13
- 1.0.4 — 2019-04-24
- 1.0.3 — 2019-04-11
- 1.0.2 — 2019-04-10
- 1.0.1 — 2019-03-30
- 1.0.0 — 2019-03-30

## README

# egg-rabbitmq
rabbitmq plugin for egg.js
# Install
$ npm i egg-rabbitmqjs --save
# Configuration
## Multiple Instances
```js
// {app_root}/config/config.default.js
exports.rabbitmq = {
    clients: {
        instance1: {
            url: 'amqp://localhost',
            options: {},
            exchange: {
                name: "xxx",
                type: "direct",
                options: { 
                    durable: true
                },
                bindings: [
                    { queue: "queuename", key: "key", options:{} }
                ],
            },
            deadLetterExchange: {
                name: "xxx",
                type: "direct",
                options: {
                    durable: true
                },
                bindings: [
                    { queue: "queuename", key: "key", options:{} }
                ],
            },
        },
        instance2: {
            url: 'amqp://localhost',
            options: {},
            exchange: {
                name: "xxx",
                type: "direct",
                options: { 
                    durable: true
                },
                bindings: [
                    { queue: "queuename", key: "key", options:{} }
                ],
            },
            deadLetterExchange: {
                name: "xxx",
                type: "direct",
                options: {
                    durable: true
                },
                bindings: [
                    { queue: "queuename", key: "key", options:{} }
                ],
            },
        },
    },
};
```
# Example
## configration
```js
config.rabbitmq = {
    clients: {
      producer: {
          url: 'amqp://localhost',
          options: {},
          exchange: {
              name: "EXCHNAGE_NAME",
              type: "direct",
              options: {
                  durable: true
              },
              bindings: [
                  { queue: "QUEUE_NAME", key: "KEY", options: { exclusive: false, durable: true, maxPriority: 10, deadLetterExchange: "DLX_EXCHANGE" } },
              ],
          },
          deadLetterExchange: {
              name: "DLX_EXCHANGE",
              type: "direct",
              options: {
                  durable: true
              },
              bindings: [
                  { queue: "DLX_QUEUE_NAME", key: "KEY", options: { exclusive: false, durable: true, maxPriority: 10, deadLetterExchange: "DLX_EXCHANGE" } },
              ],
          },
      },
    }
  };
  ```
  ## Usage
  ```js
  let message = {...};
  this.app.rabbitmq.get('producer').publish("EXCHANGE_NAME", message.Key, Buffer.from(JSON.stringify(message)), { priority: message.Priority, persistent: true, mandatory: true });
  ```

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