beetle: sort servers randomly in when subscriber connects
It seems that there is a certain preference on connection
level when selecting the next message to process. We protect
against such bias by connecting in random order.
MODIFY
lib/beetle/base.rb
lib/beetle/base.rb
@@ -43,6 +43,10 @@ module Beetle
@servers.each { |s| set_current_server(s); yield }
end
+ def each_server_sorted_randomly
+ @servers.sort_by{rand}.each { |s| set_current_server(s); yield }
+ end
+
def exchanges
@exchanges[@server] ||= {}
end

MODIFY
lib/beetle/subscriber.rb
lib/beetle/subscriber.rb
@@ -34,7 +34,7 @@ module Beetle
@listened_queues = queues
@exchanges_for_queues = exchanges_for_queues(queues)
EM.run do
- each_server do
+ each_server_sorted_randomly do
connect_server connection_settings
end
yield if block_given?

beetle: sort servers randomly in when subscriber connects

It seems that there is a certain preference on connection
level when selecting the next message to process. We protect
against such bias by connecting in random order.