8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/multiple_man/connection.rb', line 8
def self.connect
yield new(channel)
Thread.current[:multiple_man_exception_retry_count] = 0
rescue Bunny::Exception, Timeout::Error => e
recovery_options = MultipleMan.configuration.connection_recovery
MultipleMan.logger.debug "Bunny Error: #{e.inspect}"
retry_count = Thread.current[:multiple_man_exception_retry_count] || 0
retry_count += 1
if retry_count < recovery_options[:max_retries]
Thread.current[:multiple_man_exception_retry_count] = retry_count
sleep recovery_options[:time_between_retries]
retry
else
Thread.current[:multiple_man_exception_retry_count] = 0
raise "MultipleMan::ConnectionError"
end
end
|