aliyun-ons
Rocket MQ SDK support Aliyun Open Notification Service Client
Last updated 2 months ago by yeliex .
MIT · Repository · Bugs · Original npm · Tarball
$ cnpm install aliyun-ons 
SYNC missed versions from official npm registry.

rocketmq

NPM version build status David deps node version

Rocket MQ SDK support Aliyun Open Notification Service Client (base on opensource project RocketMQ)

Forked from ali-ons

Install

npm install rocketmq --save

Usage

consumer

'use strict';

const Consumer = require('rocketmq').Consumer;
const consumer = new Consumer({
  namesrvAddr: 'localhost:9876', // for rocket mq
  accessKey: 'your-accesskey',  // for aliyun-ons
  secretKey: 'your-secretkey',  // for aliyun-ons
  onsAddr: '',                   // for aliyun-ons
  consumerGroup: 'your-consumer-group',  // for aliyun-ons
  
  isBroadcast: false, // default is false, that mean messages will be pushed to consumer cluster only once.
});

consumer.subscribe('your-topic', '*');

consumer.on('message', (msgs, done) => {
  msgs.forEach(msg => console.log(`receive message, msgId: ${msg.msgId}, body: ${msg.body.toString()}`));
  done();
});

consumer.on('error', err => console.log(err.stack));
consumer.ready(() => console.log('consumer is ready'));

producer

'use strict';

const Producer = require('rocketmq').Producer;
const Message = require('rocketmq').Message;

const producer = new Producer({
  namesrvAddr: 'localhost:9876', // for rocket mq
  accessKey: 'your-accesskey',   // for aliyun-ons
  secretKey: 'your-secretkey',    // for aliyun-ons
  producerGroup: 'your-producer-group',  // for aliyun-ons
});

producer.ready(() => {
  console.log('producer ready');
  const msg = new Message('your-topic', // topic
    'TagA', // tag
    'Hello ONS !!! ' // body
  );

  producer.send(msg, (err, sendResult) => console.log(err, sendResult));
});

License

MIT

Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (16)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |