Created
May 18, 2012 08:37
-
-
Save gotbadger/2724020 to your computer and use it in GitHub Desktop.
AMQP Listener
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
amqp = require('amqp'); | |
connection = amqp.createConnection { host: 'localhost' } | |
# Wait for connection to become established. | |
connection.on 'ready', ()-> | |
exchange = connection.exchange 'phil-exchange' | |
# Create a queue and bind to all messages. | |
connection.queue 'phil-queue',{autoDelete:false,durable:true}, (q)-> | |
# Catch all messages | |
q.bind('phil-exchange','#'); | |
# Receive messages | |
q.subscribe {ack:true},(message)-> | |
# Print messages | |
console.log(message.data.toString()) | |
q.shift() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment