Class KristenHttpClient

    • Constructor Detail

      • KristenHttpClient

        public KristenHttpClient​(KristenHttpClientParameters parameters)
                          throws com.kristensoft.kdc.license.runtime.LicenseException
        Creates an HTTP client using the specified parameters.
        Parameters:
        parameters - the parameters used to configure the HTTP client
        Throws:
        IllegalArgumentException - if parameters is null
        com.kristensoft.kdc.license.runtime.LicenseException - if the client cannot be created due to a licensing error
        See Also:
        KristenHttpClientParameters
    • Method Detail

      • getKristenHttpClientParameters

        public KristenHttpClientParameters getKristenHttpClientParameters()
        Returns the parameters used to configure this HTTP client.
        Returns:
        the HTTP client parameters
      • receive

        public Agent receive()
        Receiving an agent directly is not supported by the HTTP client.
        Returns:
        null
      • connect

        public void connect()
        Attempts to establish a connection to the configured HTTP server.

        The result of the connection attempt is reported to the configured KristenHttpClientEventHandler instances.

      • sendSync

        public Reply sendSync​(Agent agent)
                       throws IOException,
                              com.kristensoft.ko.KristenObjectsException,
                              KristenCommsException
        Sends an agent synchronously to the configured HTTP server and waits for a reply.
        Parameters:
        agent - the agent to send
        Returns:
        the reply received from the HTTP server, or null if a reply cannot be obtained
        Throws:
        IllegalArgumentException - if agent is null
        IOException - if an I/O error occurs while sending or receiving
        com.kristensoft.ko.KristenObjectsException - if an object serialization or deserialization error occurs
        KristenCommsException - if a KDC communications error occurs
      • close

        public final void close()
        Closes this HTTP client.

        No explicit cleanup is required because HTTP connections and their underlying resources are managed by the HTTP implementation.

        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in class Client
      • send

        public void send​(byte[] bytes)
        Sends the specified bytes using the synchronous HTTP send operation.
        Parameters:
        bytes - the bytes to send
      • isRunning

        public boolean isRunning()
        Determines whether this communication entity is currently running.
        Returns:
        true if this communication entity is running; false otherwise
      • flushMetrics

        public void flushMetrics()
        Flushes the accumulated latency metrics for this communication entity.

        This method may be used to report any currently accumulated metrics without waiting for the configured latency reporting interval.

      • getAgentSerializer

        public AgentSerializer getAgentSerializer()
        Returns the agent serializer used by this communication entity.

        The serializer may be used to inspect or modify serialization settings at runtime, including compression and encryption settings.

        Returns:
        the agent serializer used by this communication entity