rmq-wrapper
Utility functions for connecting, producing and consuming messages on RMQ
- rmq-wrapper
- ~consume ⇒
Promise- .ack(data) ⇒
boolean
- .ack(data) ⇒
- ~produce(queue, message, [persistent]) ⇒
Promise - ~cancel(queue) ⇒
Promise
- ~consume ⇒
rmq-wrapper~consume ⇒ Promise
This method connects to a queue and calls the provided callback consumeFunction when a message is received on the queue
Kind: inner constant of rmq-wrapper
Returns: Promise - Resolved when the connection completes
Throws:
exception
| Param | Type | Description |
|---|---|---|
| queue | string |
name of the queue to listen on |
| consumeFunction | string |
function to call when a message is received on the queue |
consume.ack(data) ⇒ boolean
This method should be called to acknolwedge a received message otherwise the message will be re-queued
Kind: static method of consume
Returns: boolean - true or false indicating success or failure
| Param | Type | Description |
|---|---|---|
| data | object |
the object from the original received message that should be acked |
rmq-wrapper~produce(queue, message, [persistent]) ⇒ Promise
This produces a message on RMQ, assumes that the connect() method was previously called
Kind: inner method of rmq-wrapper
Returns: Promise - Resolved when the message was produced on the queue
Throws:
exception
| Param | Type | Default | Description |
|---|---|---|---|
| queue | string |
name of the queue to listen on | |
| message | string |
stringified text to be put on the queue | |
| [persistent] | boolean |
"true" |
if true the message is stored peristently on the queue |
rmq-wrapper~cancel(queue) ⇒ Promise
This tells RMQ to stop announcing new messages, so the callback consumeFunction is no longer called. The queue should be re-connected to restart message delivery.
Kind: inner method of rmq-wrapper
Returns: Promise - Resolved when the queue was cancelled
Throws:
exception
| Param | Type | Description |
|---|---|---|
| queue | string |
name of the queue to listen on |