iamqp
Version:
RabbitMQ wrapper for NodeJS with several produce(reply)/consume scenarios
536 lines (200 loc) • 12.9 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>RpcClient - Documentation</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="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Common.html">Common</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_commonPublishPreparations">_commonPublishPreparations</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_emitAndDispatchError">_emitAndDispatchError</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_logData">_logData</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_messageDispatcherWrapper">_messageDispatcherWrapper</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_parseConsumedMessage">_parseConsumedMessage</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#_preparePublishingMessage">_preparePublishingMessage</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#closeConnection">closeConnection</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#getEventer">getEventer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#isReady">isReady</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#openConnection">openConnection</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Common.html#toString">toString</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="ConsoleLogger.html">ConsoleLogger</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#error">error</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#info">info</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#log">log</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="ConsoleLogger.html#warn">warn</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="FanoutConsumer.html">FanoutConsumer</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="FanoutProducer.html">FanoutProducer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="FanoutProducer.html#fanout">fanout</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="PlainConsumer.html">PlainConsumer</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="PlainProducer.html">PlainProducer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="PlainProducer.html#publish">publish</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="RpcClient.html">RpcClient</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="RpcClient.html#callRemote">callRemote</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="RpcServer.html">RpcServer</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="RpcServer.html#respond">respond</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="UUIDv4.html">UUIDv4</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="UUIDv4.html#generate">generate</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li>
</nav>
<div id="main">
<h1 class="page-title">RpcClient</h1>
<section>
<header>
<h2>
RpcClient
</h2>
<div class="class-description"><p>RPC client. Init example:</p>
<pre>
const iamqp = require('iamqp');
const amqpUri = 'amqp://localhost';
const rpcChannel = 'rpc-channel-a';
let rpcClient = new iamqp.RPCClient(amqpUri, rpcChannel);
// This needs to be done or the errors will bubble up.
rpcClient.getEventer().on('error', (err) => {
console.log('RPC client error:' + err.message);
});
// For when the connection is established.
rpcClient.getEventer().on('connected', () => {
console.log('RPC client connected');
});
rpcClient.getEventer().on('reply', (reply, correlationId) => {
console.log('RPC client got a reply (' + correlationId + '): ' + reply);
});
// Open the connection - this takes some time and is not sync
rpcClient.openConnection();
// ...
// Call the RPC server with some data.
// The correlation ID strings are to be used to distinguish replies to answers.
let correlationIdA = rpcClient.callRemote({'a': 5});
let correlationIdB = rpcClient.callRemote({'b': 5});
if (correlationIdA === false) {
console.log('call not performed on A');
} else {
console.log('correlationID on A: ' + correlationIdA);
}
if (correlationIdB === false) {
console.log('call not performed on B');
} else {
console.log('correlationID on B: ' + correlationIdB);
}
// ...
// Close the connection
if (rpcClient.closeConnection()) {
console.log('RPC client connection closing ...');
}
</pre>
<p>...</p></div>
</header>
<article>
<div class="container-overview">
<div class="section-method">
<h2>Constructor</h2>
<h4 class="name" id="RpcClient"><span class="type-signature"></span>new RpcClient<span class="signature">(amqpUri, channelName, configuration<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="rpc_rpc_client.js.html">rpc/rpc_client.js</a>, <a href="rpc_rpc_client.js.html#line64">line 64</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>amqpUri</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#AmqpURI">AmqpURI</a></code></span>
</td>
<td class="attributes">
</td>
<td class="description last">
</td>
</tr>
<tr>
<td class="name"><code>channelName</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#ChannelName">ChannelName</a></code></span>
</td>
<td class="attributes">
</td>
<td class="description last">
</td>
</tr>
<tr>
<td class="name"><code>configuration</code></td>
<td class="type">
<span class="param-type"><code><a href="global.html#Configuration">Configuration</a></code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 class="subsection-title">Methods</h3>
<div class="section-method">
<h4 class="name" id="callRemote"><span class="type-signature"></span>callRemote<span class="signature">(contentToPublish)</span><span class="type-signature"> → {boolean|string}</span></h4>
<div class="description">
<p>Perform the "server" call with some data.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="rpc_rpc_client.js.html">rpc/rpc_client.js</a>, <a href="rpc_rpc_client.js.html#line83">line 83</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>contentToPublish</code></td>
<td class="type">
<span class="param-type"><code>number</code></span>
|
<span class="param-type"><code>string</code></span>
|
<span class="param-type"><code>boolean</code></span>
|
<span class="param-type"><code>Object</code></span>
|
<span class="param-type"><code>Array</code></span>
</td>
<td class="description last">
</td>
</tr>
</tbody>
</table>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code>boolean</code></span>
|
<span class="param-type"><code>string</code></span>
</dd>
</dl>
<div class="param-desc">
<p>the correlation ID of the call.
The user can use this as to distinguish between multiple answers.
If something went wrong, false will be returned.</p>
</div>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Sun Aug 04 2019 22:10:47 GMT+0200 (Central European Summer Time) using the Minami theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>