Created
March 30, 2020 22:22
-
-
Save klogic/96789823951197a6e2fd9806f56f3439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("dotenv").config(); | |
const amqp = require("amqplib/callback_api"); | |
amqp.connect("amqp://" + process.env.RABBITMQ_URL, function(err, conn) { | |
conn.createChannel(function(err, ch) { | |
var ex = "posts"; | |
ch.assertExchange(ex, "fanout", { durable: false }); | |
ch.assertQueue("", { exclusive: true }, function(err, q) { | |
console.log( | |
" [*] Waiting for messages in %s. To exit press CTRL+C", | |
q.queue | |
); | |
ch.bindQueue(q.queue, ex, ""); | |
ch.consume(q.queue, function(msg) { | |
ch.ack(msg); | |
console.log(" [x] %s", msg.content.toString()); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment