# File lib/chef/index_queue/amqp_client.rb, line 40 def amqp_client unless @amqp_client begin @amqp_client = Bunny.new(amqp_opts) Chef::Log.debug "Starting AMQP connection with client settings: #{@amqp_client.inspect}" @amqp_client.start @amqp_client.qos(:prefetch_count => 1) rescue Bunny::ServerDownError => e Chef::Log.fatal "Could not connect to rabbitmq. Is it running, reachable, and configured correctly?" raise e rescue Bunny::ProtocolError => e Chef::Log.fatal "Connection to rabbitmq refused. Check your rabbitmq configuration and chef's amqp* settings" raise e end end @amqp_client end
# File lib/chef/index_queue/amqp_client.rb, line 62 def disconnected! Chef::Log.error("Disconnected from the AMQP Broker (RabbitMQ)") @amqp_client = nil reset! end
# File lib/chef/index_queue/amqp_client.rb, line 58 def exchange @exchange ||= amqp_client.exchange("chef-indexer", :durable => true, :type => :fanout) end
# File lib/chef/index_queue/amqp_client.rb, line 68 def queue_for_object(obj_id) retries = 0 vnode_tag = obj_id_to_int(obj_id) % VNODES begin yield amqp_client.queue("vnode-#{vnode_tag}", :passive => false, :durable => true, :exclusive => false, :auto_delete => false) rescue Bunny::ServerDownError, Bunny::ConnectionError, Errno::ECONNRESET disconnected! if (retries += 1) < 2 Chef::Log.info("Attempting to reconnect to the AMQP broker") retry else Chef::Log.fatal("Could not re-connect to the AMQP broker, giving up") raise end end end
Generated with the Darkfish Rdoc Generator 2.