sails-hook-amqp v0.1.6
sails-hook-amqp
A wrapper of amqp.node bundled as a sails js Hook that enables you to use the AMQP protocol for sending and receiving messages.
Installation
Configuration
Create a file named amqp.js in your config directory with the following content
The socketOptions property can be omitted if not relevant.
See amqp.node@connect for details.
Usage
Publish
Publish a single message to an exchange.
sails.hooks.amqp.publish(exchange, routingKey, content, options)
The options parameter can be omitted in favour of defaults.
See amqp.node@channel_publish for details.
Examples
Send to Queue
Send a single message with the content given as a buffer, string or JSON to the specific queue named, bypassing routing. The options and return value are exactly the same as for #publish.
sails.hooks.amqp.sendToQueue(queue, content, options)
The options parameter can be omitted in favour of defaults.
See amqp.node@channel_sendToQueue for details.
Examples
Subscribe
sails.hooks.amqp.subscribe(queue || routingKey,onMessageCallback,assertQueueOpts,consumeOpts)
The assertQueueOpts & consumeOpts parameters can be omitted in favour of defaults.
See amqp.node@channel_assertQueue, amqp.node@channel_consume for details.