Class ClientRequestor

  • All Implemented Interfaces:
    AutoCloseable

    public final class ClientRequestor
    extends Object
    implements AutoCloseable
    The ClientRequestor class helps making requests.
    The ClientRequestor constructor is given a ClientSession and a request address. It creates a temporary queue for the responses and provides a request method that sends the request message and waits for its reply.
    • Method Detail

      • request

        public ClientMessage request​(ClientMessage request)
                              throws Exception
        Sends a message to the request address and wait indefinitely for a reply. The temporary queue is used for the REPLYTO_HEADER_NAME, and only one reply per request is expected
        Parameters:
        request - the message to send
        Returns:
        the reply message
        Throws:
        Exception
      • request

        public ClientMessage request​(ClientMessage request,
                                     long timeout)
                              throws Exception
        Sends a message to the request address and wait for the given timeout for a reply. The temporary queue is used for the REPLYTO_HEADER_NAME, and only one reply per request is expected
        Parameters:
        request - the message to send
        timeout - the timeout to wait for a reply (in milliseconds)
        Returns:
        the reply message or null if no message is replied before the timeout elapses
        Throws:
        Exception
      • close

        public void close()
                   throws Exception
        Closes the ClientRequestor and its session.
        Specified by:
        close in interface AutoCloseable
        Throws:
        Exception - if an exception occurs while closing the ClientRequestor