Created
May 10, 2024 11:41
-
-
Save mkumm/796aa5cea1da55fc8c237afe205f0ded to your computer and use it in GitHub Desktop.
A simple RabbitMQ consumer in JavaScript
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
#!/usr/bin/env node | |
var amqp = require('amqplib/callback_api'); | |
amqp.connect('amqp://localhost:5675', function(_, connection) { | |
connection.createChannel(function(_, channel) { | |
var queue = 'sneakers'; | |
channel.assertQueue(queue, { | |
durable: false | |
}); | |
channel.consume(queue, function(msg) { | |
console.log(msg.content.toString()); | |
}, {noAck: true}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment