README
amqplib-wrapper
Wrapper around amqplib that automatically reconnects and creates channels.
Install
npm install @artie-owlet/amqplib-wrapper
Usage
import { ConnectionWrapper } from '@artie-owlet/amqplib-wrapper';
// create connection wrapper
const connWrap = new ConnectionWrapper({
reconnectTimeout: 1000,
});
// create channel wrapper
const chanWrap = connWrap.createChannelWrapper();
// get amqplib Channel and immediately use it
const chan = await chanWrap.getChannel();
chan.publish('my-ex', 'rk', Buffer.from('hello'));
// handle "open" event to start/resume consuming
chanWrap.on('open', async (chan) => {
await chan.assertQueue('my-queue');
chan.consume('my-queue', (msg) => {
// ...
});
});
API
See artie-owlet.github.io/amqplib-wrapper