egg-rabbitmq
amqplib plugin for Egg.js
NOTE: This plugin just for integrate amqplib into Egg.js, more documentation please visit http://www.squaremobius.net/amqp.node/.
Install
$ npm i egg-amqplib-plus --save
Configuration
exports.rabbitmq = {
enable: true,
package: 'egg-amqplib-plus',
};
see config/config.default.js for more detail.
Simple instance
exports.rabbitmq = {
client: {
url: 'amqp://guest:guest@localhost:5672',
},
app: true,
agent: false,
};
Usage:
(async () => {
const ch = app.rabbitmq;
await ch.assertQueue(queueName, { durable: true });
await ch.checkQueue(queueName);
ch.sendToQueue(queueName, Buffer.from(msg));
}).catch(console.error);
Multiple instance
exports.rabbitmq = {
clients: {
client1: {
url: 'amqp://guest:guest@localhost:5672',
},
client2: {
url: 'amqp://guest:guest@xxx',
},
},
app: true,
agent: false,
};
Usage:
const ch1 = app.rabbitmq.get('client1');
const ch2 = app.rabbitmq.get('client2');
Questions & Suggestions
Please open an issue here.
License
MIT