Skip to content

Instantly share code, notes, and snippets.

@mkumm
Created May 10, 2024 11:41
Show Gist options
  • Save mkumm/796aa5cea1da55fc8c237afe205f0ded to your computer and use it in GitHub Desktop.
Save mkumm/796aa5cea1da55fc8c237afe205f0ded to your computer and use it in GitHub Desktop.
A simple RabbitMQ consumer in JavaScript
#!/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