Class: Hutch::Adapters::BunnyAdapter
- Inherits:
-
Object
- Object
- Hutch::Adapters::BunnyAdapter
show all
- Extended by:
- Forwardable
- Includes:
- Logging
- Defined in:
- lib/hutch/adapters/bunny.rb
Constant Summary
collapse
- DEFAULT_VHOST =
Bunny::Session::DEFAULT_VHOST
- ConnectionRefused =
Bunny::TCPConnectionFailed
- ChannelAlreadyClosed =
Bunny::ChannelAlreadyClosed
- PreconditionFailed =
Bunny::PreconditionFailed
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
logger, #logger, logger=, setup_logger
Constructor Details
#initialize(opts = {}) ⇒ BunnyAdapter
Returns a new instance of BunnyAdapter.
20
21
22
|
# File 'lib/hutch/adapters/bunny.rb', line 20
def initialize(opts={})
@connection = Bunny.new(opts)
end
|
Class Method Details
.decode_message(delivery_info, properties, payload) ⇒ Object
24
25
26
|
# File 'lib/hutch/adapters/bunny.rb', line 24
def self.decode_message(delivery_info, properties, payload)
[delivery_info, properties, payload]
end
|
.new_exchange(ch, exchange_type, exchange_name, exchange_options) ⇒ Object
56
57
58
|
# File 'lib/hutch/adapters/bunny.rb', line 56
def self.new_exchange(ch, exchange_type, exchange_name, exchange_options)
Bunny::Exchange.new(ch, exchange_type, exchange_name, exchange_options)
end
|
Instance Method Details
#current_timestamp ⇒ Object
52
53
54
|
# File 'lib/hutch/adapters/bunny.rb', line 52
def current_timestamp
Time.now.to_i
end
|
#install_channel_recovery(ch) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/hutch/adapters/bunny.rb', line 36
def install_channel_recovery(ch)
ch.on_error do |channel, close|
next unless close.delivery_ack_timeout? || close.unknown_delivery_tag?
begin
channel.reopen
recover_channel_topology(channel)
logger.warn "recovered consumer channel closed with '#{close.reply_text}'"
rescue => ex
logger.error "channel recovery failed: #{ex.class}: #{ex.message}"
end
end
end
|
#prefetch_channel(ch, prefetch) ⇒ Object
28
29
30
|
# File 'lib/hutch/adapters/bunny.rb', line 28
def prefetch_channel(ch, prefetch)
ch.prefetch(prefetch) if prefetch
end
|
#queue_exists?(name) ⇒ Boolean
32
33
34
|
# File 'lib/hutch/adapters/bunny.rb', line 32
def queue_exists?(name)
@connection.queue_exists?(name)
end
|