0.0.7 • Published 10 years ago
node-metaq-client v0.0.7
node-metaq-client
Install
$ npm install node-metaq-client
Usage
var metaq = require('node-metaq-client');
* @param {object} options config
* - accessKey
* - secretKey
* - metaRestHost
* - metaqRestVersion
* - group
* - tairDiamondHost
* - tairDataId
* - tairNamespace
* - conCount 消费并发数,默认: 1
* - capacity 收消息队列缓存个数
var client = metaq.createClient({
accessKey : 'a885c583',
secretKey : 'a885c583-a6b5-401d-9f0f-aebc328c6466',
metaqRestHost : 'http://10.235.170.6:80',
metaqRestVersion : '2014-04-01',
group: 'app'
//tairDiamondHost : 'xxx',
//tairDataId : 'xx',
//tairNamespace : xx
});
client.on('c_error',function(err){
console.log('metaq client error:', err.msg, err.stack);
});
client.send('lk-test','message', function (err,data){
if(err){
console.log('err' + err);
}
});
client.subscribe('lk-test',null,function(err,msg,notify) {
console.log(msg);
//do...
//异步处理完成后,调notify(),接收下一条消息
notify();
},function(err,data) {
if(!err) {
console.log('subscribe success.');
}
});