rmq-wrapper
Version:
199 lines (162 loc) • 5.05 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><p><a name="module_rmq-wrapper"></a></p>
<h2>rmq-wrapper</h2>
<p>Utility functions for connecting, producing and consuming messages on RMQ</p>
<ul>
<li><a href="#module_rmq-wrapper">rmq-wrapper</a>
<ul>
<li><a href="#module_rmq-wrapper..consume">~consume</a> ⇒ <code>Promise</code>
<ul>
<li><a href="#module_rmq-wrapper..consume.ack">.ack(data)</a> ⇒ <code>boolean</code></li>
</ul>
</li>
<li><a href="#module_rmq-wrapper..produce">~produce(queue, message, [persistent])</a> ⇒ <code>Promise</code></li>
<li><a href="#module_rmq-wrapper..cancel">~cancel(queue)</a> ⇒ <code>Promise</code></li>
</ul>
</li>
</ul>
<p><a name="module_rmq-wrapper..consume"></a></p>
<h3>rmq-wrapper~consume ⇒ <code>Promise</code></h3>
<p>This method connects to a queue and calls the provided callback consumeFunction when a message is received on the queue</p>
<p><strong>Kind</strong>: inner constant of <a href="#module_rmq-wrapper"><code>rmq-wrapper</code></a><br>
<strong>Returns</strong>: <code>Promise</code> - Resolved when the connection completes<br>
<strong>Throws</strong>:</p>
<ul>
<li><code>exception</code></li>
</ul>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>queue</td>
<td><code>string</code></td>
<td>name of the queue to listen on</td>
</tr>
<tr>
<td>consumeFunction</td>
<td><code>string</code></td>
<td>function to call when a message is received on the queue</td>
</tr>
</tbody>
</table>
<p><a name="module_rmq-wrapper..consume.ack"></a></p>
<h4>consume.ack(data) ⇒ <code>boolean</code></h4>
<p>This method should be called to acknolwedge a received message otherwise the message will be re-queued</p>
<p><strong>Kind</strong>: static method of <a href="#module_rmq-wrapper..consume"><code>consume</code></a><br>
<strong>Returns</strong>: <code>boolean</code> - true or false indicating success or failure</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td>
<td><code>object</code></td>
<td>the object from the original received message that should be acked</td>
</tr>
</tbody>
</table>
<p><a name="module_rmq-wrapper..produce"></a></p>
<h3>rmq-wrapper~produce(queue, message, [persistent]) ⇒ <code>Promise</code></h3>
<p>This produces a message on RMQ, assumes that the connect() method was previously called</p>
<p><strong>Kind</strong>: inner method of <a href="#module_rmq-wrapper"><code>rmq-wrapper</code></a><br>
<strong>Returns</strong>: <code>Promise</code> - Resolved when the message was produced on the queue<br>
<strong>Throws</strong>:</p>
<ul>
<li><code>exception</code></li>
</ul>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>queue</td>
<td><code>string</code></td>
<td></td>
<td>name of the queue to listen on</td>
</tr>
<tr>
<td>message</td>
<td><code>string</code></td>
<td></td>
<td>stringified text to be put on the queue</td>
</tr>
<tr>
<td>[persistent]</td>
<td><code>boolean</code></td>
<td><code>"true"</code></td>
<td>if true the message is stored peristently on the queue</td>
</tr>
</tbody>
</table>
<p><a name="module_rmq-wrapper..cancel"></a></p>
<h3>rmq-wrapper~cancel(queue) ⇒ <code>Promise</code></h3>
<p>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.</p>
<p><strong>Kind</strong>: inner method of <a href="#module_rmq-wrapper"><code>rmq-wrapper</code></a><br>
<strong>Returns</strong>: <code>Promise</code> - Resolved when the queue was cancelled<br>
<strong>Throws</strong>:</p>
<ul>
<li><code>exception</code></li>
</ul>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>queue</td>
<td><code>string</code></td>
<td>name of the queue to listen on</td>
</tr>
</tbody>
</table></article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#connect">connect</a></li><li><a href="global.html#Exchange">Exchange</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Wed Feb 26 2020 12:31:33 GMT+0000 (Greenwich Mean Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>