set beetle disconnect timeout > bunny
Bunny has a disconnect_timeout that is applied to each channel and to
the connection. This sets it accordingly to give bunny the time necessary
to disconnect properly (without just closing the TCP connection after 1 second).
MODIFY
lib/beetle/publisher.rb
lib/beetle/publisher.rb
@@ -2,6 +2,9 @@ module Beetle
# Provides the publishing logic implementation.
class Publisher < Base
+ DEFAULT_BUNNY_CONNECT_TIMEOUT = 5
+ DEFAULT_BEETLE_DISCONNECT_TIMEOUT = DEFAULT_BUNNY_CONNECT_TIMEOUT * 2 + 1
+
attr_reader :dead_servers
def initialize(client, options = {}) #:nodoc:
@@ -168,6 +171,7 @@ module Beetle
:frame_max => @client.config.frame_max,
:channel_max => @client.config.channel_max,
:socket_timeout => @client.config.publishing_timeout,
+ :connect_timeout => DEFAULT_BUNNY_CONNECT_TIMEOUT,
:spec => '09')
b.start
b
@@ -224,7 +228,7 @@ module Beetle
def stop!(exception=nil)
return unless bunny?
- Beetle::Timer.timeout(1) do
+ Beetle::Timer.timeout(DEFAULT_BEETLE_DISCONNECT_TIMEOUT) do
logger.debug "Beetle: closing connection from publisher to #{server}"
if exception
bunny.__send__ :close_socket

MODIFY
test/beetle/publisher_test.rb
test/beetle/publisher_test.rb
@@ -24,6 +24,7 @@ module Beetle
:pass => "guest",
:vhost => "/",
:socket_timeout => 0,
+ :connect_timeout => 5,
:frame_max => 131072,
:channel_max => 2047,
:spec => '09'

set beetle disconnect timeout > bunny

Bunny has a disconnect_timeout that is applied to each channel and to
the connection. This sets it accordingly to give bunny the time necessary
to disconnect properly (without just closing the TCP connection after 1 second).