Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ node_modules
example/.config.js
.nyc_output/
.idea
.vscode
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const consumer = new Consumer({
consumerGroup: 'your-consumer-group',
// namespace: '', // aliyun namespace support
// isBroadcast: true,
// consumeOrderly: true,
});

consumer.subscribe(config.topic, '*', async msg => {
Expand Down Expand Up @@ -76,6 +77,15 @@ const producer = new Producer({
// msg.setStartDeliverTime(Date.now() + 5000);

const sendResult = await producer.send(msg);
// order message example: send msgs with the same orderId to same queue
const orderId = '******';
// pass string to 2nd arg, same string will be send to same queue (aliyun-ons api)
const sendResult = await producer.send(msg, orderId);
// or you can write your own message queue seletor (RocketMQ api)
const sendResult = await producer.send(msg, messageQueues => {
let select = Math.max(Math.abs(hashCode(orderId)), 0);
return messageQueues[select % messageQueues.length];
});
console.log(sendResult);
})().catch(err => console.error(err))
```
Expand Down
Loading