Skip to content

Instantly share code, notes, and snippets.

@tareqabedrabbo
Created February 20, 2012 17:35
Show Gist options
  • Save tareqabedrabbo/1870222 to your computer and use it in GitHub Desktop.
Save tareqabedrabbo/1870222 to your computer and use it in GitHub Desktop.
Connects to RabbitMQ's log exchange and logs all received messages to the console
var connection = require('amqp').createConnection({host: 'localhost'});
connection.on('ready', function() {
// create a temporary queue by passing an empty string as the queue name
var queue = connection.queue('', function(queue) {
console.log('connected to ' + queue.name);
// bind the queue to all messages on the amq.rabbitmq.log topic exchange
queue.bind('amq.rabbitmq.log', '#');
// log messages to the console
queue.subscribe(function(message, headers, deliveryInfo) {
console.log('[' + deliveryInfo.routingKey + '] ' + message.data.toString());
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment