A RabbitMQ JavaScript client library. Because amqplib didn't look particularly appealing out of the box.
npm install --save bugs-q
Publishing
const { RabbitMQChannel } = require('bugs-q');
const publishingChannel = new RabbitMQChannel('amqp://localhost');
const queue = await publishingChannel.queue('example');
await queue.publish('hello world');
Consuming
const { RabbitMQChannel } = require('bugs-q');
const consumingChannel = new RabbitMQChannel('amqp://localhost');
const queue = await consumingChannel.queue('example');
await queue.consume(async (message) => {
console.log('got a new message', message.content.toString());
await queue.acknowledge(message);
});
Note: don't publish and consume using the same instance of a channel.
See examples for more usage scenarios.