Skip to content

Instantly share code, notes, and snippets.

@gotbadger
Created May 18, 2012 08:37
Show Gist options
  • Save gotbadger/2724020 to your computer and use it in GitHub Desktop.
Save gotbadger/2724020 to your computer and use it in GitHub Desktop.
AMQP Listener
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