Skip to content

Instantly share code, notes, and snippets.

@madhur
Created May 23, 2016 14:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save madhur/96b598413f43ef00504e13280d701e5d to your computer and use it in GitHub Desktop.
var amqp = require('amqplib');
var http = require('http');
var PUBNUB = require('pubnub');
pubnub = PUBNUB({
publish_key: 'demo',
subscribe_key: 'demo'
});
amqp.connect('amqp://localhost').then(function(conn) {
process.once('SIGINT', function() { conn.close(); });
return conn.createChannel().then(function(ch) {
ch.prefetch(100);
ch.consume('tasks.send_notification_task', doWork, { noAck: false });
return;
function doWork(msg) {
var body = msg.content.toString();
var msgObj = JSON.parse(msg.content.toString());
var msg1="test";
console.log(msg);
pubnub.publish({
channel: '16182',
message: msg1,
callback: function(m) {
ch.ack(msg);
}
});
}
});
}).then(null, console.warn);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment