egg-rmq
egg plugin for RabbitMQ
Install
$ npm i egg-rmq --save
Usage
// {app_root}/config/plugin.jsexportsrmq = enable: true package: 'egg-rmq';
Configuration
Single Server
// {app_root}/config/config.default.jsexportsrmq = host: 'amqp://localhost';
Multiple Server
// {app_root}/config/config.default.jsexportsrmq = servers: test: host: 'amqp://localhost' ;
// {app_root}/config/config.default.js// If not set name then this config like Single Server, use app.rmq.connexportsrmq = servers: host: 'amqp://localhost' name: 'test' host: 'amqp://localhost2' ;
Route queue
use rmq.route to set Single Server channel
use rmq[server name].route to set Multiple Server channel
// {app_root}/router.jsmodule { const router controller rmq = app; rmq; // hello is queue};
Controller
use ctx.req.ch to get Channel
use ctx.req.queue to get Queue
use app.rmq.conn to get Single Server connect
use app.rmq[server name].conn to get Multiple Server connect
// {app_root}/rmq/controller/hello.jsmodule { return Controller async { const ctx = this; await ctxreqch; ctxreqch; ctxreqch; } ;};
see config/config.default.js for more detail.
Questions & Suggestions
Please open an issue here.