tombailey / bugs-q

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bugs-q

A RabbitMQ JavaScript client library. Because amqplib didn't look particularly appealing out of the box.

Installation

npm install --save bugs-q

Usage

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.

License

Apache License Version 2.0

About

License:Apache License 2.0


Languages

Language:JavaScript 100.0%