message4nsq
v0.0.2
Published
provide a simple nsq client interface
Downloads
2
Readme
message4nsq
Installation
$ npm install --save message4nsq
Example
var bluebird = require('bluebird');
var message = require('message4nsq')({
'nsqdTCPAddresses': 'localhost:4150',
promisify: bluebird.promisify
});
var topic = 'devTopic';
var channel = 'devChannel';
var msg = {
foo: 'bar'
};
message.publish(topic, msg, function (err) {
if (err) {
console.log(err);
return;
}
console.log('message sent.');
message.close();
});
var reader = message.watch(topic, channel, function (msg) {
console.log('message recv: ' + JSON.stringify(msg.json()));
msg.finish();
});