# amqp-setup

> This package is useful to centralize all RabbitMQ configuration in only one channel.

Latest version **0.0.3** (published 2019-08-08) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-08-08 |
| First published | 2019-06-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.16.0 |
| Dependencies | 2 |
| Unpacked size | 15.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Celso Marques |
| Maintainers | celsomarques |
| Keywords | amqp, amqplib, rabbitmq |

## Links

- npm: https://www.npmjs.com/package/amqp-setup
- Repository: https://github.com/celsomarques/amqp-setup
- Issues: https://github.com/celsomarques/amqp-setup/issues
- npm.io page: https://npm.io/package/amqp-setup

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) 4.1.1
- [bluebird](https://npm.io/package/bluebird.md) 3.5.5

## Recent versions

- 0.0.3 (latest) — 2019-08-08
- 0.0.2 — 2019-06-28
- 0.0.1 — 2019-06-27

## README

## Usage


*exchanges.json*

```
[
  {
    "name": "person.ex",
    "type": "fanout"
  }
]
```


*queues.json*

```
[
  {
    "name": "person.q",
    "options": { "deadLetterExchange": "person.dead.ex" }
  },
  { "name": "person.manual-reprocess.q" }
]
```


*bindings.json*

```
[
  { "exchange": "person.ex", "queue": "person.q" },
  { "exchange": "person.dead.ex", "queue": "person.manual-reprocess.q" }
]
```


*person/broker/config.js*

```
'use strict'

import exchanges from './exchanges.json'
import queues from './queues.json'
import bindings from './bindings.json'
import handler from 'app/v1/person/handler'

const consumers = [
  {
    type: '*',
    name: 'person.q',
    handler: handler
  }
]

export default { exchanges, queues, bindings, consumers }
```


*channel.js*

```
'use strict'

import amqplibSetup from 'amqplib-setup'
import * as amqp from 'amqp-connection-manager'
import personConfig from 'app/v1/person/broker/config'

const opts = {
 heartbeatIntervalInSeconds: 30,
 reconnectTimeInSeconds: 1
}
const rabbit = amqp.connect([process.env.RABBITMQ_URL], opts)

const setup = async(channel) => {

  channel.prefetch(parseInt(process.env.RABBITMQ_PREFETCH))

  try {
    await amqplibSetup(channel, personConfig)
    logger.info('Broker was started successfully')
  } catch (err) {
    logger.error('Failed to start broker', err)
  }
}

export default rabbit.createChannel({ json: true, setup })
```

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