0.2.0 • Published 4 years ago
egg-mq-http-sdk v0.2.0
egg-mq-http-sdk
Install
$ npm i egg-mq-http-sdk --save
Usage
// {app_root}/config/plugin.js
exports.mqHttpSdk = {
enable: true,
package: 'egg-mq-http-sdk',
};
Configuration
// {app_root}/config/config.default.js
exports.mqHttpSdk = {
endpoint: '',
accessKeyId: '',
accessKeySecret: '',
securityToken?: '',
producers?: [{
instanceId: '',
topic: '',
groupId?: '',
}],
consumers?: [{
instanceId: '',
topic: '',
groupId?: '',
messageTags?: [''],
}],
pollingInterval?: 3000, // 轮询间隔 ms 默认为0
};
Example
import { MQClient, createMessageProperties, ConsumeMessageResponse } from 'egg-mq-http-sdk';
const client: MQClient = (this.app as any).mqClient;
const producer = client.getProducer(instanceId, topic);
const msgProps = createMessageProperties();
msgProps.messageKey(message_key);
await producer.publishMessage(body, tag, msgProps);
const transProducer = client.getTransProducer(instanceId, topic, groupId);
app.ts:
import { consume, transProduce } from 'egg-mq-http-sdk';
app.beforeStart(async () => {
consume(app, 'messageTag', async (ctx, consumer, message) => {
// 注册消费消息方法
});
transProduce(app, 'messageTag', async (ctx, transProducer, message) => {
// 注册回查半消息方法
})
});
Questions & Suggestions
Please open an issue here.
License
0.2.0
4 years ago
0.1.9
4 years ago
0.1.8
4 years ago
0.1.7
4 years ago
0.1.6
4 years ago
0.1.5
4 years ago
0.1.4
4 years ago
0.1.0
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.0.9
4 years ago
0.0.8
4 years ago
0.1.3
4 years ago
0.0.7
4 years ago
0.0.6
4 years ago
0.0.5
4 years ago
0.0.4
4 years ago
0.0.3
4 years ago
0.0.2
4 years ago
0.0.1
4 years ago