1.3.7 • Published 2 months ago

egg-rocketmq-http v1.3.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

egg-rocketmq-http

provides egg bindings for the ali rocketMQ.

npm download NPM version GitHub issues GitHub

Install

$ npm i egg-rocketmq-http --save

Usage

// {app_root}/config/plugin.ts
export const rocketMQ = {
  enable: true,
  package: 'egg-rocketmq-http',
}

// {app_root}/config/config.default.ts
export const rocketMQ = {
    ...
    consumers: [
      {
        consumer: 'cons',
        tags: string[ 'tagA' ]
      },
    ] ,
};

// Producer
this.app.mq.publish(body, 'tagA');

// Consumer
// {app_root}/app/mq/cons.ts
import { Consumer, Message } from 'egg-rocketmq-http';
export default class Cons extends Consumer {
  private name = 'cons';
  async tagA(message: Message) {
    console.log('cons\'s tagA action: %s', message.MessageBody);
    this.app.mq.ack(this.name, [ message.ReceiptHandle ]);
  }
}

see lib/discovery/controller.ts for more detail.

Configuration

// {app_root}/config/config.default.ts
exports.rocketMQ = {
    log: true, // it will log in the path /logs/mq.log
    endpoint: '',
    accessKeyId: '',
    accessKeySecret: '',
    securityToken: null,
    instanceId: '',
    topic: '',
    consumers: {
      xxxxx: {
        tags: string[ 'test' ], // tags the app watched
        numOfMessages?: 3,
        waitSeconds?: 30,
        send?: 'random', // default, send to a random app, or you can set to 'all'
        sure?: false, // must be success, it will send ack automatically
        consumeWait?: 30000 // maximum waiting time for consumption, default: 30000(ms)
      },
    } ,
};

see config/config.default.ts for more detail.

Questions & Suggestions

Please open an issue here.

License

MIT

1.3.7

2 months ago

1.3.6

2 months ago

1.3.5

5 months ago

1.3.4

9 months ago

1.2.6

10 months ago

1.3.2

10 months ago

1.3.1

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.1

11 months ago

1.1.0

11 months ago