npm package: @runnerty/executor-amqp
Description: Runnerty module: AMQP Publisher
Author: Runnerty Tech
Latest version: 3.1.0

<p align="center">
  <a href="http://runnerty.io">
    <img height="257" src="https://runnerty.io/assets/header/logo-stroked.png">
  </a>
  <p align="center">Smart Processes Management</p>
</p>

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Dependency Status][david-badge]][david-badge-url]
<a href="#badge">
<img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg">
</a>

# Executor for [Runnerty]: AMQP

Module AMQP (Advanced Message Queuing Protocol) 0-9-1 Publisher.
This is a wrapper from the [amqplib](https://github.com/squaremo/amqp.node)

### Installation:

```bash
npm i @runnerty/executor-amqp
```

### Configuration:

Add in [config.json]:

##### Simple:

```json
{
  "id": "amqp_default",
  "type": "@runnerty-executor-amqp",
  "hostname": "localhost"
}
```

##### All parameters:

```json
{
  "id": "amqp_default",
  "type": "@runnerty-executor-amqp",
  "protocol": "amqp",
  "hostname": "localhost",
  "port": 5672,
  "username": "guest",
  "password": "guest",
  "locale": "en_US",
  "frameMax": 1000,
  "heartbeat": 0,
  "vhost": "/",
  "options": {
    "expiration": 10000,
    "userId": "myUserId",
    "CC": "myCC",
    "BCC": ["bcc1,bcc2"],
    "mandatory": false,
    "persistent": true,
    "deliveryMode": true,
    "contentType": "myContentType",
    "contentEncoding": "myContentEncoding",
    "headers": { "header": "value" },
    "priority": 9,
    "correlationId": "myCorrelationId",
    "replyTo": "myReplyTo",
    "messageId": "myMessageId",
    "timestamp": 999999999,
    "type": "myType",
    "appId": "myAppId"
  }
}
```

### Plan sample:

Add in [plan.json]:

##### Exange:

```json
{
  "id": "amqp_default",
  "exange": "MY_EXANGE",
  "exangeType": "direct",
  "routingKey": "runnerty.test.#",
  "message": "My message from Runnerty!",
  "options": {
    "persistent": true
  }
}
```

##### Or direct to Queue:

```json
{
  "id": "amqp_default",
  "queue": "MY_QUEUE",
  "message": "My message from Runnerty!",
  "options": {
    "priority": 10
  }
}
```

### Connection parameters

| Option    | Type   | Description                                                           |
| :-------- | :----- | :-------------------------------------------------------------------- |
| protocol  | string | The to be used protocol: "amqp" or "amqps". Default value: 'amqp'.    |
| hostname  | string | Hostname. Default value: 'localhost'                                  |
| port      | string | Port. Default value: 5672                                             |
| username  | string | Username. Default value: 'guest'                                      |
| password  | string | Password. Default value: 'guest'                                      |
| locale    | string | Password. Default value: 'en_US'                                      |
| frameMax  | number | The size in bytes of the maximum frame allowed. Default value: 0x1000 |
| heartbeat | number | The period of the connection heartbeat in seconds. Default value: 0   |
| vhost     | string | What VHost shall be used. Default value: '/'                          |

### Message options

##### Can be set in `config` as default or in the process. The value indicated in the process overwrites the one indicated in `config`.

| Option          | Type               |
| :-------------- | :----------------- |
| expiration      | string/number      |
| userId          | string             |
| CC              | string/string[]    |
| BCC             | string/string[]    |
| mandatory       | boolean            |
| persistent      | boolean            |
| deliveryMode    | boolean/number     |
| contentType     | string             |
| contentEncoding | string             |
| headers         | object (key:value) |
| priority        | number             |
| correlationId   | string             |
| replyTo         | string             |
| messageId       | string             |
| timestamp       | number             |
| type            | string             |
| appId           | string             |

More information in amqp-lib [api reference](http://squaremo.github.com/amqp.node/channel_api.html)

### Output (Process values):

- `PROCESS_EXEC_MSG_OUTPUT`: Log operations message.
- `PROCESS_EXEC_ERR_OUTPUT`: Error output message.

[runnerty]: http://www.runnerty.io
[downloads-image]: https://img.shields.io/npm/dm/@runnerty/executor-amqp.svg
[npm-url]: https://www.npmjs.com/package/@runnerty/executor-amqp
[npm-image]: https://img.shields.io/npm/v/@runnerty/executor-amqp.svg
[david-badge]: https://david-dm.org/runnerty/executor-amqp.svg
[david-badge-url]: https://david-dm.org/runnerty/executor-amqp
[config.json]: http://docs.runnerty.io/config/
[plan.json]: http://docs.runnerty.io/plan/