Skip to content

Instantly share code, notes, and snippets.

@rattrap
Created February 20, 2018 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rattrap/3701c957af8b067f87abc08a32dcf6e6 to your computer and use it in GitHub Desktop.
Save rattrap/3701c957af8b067f87abc08a32dcf6e6 to your computer and use it in GitHub Desktop.
require "bunny"
# Start a communication session with RabbitMQ
conn = Bunny.new("amqp://username:password@rabbit-server:5672/%2F")
conn.start
# open a channel
ch = conn.create_channel
# declare a queue
q = ch.queue("test", durable:true, :exclusive => false)
q.subscribe(:block => true, :manual_ack => false) do |delivery_info, properties, payload|
puts "Received #{payload}, message properties are #{properties.inspect}"
end
# close the connection
conn.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment