Advertisement
Guest User

Untitled

a guest
Mar 10th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'bunny'
  4.  
  5. raise 'invalid message size' unless ARGV[0] =~ /^[0-9]+$/
  6.  
  7. c = Bunny.new(:host => 'mq1', :user => 'admin', :password => 'passwd', :automatically_recover => false)
  8. c.start
  9.  
  10. ch = c.create_channel
  11. q = ch.queue('test-queue')
  12.  
  13. puts "(started) #{Time.now}"
  14.  
  15. begin
  16. loop { q.publish('a' * ARGV[0].to_i) }
  17. rescue Bunny::NetworkFailure => _
  18. puts "(aborted) #{Time.now}"
  19. rescue Exception => _
  20. ch.close
  21. c.close
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement