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
// {app_root}/config/plugin.jsexportsrabbitmq = enable: true package: 'egg-amqplib-plus';
see config/config.default.js for more detail.
Simple instance
// {app_root}/config/config.default.jsexportsrabbitmq = client: url: 'amqp://guest:guest@localhost:5672' // load into app, default is open app: true // load into agent, default is close agent: false;
Usage:
async { // you can access to simple rabbitmq instance channel using app.rabbitmq. const ch = apprabbitmq; // Channel // assertQueue await ch; // checkQueue await ch; // sendToQueue ch;};
Multiple instance
exportsrabbitmq = clients: // clientId, access the client instance by app.rabbitmq.get('clientId') client1: url: 'amqp://guest:guest@localhost:5672' client2: url: 'amqp://guest:guest@xxx' // ... // load into app, default is open app: true // load into agent, default is close agent: false;
Usage:
const ch1 = apprabbitmq; const ch2 = apprabbitmq;
Questions & Suggestions
Please open an issue here.