Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.41 KB | None | 0 0
  1. require 'amqp'
  2. require 'rubygems'
  3. require 'bunny'
  4. require 'eventmachine'
  5.  
  6. connection = Bunny.new
  7. connection.start
  8.  
  9. channel = connection.create_channel
  10. queue = channel.queue('hello')
  11.  
  12. begin
  13.   puts ' [*] Waiting for messages. To exit press CTRL+C'
  14.   queue.subscribe(block: true) do |metadata, payload|
  15.     puts " [x] Received #{payload}"
  16.   end
  17. rescue Interrupt => _
  18.   connection.close
  19.  
  20.   exit(0)
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement