egg-amqplib
Amqp plugin for egg with amqplib
Install
$ npm i egg-amqplib --save
Usage
// {app_root}/config/plugin.jsexportsamqplib = enable: true package: 'egg-amqplib';
Configuration
// {app_root}/config/config.default.jsexportsamqplib = client: // url: 'amqp://localhost', connectOptions: protocol: 'amqp' hostname: 'localhost' port: 5672 username: 'guest' password: 'guest' locale: 'en_US' frameMax: 0 heartbeat: 0 vhost: '/' // socketOptions: { // cert: certificateAsBuffer, // client cert // key: privateKeyAsBuffer, // client key // passphrase: 'MySecretPassword', // passphrase for key // ca: [caCertAsBuffer], // array of trusted CA certs // }, ;
see config/config.default.js for more detail.
Example
const queueName = 'test'; // Publisherconst msg = 'test';const ch = await thisappamqplib;await ch;const ok = await ch; // Consumerawait ch;const msg = await ch; if msg !== null ch; await ch;
Questions & Suggestions
Please open an issue here.