Class: Promiscuous::AMQP::HotBunnies

Inherits:
Bunny
  • Object
show all
Defined in:
lib/promiscuous/amqp/hot_bunnies.rb

Defined Under Namespace

Modules: Subscriber

Instance Attribute Summary collapse

Attributes inherited from Bunny

#callback_mapping, #connection_lock

Instance Method Summary collapse

Methods inherited from Bunny

#connect, hijack_bunny, #initialize, #new_connection, #on_confirm, #publish

Constructor Details

This class inherits a constructor from Promiscuous::AMQP::Bunny

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



2
3
4
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 2

def connection
  @connection
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 34

def connected?
  !!@connection.try(:is_open)
end

#disconnectObject



25
26
27
28
29
30
31
32
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 25

def disconnect
  @connection_lock.synchronize do
    return unless connected?
    @channel.close rescue nil
    @connection.close rescue nil
    @connection = @channel = nil
  end
end

#initialize_driverObject



4
5
6
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 4

def initialize_driver
  require 'hot_bunnies'
end

#raw_confirm_select(channel, &callback) ⇒ Object



16
17
18
19
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 16

def raw_confirm_select(channel, &callback)
  channel.add_confirm_listener(&callback)
  channel.confirm_select
end

#raw_new_connection(options = {}) ⇒ Object

TODO auto reconnect



10
11
12
13
14
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 10

def raw_new_connection(options={})
  ::HotBunnies.connect(:uri => options[:url],
                       :heartbeat_interval => Promiscuous::Config.heartbeat,
                       :connection_timeout => Promiscuous::Config.socket_timeout)
end

#raw_publish(options = {}) ⇒ Object



21
22
23
# File 'lib/promiscuous/amqp/hot_bunnies.rb', line 21

def raw_publish(options={})
  options[:exchange].publish(options[:payload], :routing_key => options[:key], :persistent => true)
end