Skip to content

Instantly share code, notes, and snippets.

@nrempel
Created May 25, 2017 05:10
Show Gist options
  • Save nrempel/061cdc5ccdbe35faac0947877e8be555 to your computer and use it in GitHub Desktop.
Save nrempel/061cdc5ccdbe35faac0947877e8be555 to your computer and use it in GitHub Desktop.
const amqp = require('amqplib/callback_api');
amqp.connect(process.env.RABBIT_URL, (err, conn) => {
conn.createChannel((err, ch) => {
// Consume messages from web queue
var q1 = 'web';
ch.assertQueue(q1, { durable: false });
ch.consume(q1, (msg) => {
console.info('Message received from web process:', msg.content.toString());
}, {noAck: true});
// Consume messages from clock queue
var q2 = 'clock';
ch.assertQueue(q2, { durable: false });
ch.consume(q2, (msg) => {
console.info('Message received from clock process:', msg.content.toString());
}, {noAck: true});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment