NSQ Publisher
Simple way to create topics and publish messages.
Installation
npm instal --save nsq-publisher
Usage
const Publisher = require('nsq-publisher');
const pub = new Publisher({
dataUrl: 'localhost',
dataHttpPort: 4151,
dataTcpPort: 4150,
topic: 'test-topic',
protocol: 'http',
autoCreate: false
});
pub.createTopic(function (err) {
if (err) {
console.error(err);
} else {
console.log('ok');
}
});
pub.createTopic()
.then(() => console.log('ok'))
.catch(err => console.error(err));
pub.publish('test message', function (err) {
if (err) {
console.error(err);
} else {
console.log('published');
}
});
pub.publish('test message')
.then(() => console.log('published'))
.catch(err => console.error(err));