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