Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function processCalendarData(cb) {
setTimeout(function(){
cb();
}, 1000);
};
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch){
var queueName = 'notification';
ch.assertQueue(queueName, {durable:true});
console.log('[*] Waiting for notifications');
ch.consume(queueName, function(msg) {
ch.ack(msg);
console.log(" [x] Received %s", msg.content.toString());
var data = JSON.parse(msg.content.toString());
//process calendar data then call queue complete notification
processCalendarData(function(){
console.log('processedCalendarData - writing calendarComplete to ' + data.callbackQueue + ' queue');
ch.sendToQueue(data.callbackQueue, new Buffer('calendarComplete'));
})
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.