# hinos-rabbitmq

> Module help to connect to rabbitMQ for hinos

Latest version **2.0.14** (published 2017-12-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install hinos-rabbitmq
pnpm add hinos-rabbitmq
yarn add hinos-rabbitmq
bun add hinos-rabbitmq
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.14 |
| Published | 2017-12-22 |
| First published | 2017-05-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | doanthuanthanh88@gmail.com |
| Maintainers | doanthuanthanh88 |

## Links

- npm: https://www.npmjs.com/package/hinos-rabbitmq
- npm.io page: https://npm.io/package/hinos-rabbitmq

## Dependencies (2)

- [amqplib](https://npm.io/package/amqplib.md) ^0.5.1
- [hinos-common](https://npm.io/package/hinos-common.md) ^2.0.7

## Recent versions

- 2.0.14 (latest) — 2017-12-22
- 2.0.13 — 2017-12-22
- 2.0.12 — 2017-12-22
- 2.0.11 — 2017-12-22
- 2.0.10 — 2017-12-22
- 2.0.9 — 2017-12-22
- 2.0.8 — 2017-12-21
- 2.0.7 — 2017-12-21
- 2.0.6 — 2017-11-16
- 2.0.5 — 2017-10-05
- 2.0.4 — 2017-09-14
- 2.0.3 — 2017-09-12
- 2.0.2 — 2017-09-12
- 2.0.1 — 2017-08-24
- 2.0.0 — 2017-08-24
- … 6 more at https://npm.io/package/hinos-rabbitmq/versions

## README

# hinos-rabbitmq
A plugin helps to manage rabbitmq connection for [hinos](https://github.com/doanthuanthanh88/hinos)

# Install
```nodejs
npm i hinos-rabbitmq -S
```

# Examples

### Typescript
Config mongo information
```nodejs
import { RabbitMQ } from 'hinos-rabbitmq';

RabbitMQ({
  url: 'amqp://127.0.0.1',
  releaseTimeout: 60000,
  queue: {
    'API_RECEIVER': {
      des: 'Listen queue message for API',
      getListenerName: (_data: any) => `${AppConfig.mqtt.queue.API_RECEIVER}`,
      getError: (data: any) => !data.error ? null : data.error || 'Unknown'
    }
  }
}).debug(!Server.isProduction)
RabbitMQ({
    key: 'connection1',
    url: 'amqp://192.168.0.56',
    queue: {
      'LOG_RECEIVER': {
        des: 'Listen queue message for Log realtime',
        getListenerName: (_data: any) => `${AppConfig.mqtt.queue.LOG_RECEIVER}`,
        getError: (data: any) => !data.error ? null : data.error || 'Unknown'
      }
    }
})
```
Use in service file
```nodejs
import { RABBITMQ, RabbitMQ, RabbitListener } from 'hinos-rabbitmq'

@RabbitListener({
  des: 'Test rabbitmq',
  queue: 'LOG_RECEIVER',
  listenerName: AppConfig.mqtt.queue.API_RECEIVER,
  onHandler(err, data) {
    console.log(err, data)
  }
})
export class ChartService {
  @RABBITMQ()
  private static rabbitMQ: RabbitMQ

  @MQTT('connection1')
  static rabbitMQ1: RabbitMQ;
  
  static async sendToRabbit(data: any = {}) {
      ChartService.rabbitMQ.send('queueName', data);
  }
}
```

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