npm package: @north-tec/nt-amqp
Description: A personal wrapper for the amqp lib
Author: Shinagzu
Latest version: 1.0.15

[![npm version](https://img.shields.io/npm/v/@north-tec/nt-amqp.svg?style=flat-square)](https://www.npmjs.com/package/@north-tec/nt-amqp)
[![npm downloads](https://img.shields.io/npm/dm/@north-tec/nt-amqp.svg?style=flat-square)](https://npm-stat.com/charts.html?package=@north-tec/nt-amqp)
[![install size](https://packagephobia.now.sh/badge?p=@north-tec/nt-amqp)](https://packagephobia.now.sh/result?p=@north-tec/nt-amqp)

## Installing

Using npm:

    $ npm install @north-tec/nt-amqp

## Example

```javascript
const Amqp = require('@north-tec/nt-amqp');
const amqpClient = new Amqp();

const connection = {
    "protocol": "amqps",
    "hostname": "broker.address.net",
    "port": 5671,
    "locale": "de_DE",
    "frameMax": 0,
    "heartbeat": 10,
    "username": "dummy",
    "password": "password",
    "vhost": "/dummy"
}

(async () => {
    amqpClient.on('reconnect', () => { process.exit(0) });
    await amqpClient.connect(connection), {}, 100);
    const receiver = amqpClient.Receiver;

    receiver.consume('dummy-queue');

    receiver.on('message', message => {
        console.log(message.content.toString());
    });
})()
```

## Classes

<dl>
<dt><a href="#Receiver">Receiver</a> ⇐ <code>events</code></dt>
<dd><p>Create a new instance of Receiver</p></dd>
<dt><a href="#Transmitter">Transmitter</a> ⇐ <code>events</code></dt>
<dd><p>Create a new instance of Transmitter</p></dd>
<dt><a href="#Amqp">Amqp</a> ⇐ <code>events</code></dt>
<dd><p>Create a new instance of Amqp</p></dd>
</dl>

<a name="Receiver"></a>

## Receiver ⇐ <code>events</code>
<p>Create a new instance of Receiver</p>

**Kind**: global class  
**Extends**: <code>events</code>  

* [Receiver](#Receiver) ⇐ <code>events</code>
    * [.consume(queue, consumeOpt, queueAssertOpt, exchange, excangeType, exchangeAssertOpt, routingKey, requeue)](#Receiver+consume)
    * [.ack(msg)](#Receiver+ack)
    * [.nack(msg, [requeue])](#Receiver+nack)

<a name="Receiver+consume"></a>

### receiver.consume(queue, consumeOpt, queueAssertOpt, exchange, excangeType, exchangeAssertOpt, routingKey, requeue)
<p>[consume description]</p>

**Kind**: instance method of [<code>Receiver</code>](#Receiver)  
**Emits**: <code>Receiver#event:message</code>, <code>Receiver#event:error</code>  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| queue | <code>String</code> |  | <p>The name of the queue</p> |
| consumeOpt | <code>Object</code> | <code>{noAck:false}</code> | <p>[description]</p> |
| queueAssertOpt | <code>Object</code> | <code>{}</code> | <p>[description]</p> |
| exchange | <code>String</code> | <code></code> | <p>[description]</p> |
| excangeType | <code>String</code> | <code>&quot;topic&quot;</code> | <p>[description]</p> |
| exchangeAssertOpt | <code>Object</code> | <code>{}</code> | <p>[description]</p> |
| routingKey | <code>String</code> | <code></code> | <p>[description]</p> |
| requeue | <code>Boolean</code> | <code>false</code> | <p>[description]</p> |

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

### receiver.ack(msg)
<p>Acknowledge a message</p>

**Kind**: instance method of [<code>Receiver</code>](#Receiver)  

| Param | Type | Description |
| --- | --- | --- |
| msg | <code>ConsumeMessage</code> | <p>[description]</p> |

<a name="Receiver+nack"></a>

### receiver.nack(msg, [requeue])
<p>Not acknowledge a message</p>

**Kind**: instance method of [<code>Receiver</code>](#Receiver)  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| msg | <code>ConsumeMessage</code> |  | <p>[description]</p> |
| [requeue] | <code>Boolean</code> | <code>false</code> | <p>If true the message get requeued</p> |

<a name="Transmitter"></a>

## Transmitter ⇐ <code>events</code>
<p>Create a new instance of Transmitter</p>

**Kind**: global class  
**Extends**: <code>events</code>  
**Emits**: <code>Transmitter#event:send</code>, <code>Transmitter#event:error</code>  

* [Transmitter](#Transmitter) ⇐ <code>events</code>
    * [.waitForConfirms()](#Transmitter+waitForConfirms) ⇒ <code>Promise.&lt;void&gt;</code>
    * [.send(queue, msg, [options])](#Transmitter+send)
    * [.publish(exchange, routingKey, msg, [options])](#Transmitter+publish)

<a name="Transmitter+waitForConfirms"></a>

### transmitter.waitForConfirms() ⇒ <code>Promise.&lt;void&gt;</code>
**Kind**: instance method of [<code>Transmitter</code>](#Transmitter)  
**Returns**: <code>Promise.&lt;void&gt;</code> - <p>[description]</p>  
<a name="Transmitter+send"></a>

### transmitter.send(queue, msg, [options])
<p>Send a message direct to queue</p>

**Kind**: instance method of [<code>Transmitter</code>](#Transmitter)  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| queue | <code>String</code> |  | <p>Queue name</p> |
| msg | <code>String</code> \| <code>Object</code> |  | <p>Message</p> |
| [options] | <code>Object</code> | <code>{}</code> | <p>Send options</p> |

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

### transmitter.publish(exchange, routingKey, msg, [options])
<p>Publish a message to exchange</p>

**Kind**: instance method of [<code>Transmitter</code>](#Transmitter)  

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| exchange | <code>String</code> |  | <p>Exchange name</p> |
| routingKey | <code>String</code> |  | <p>Routing key</p> |
| msg | <code>String</code> \| <code>Object</code> |  | <p>Message</p> |
| [options] | <code>Object</code> | <code>{}</code> | <p>Publish options</p> |

<a name="Amqp"></a>

## Amqp ⇐ <code>events</code>
<p>Create a new instance of Amqp</p>

**Kind**: global class  
**Extends**: <code>events</code>  

## Resources

-   [Changelog](https://github.com/Macomm/nt-amqp/blob/master/CHANGELOG.md)

## License

-   [MIT](https://github.com/Macomm/nt-amqp/blob/master/LICENSE)