https://github.com/mapleincode/wm-rocketmq
rocketmq client use async/await
https://github.com/mapleincode/wm-rocketmq
Last synced: 3 months ago
JSON representation
rocketmq client use async/await
- Host: GitHub
- URL: https://github.com/mapleincode/wm-rocketmq
- Owner: mapleincode
- Created: 2018-04-15T20:11:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T03:34:25.000Z (about 7 years ago)
- Last Synced: 2025-03-09T00:28:03.988Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
RocketMQ Client
从某大佬的 SDK [RocketMQ](https://www.npmjs.com/package/rocketmq) 封装而来
## Install
```sh
npm install rocketmq --save
```## Usage
consumer
```javascript
const { Consumer } = require('wm-rocketmq');
const httpclient = require('urllib');const consumer = new Consumer({
namesrvAddr: '127.0.0.1:9876',
consumerGroup: 'your-consumer-group',
httpclient,
// logger,
isBroadcast: false, // default is false, that mean messages will be pushed to consumer cluster only once.
});consumer.on('mq_message', function(msg) {
// msg
});consumer.on('error', function(err) {
// error
});consumer.subscribe(config.topic, config.tags);
```producer
```javascript
const { Message, Producer } = require('wm-rocketmq');
const httpclient = require('urllib');const producer = new Producer({
namesrvAddr: '127.0.0.1:9876', // for rocket mq
httpclient,
// logger,
producerGroup: 'your-producer-group'
});const msg = new Message(config.topic, // topic
config.tags, // tag
'Hello ONS !!! ' // body
);setTimeout(async () => {
const result = await producer.send(msg);
}, 0);
```