Class: EventQ::RabbitMq::QueueClient
- Inherits:
-
Object
- Object
- EventQ::RabbitMq::QueueClient
- Defined in:
- lib/eventq_rabbitmq/rabbitmq_queue_client.rb
Constant Summary collapse
- GUEST =
'guest'.freeze
Instance Method Summary collapse
- #connection_options ⇒ Object
- #get_connection ⇒ Object
-
#initialize(options = {}) ⇒ QueueClient
constructor
A new instance of QueueClient.
Constructor Details
#initialize(options = {}) ⇒ QueueClient
Returns a new instance of QueueClient.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/eventq_rabbitmq/rabbitmq_queue_client.rb', line 7 def initialize( = {}) if [:endpoint] == nil raise ':endpoint must be specified.'.freeze end @endpoint = [:endpoint] @port = Integer([:port] || 5672) @user = [:user] || GUEST @password = [:password] || GUEST @ssl = [:ssl] == true || false end |
Instance Method Details
#connection_options ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/eventq_rabbitmq/rabbitmq_queue_client.rb', line 25 def { :host => @endpoint, :port => @port, :user => @user, :pass => @password, :ssl => @ssl, :read_timeout => 4, :heartbeat => 8, :continuation_timeout => 5000, :automatically_recover => true, :network_recovery_interval => 1, :recover_from_connection_close => true } end |
#get_connection ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/eventq_rabbitmq/rabbitmq_queue_client.rb', line 41 def get_connection if RUBY_PLATFORM =~ /java/ conn = MarchHare.connect() else conn = Bunny.new() end conn.start return conn end |