def disconnect(host, port, remove = false)
      and_remove = " and removing" if remove
      Log.info("Disconnecting#{and_remove} broker at host #{host.inspect} port #{port.inspect}")
      Log.info("Current broker configuration: #{@client.status.inspect}")
      id = RightAMQP::HABrokerClient.identity(host, port)
      @connect_request_stats.update("disconnect #{@client.alias_(id)}")
      connected = @client.connected
      result = e = nil
      if connected.include?(id) && connected.size == 1
        result = "Not disconnecting from #{id} because it is the last connected broker for this agent"
      elsif @client.get(id)
        begin
          if remove
            @client.remove(host, port) do |id|
              unless update_configuration(:host => @client.hosts, :port => @client.ports)
                result = "Successfully disconnected from broker #{id} but failed to update config file"
              end
            end
          else
            @client.close_one(id)
          end
        rescue StandardError => e
          result = Log.format("Failed to disconnect from broker #{id}", e)
        end
      else
        result = "Cannot disconnect from broker #{id} because not configured for this agent"
      end
      ErrorTracker.log(self, result, e) if result
      result
    end
def disconnect(host, port, remove = false)
      and_remove = " and removing" if remove
      Log.info("Disconnecting#{and_remove} broker at host #{host.inspect} port #{port.inspect}")
      Log.info("Current broker configuration: #{@client.status.inspect}")
      id = RightAMQP::HABrokerClient.identity(host, port)
      @connect_request_stats.update("disconnect #{@client.alias_(id)}")
      connected = @client.connected
      result = e = nil
      if connected.include?(id) && connected.size == 1
        result = "Not disconnecting from #{id} because it is the last connected broker for this agent"
      elsif @client.get(id)
        begin
          if remove
            @client.remove(host, port) do |id|
              unless update_configuration(:host => @client.hosts, :port => @client.ports)
                result = "Successfully disconnected from broker #{id} but failed to update config file"
              end
            end
          else
            @client.close_one(id)
          end
        rescue StandardError => e
          result = Log.format("Failed to disconnect from broker #{id}", e)
        end
      else
        result = "Cannot disconnect from broker #{id} because not configured for this agent"
      end
      ErrorTracker.log(self, result, e) if result
      result
    end
def disconnect ( host , port , remove = false ) and_remove = " and removing" if remove Log . info ( "Disconnecting#{and_remove} broker at host #{host.inspect} port #{port.inspect}" ) Log . info ( "Current broker configuration: #{@client.status.inspect}" ) id = RightAMQP :: HABrokerClient . identity ( host , port ) @connect_request_stats . update ( "disconnect #{@client.alias_(id)}" ) connected = @client . connected result = e = nil if connected . include? ( id ) && connected . size == 1 result = "Not disconnecting from #{id} because it is the last connected broker for this agent" elsif @client . get ( id ) begin if remove @client . remove ( host , port ) do | id | unless update_configuration ( :host => @client . hosts , :port => @client . ports ) result = "Successfully disconnected from broker #{id} but failed to update config file" end end else @client . close_one ( id ) end rescue StandardError => e result = Log . format ( "Failed to disconnect from broker #{id}" , e ) end else result = "Cannot disconnect from broker #{id} because not configured for this agent" end ErrorTracker . log ( self , result , e ) if result result end
Disconnect from an AMQP broker and optionally remove it from the configuration
 Refuse to do so if it is the last connected broker

 === Parameters
 host(String):: Host name of broker
 port(Integer):: Port number of broker
 remove(Boolean):: Whether to remove broker from configuration rather than just closing it,
   defaults to false

 === Return
 (String|nil):: Error message if failed, otherwise nil
Disconnect from an AMQP broker and optionally remove it from the configuration Refuse to do so if it is the last connected broker