Package org.apache.activemq.artemis.api.core.client

## Class ClientRequestor

- java.lang.Object
- - org.apache.activemq.artemis.api.core.client.ClientRequestor

- All Implemented Interfaces:
    `java.lang.AutoCloseable`

      public final class ClientRequestor
      extends java.lang.Object
      implements java.lang.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.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ClientRequestor​(ClientSession session, java.lang.String requestAddress)` |
    `ClientRequestor​(ClientSession session, org.apache.activemq.artemis.api.core.SimpleString requestAddress)` | Constructor for the ClientRequestor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Closes the ClientRequestor and its session.
    `ClientMessage` | `request​(ClientMessage request)` | Sends a message to the request address and wait indefinitely for a reply.
    `ClientMessage` | `request​(ClientMessage request, long timeout)` | Sends a message to the request address and wait for the given timeout for a reply.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClientRequestor

          public ClientRequestor​(ClientSession session,
                                 org.apache.activemq.artemis.api.core.SimpleString requestAddress)
                          throws java.lang.Exception

      Constructor for the ClientRequestor. The implementation expects a ClientSession with automatic commits of sends and acknowledgements
      Parameters:
        `session` - a ClientSession uses to handle requests and replies
        `requestAddress` - the address to send request messages to
      Throws:
        `java.lang.Exception`

    - #### ClientRequestor

          public ClientRequestor​(ClientSession session,
                                 java.lang.String requestAddress)
                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`
      See Also:
        `ClientRequestor(ClientSession, SimpleString)`

  - ### Method Detail

    - #### request

          public ClientMessage request​(ClientMessage request)
                                throws java.lang.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:
        `java.lang.Exception`

    - #### request

          public ClientMessage request​(ClientMessage request,
                                       long timeout)
                                throws java.lang.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:
        `java.lang.Exception`

    - #### close

          public void close()
                     throws java.lang.Exception

      Closes the ClientRequestor and its session.
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `java.lang.Exception` - if an exception occurs while closing the ClientRequestor