Created
          February 20, 2012 17:35 
        
      - 
      
 - 
        
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
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | 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