# aob-rabbit-wrapper

> Node.js wrapper for rabbit methods

Latest version **1.0.5** (published 2018-06-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install aob-rabbit-wrapper
pnpm add aob-rabbit-wrapper
yarn add aob-rabbit-wrapper
bun add aob-rabbit-wrapper
```

## 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.5 |
| Published | 2018-06-30 |
| First published | 2018-06-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dheeraj Balodia |
| Maintainers | mohit_21 |

## Links

- npm: https://www.npmjs.com/package/aob-rabbit-wrapper
- npm.io page: https://npm.io/package/aob-rabbit-wrapper

## Dependencies (3)

- [amqp](https://npm.io/package/amqp.md) ^0.2.6
- [lodash](https://npm.io/package/lodash.md) ^4.17.10
- [aob-logger-wrapper](https://npm.io/package/aob-logger-wrapper.md) ^1.0.3

## Recent versions

- 1.0.5 (latest) — 2018-06-30
- 1.0.4 — 2018-06-30
- 1.0.3 — 2018-06-30
- 1.0.2 — 2018-06-29
- 1.0.1 — 2018-06-29

## README

***Usage***
```sh
$ import { createRabbitConnectionToPublish } from 'aob-rabbit-wrapper'
$ import { createRabbitConnectionToSubscribe } from 'aob-rabbit-wrapper'
```
This package exposes following methods
| Method | Description | Params
| ------ | ------ | ------ |
| createRabbitConnectionToPublish | Create connection and bind it with exchange provide  | {publishConnectionMap}
| createRabbitConnectionToSubscribe | Create connection for subscribing the queues binded with multiple exchanges in rabbit Mq | {publishConnectionMap}


## createRabbitConnectionToPublish ##
Give **Options** of rabbit and **event publisher list** for setting up the connection.
It will map a callback came from rabbitMq when connection established. Which is mapped in **publishConnectionMap**.
> **publishConnectionMap**
in this map you'll get the publisher callback on which you can publish messgae using the exchange name and routing key
**For example:**
- **Options**
```  
const rabbitOptions = () => ({
    host: localhost,
    port: 5672,
    login: rabbitLoginUserName,
    password: rabbitLoginUserPassword,
    connectionTimeout: 10000,
    authMechanism: 'AMQPLAIN',
    vhost: '/',
    noDelay: true,
    ssl: { enabled: false },
  });
  ```

  - **PublisherList**
  ```
   eventPublisherList: 
   [ { routingKey: rabbitRoutingKey,
       exchangeName: exchangeNameForPublishingEvent,
       exchangeType: 'topic', // direct, fanout, headers
       eventId: 1 },
     { routingKey: 'rabbitRoutingKey',
       exchangeName: 'exchangeNameForPublishingEvent',
       exchangeType: 'fanout',
       eventId: 2 } ],
  ```
  
## createRabbitConnectionToSubscribe ##
Give **subsciber list** for setting up the connection to the rabbitMQ.
Pass the function reference with the subscriber list which will receive the msg on referenced function.

**For example:**

  - **Subscriber List**
  ```
  eventSubscriberList: 
   [ { routingKey: 'rabbitRoutingKey',
       exchangeName: 'exchangeNameForSubscribing',
       queueName: 'queueName',
       exchangeType: 'topic' },
     { routingKey: 'rabbitRoutingKey',
       exchangeName: 'exchangeNameForSubscribing',
       queueName: 'queueName',
       exchangeType: 'fanout' } ] }
  ```

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