Skip to content

Instantly share code, notes, and snippets.

@anymaniax
Created June 2, 2017 11:22
Show Gist options
  • Save anymaniax/29b6cd241c938b720ff138ea003d50ab to your computer and use it in GitHub Desktop.
Save anymaniax/29b6cd241c938b720ff138ea003d50ab to your computer and use it in GitHub Desktop.
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch) {
var q = 'task_queue';
ch.assertQueue(q, {durable: true});
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", q);
ch.consume(q, function(msg) {
var secs = msg.content.toString().split('.').length - 1;
console.log(" [x] Received %s", msg.content.toString());
console.log(" [x] Done");
ch.ack(msg);
}, {noAck: false});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment