# rmq-wrapper

> RMQ wrapper

Latest version **0.0.7** (published 2020-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install rmq-wrapper
pnpm add rmq-wrapper
yarn add rmq-wrapper
bun add rmq-wrapper
```

## 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.7 |
| Published | 2020-02-26 |
| First published | 2019-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chris Horn |
| Maintainers | onem-developer |
| Keywords | RabbitMq, RMQ, ONEm |

## Links

- npm: https://www.npmjs.com/package/rmq-wrapper
- Repository: https://github.com/chrishornmem/rmq-wrapper
- Homepage: https://github.com/chrishornmem/rmq-wrapper#readme
- Issues: https://github.com/chrishornmem/rmq-wrapper/issues
- npm.io page: https://npm.io/package/rmq-wrapper

## Dependencies (4)

- [uuidv4](https://npm.io/package/uuidv4.md) ^6.0.2
- [amqplib](https://npm.io/package/amqplib.md) ^0.5.3
- [debug-level](https://npm.io/package/debug-level.md) ^0.3.0
- [amqp-connection-manager](https://npm.io/package/amqp-connection-manager.md) ^2.3.2

## Recent versions

- 0.0.7 (latest) — 2020-02-26
- 0.0.6 — 2019-11-18
- 0.0.5 — 2019-10-16

## README

## Functions

<dl>
<dt><a href="#connect">connect([host])</a></dt>
<dd></dd>
<dt><a href="#Exchange">Exchange(name, [type], [options])</a></dt>
<dd></dd>
</dl>

<a name="connect"></a>

## connect([host])
**Kind**: global function  

| Param | Type | Description |
| --- | --- | --- |
| [host] | <code>string</code> | default is process.env.RMQ_HOST || 'amqp://rabbitmq:5672' |

<a name="Exchange"></a>

## Exchange(name, [type], [options])
**Kind**: global function  

| Param | Type | Description |
| --- | --- | --- |
| name | <code>string</code> | Name of the exchange |
| [type] | <code>string</code> | 'direct', 'fanout' etc, default is 'direct' |
| [options] | <code>object</code> | amqp channel.assertExchange options object |


* [Exchange(name, [type], [options])](#Exchange)
    * [.subscribe(queue, consumeHandler, [routingKey], [prefetch], [messageTtl])](#Exchange+subscribe)
    * [.ack(message)](#Exchange+ack)
    * [.publish(routingKey, message, [options])](#Exchange+publish)
    * [.sendRPCMessage(queue, message, [timeout])](#Exchange+sendRPCMessage)
    * [.replyToRPC(message, reply)](#Exchange+replyToRPC)

<a name="Exchange+subscribe"></a>

### exchange.subscribe(queue, consumeHandler, [routingKey], [prefetch], [messageTtl])
**Kind**: instance method of [<code>Exchange</code>](#Exchange)  

| Param | Type | Description |
| --- | --- | --- |
| queue | <code>string</code> | name of queue |
| consumeHandler | <code>function</code> | handler function to call when message arrives on queue |
| [routingKey] | <code>string</code> | optional routing key, defaults to queue name |
| [prefetch] | <code>number</code> | optional number of messages to prefetch, default is 1 |
| [messageTtl] | <code>number</code> | optional time to live for messages on the queue, default is process.env.RMQ_MESSAGE_TTL || 10000 |

<a name="Exchange+ack"></a>

### exchange.ack(message)
**Kind**: instance method of [<code>Exchange</code>](#Exchange)  

| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | message to ack |

<a name="Exchange+publish"></a>

### exchange.publish(routingKey, message, [options])
**Kind**: instance method of [<code>Exchange</code>](#Exchange)  

| Param | Type | Description |
| --- | --- | --- |
| routingKey | <code>string</code> | optional routing key, defaults to queue name |
| message | <code>object</code> | message to send (JSON object) |
| [options] | <code>object</code> | amqplib options object for publish method |

<a name="Exchange+sendRPCMessage"></a>

### exchange.sendRPCMessage(queue, message, [timeout])
**Kind**: instance method of [<code>Exchange</code>](#Exchange)  

| Param | Type | Description |
| --- | --- | --- |
| queue | <code>string</code> | name of queue |
| message | <code>object</code> | message to send (JSON object) |
| [timeout] | <code>number</code> | time to wait for response in ms, default is process.env.RMQ_RPC_TIMEOUT || 10000 |

<a name="Exchange+replyToRPC"></a>

### exchange.replyToRPC(message, reply)
**Kind**: instance method of [<code>Exchange</code>](#Exchange)  

| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | the original message to reply to |
| reply | <code>object</code> | JSON content of the reply messsage |

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