Advertisement
Guest User

Untitled

a guest
Jan 25th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. require "bunny"
  2.  
  3. class TestRabbitMQConnection
  4. attr_reader :host,
  5. :port,
  6. :username,
  7. :password
  8.  
  9. def initialize(host: , port:, username:, password:)
  10. @host = host
  11. @port = port
  12. @username = username
  13. @password = password
  14. end
  15.  
  16. def perform
  17. connection.start
  18.  
  19. puts connection.inspect
  20. puts channel.inspect
  21.  
  22. channel.close
  23. connection.stop
  24. puts "OK"
  25. end
  26.  
  27. def connection
  28. @connection ||= Bunny.new(
  29. host: host,
  30. port: port,
  31. username: username,
  32. password: password
  33. )
  34. end
  35.  
  36. def channel
  37. @channel ||= connection.create_channel
  38. end
  39. end
  40.  
  41. TestRabbitMQConnection.new(
  42. host: "127.0.0.1",
  43. port: 51853,
  44. username: "a9s-brk-usr-wjzxgxwjxgrzzlusyjkvnkmvbuhwgcyhdc",
  45. password: "VztISCgo50yPXUQljPbxqqnfd1N0af0hQg"
  46. ).perform
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement