0.1.4 • Published 4 years ago
@apihawk/microcell-amqp-transport v0.1.4
microcell-amqp-transport
An AMQP transport for MicroCell.
Install
npm install @apihawk/microcell-amqp-transportUsage
const MicroCell = require('@apihawk/microcell');
const MicroCellAMQPTransport = require('@apihawk/microcell-amqp-transport');
const server = new (MicroCell.plugin(MicroCellAMQPTransport))();
server
.listen({
amqp_queue: process.ENV.AMQP_QUEUE,
amqp_url: process.ENV.AMQP_URL
})
.add({foo: 'One', bar: 'Two'}, (data, respond) => {
respond(null, `Payload is: ${data.payload}`);
})
.act({foo: 'One', bar: 'Two', payload: 'Hello World'}, () => {
console.log("Final response:", response); // Final response: Payload is: Hello World
});Methods
Implements or extends all methods available in MicroCell.
listen(params)
The listen method starts a server that listens for JSON messages depending on the transport plugin. If you do not use a plugin, the function exits. Accepts params object which passes parameters for the used transport plugin.
Parameters:
amqp_queue- The name of the queue to be used for the transport. Required. Example:AppCell[OnAppDNS].amqp_url- A standard amqp url. Required. Example:amqp://user:pass@host:5672/
client(params)
On the client-side, calling microcell.client() means that MicroCell sends any actions it cannot match locally out over the selected transport.
Accepts same parameters as listen().
License
Copyright (c) 2019 Anton Katsarov and other contributors; Licensed under MIT.