Narcoleptic Pony Machine

    egg-mq

    0.1.0 • Public • Published

    egg-mq

    Install

    $ npm i egg-mq --save

    Usage

    // {app_root}/config/plugin.js
    exports.mq = {
      enable: true,
      package: 'egg-mq',
    };

    Configuration

    // {app_root}/config/config.default.js
    const mq = require('./mq.json');
     
    exports.mq = {
      rabbitmq: { address, port, username, password },
      ...mq
    };
    // {app_root}/config/mq.json
    {
      "producers": [
        {
          "exchange": "eggmqproducer.exchange.message",
          "exchangeType": "topic"
        }
      ],
      "consumers": [
        {
          "exchange": "eggmqproducer.exchange.message",
          "exchangeType": "topic",
          "queue": "eggmqconsumer.queue.textMessage",
          "topic": "text.*",
          "consumer": "foo.bar"
        }
      ]
    }

    Example

    // producer
    ctx.service.mq.producer('some.exchange', 'some.topic', payload);
    // ctx.service.consumer
    async consumer(topic, payload) {
      ctx.logger.info(payload);
    }

    Questions & Suggestions

    Please open an issue here.

    License

    MIT

    Install

    npm i egg-mq

    DownloadsWeekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    5.62 kB

    Total Files

    6

    Last publish

    Collaborators

    • hbrls