org.apache.jmeter.protocol.jms.sampler

## Class TimeoutEnabledQueueRequestor

- java.lang.Object
- - org.apache.jmeter.protocol.jms.sampler.TimeoutEnabledQueueRequestor

-     public class TimeoutEnabledQueueRequestor
      extends java.lang.Object

  The `TimeoutEnabledQueueRequestor` helper class simplifies making service requests using the request/reply pattern.

  The `TimeoutEnabledQueueRequestor` constructor is given a non-transacted `QueueSession` and a destination `Queue`. It creates a `TemporaryQueue` for the responses and provides a `request` method that sends the request message and waits for its reply.

  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TimeoutEnabledQueueRequestor(javax.jms.Session session, javax.jms.Queue queue)` Constructor for the `TimeoutEnabledQueueRequestor` class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the `TimeoutEnabledQueueRequestor` and its session.
    `javax.jms.Message` | `request(javax.jms.Message message)` Sends a request and waits for a reply.
    `javax.jms.Message` | `request(javax.jms.Message message, long timeout)` Sends a request and waits for a reply.

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

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

- - ### Constructor Detail

    - #### TimeoutEnabledQueueRequestor

          public TimeoutEnabledQueueRequestor(javax.jms.Session session,
                                              javax.jms.Queue queue)
                                       throws javax.jms.JMSException

      Constructor for the `TimeoutEnabledQueueRequestor` class.

      This implementation assumes the session parameter to be non-transacted, with a delivery mode of either `AUTO_ACKNOWLEDGE` or `DUPS_OK_ACKNOWLEDGE`.

      Parameters:
        `session` - the `QueueSession` the queue belongs to, session will not be closed by `TimeoutEnabledQueueRequestor`
        `queue` - the queue to performthe request/reply call on
      Throws:
        `javax.jms.JMSException` - if the JMS provider fails to create the `TimeoutEnabledQueueRequestor` due to some internal error.
        `javax.jms.InvalidDestinationException` - if an invalid queue is specified.

  - ### Method Detail

    - #### request

          public javax.jms.Message request(javax.jms.Message message)
                                    throws javax.jms.JMSException

      Sends a request and waits for a reply. The temporary queue is used for the `JMSReplyTo` destination, and only one reply per request is expected. The method blocks indefinitely until a message arrives!
      Parameters:
        `message` - the message to send
      Returns:
        the reply message
      Throws:
        `javax.jms.JMSException` - if the JMS provider fails to complete the request due to some internal error.

    - #### request

          public javax.jms.Message request(javax.jms.Message message,
                                           long timeout)
                                    throws javax.jms.JMSException

      Sends a request and waits for a reply. The temporary queue is used for the `JMSReplyTo` destination, and only one reply per request is expected. The client waits/blocks for the reply until the timeout is reached.
      Parameters:
        `message` - the message to send
        `timeout` - time to wait for a reply on temporary queue. If you specify no arguments or an argument of 0, the method blocks indefinitely until a message arrives
      Returns:
        the reply message
      Throws:
        `javax.jms.JMSException` - if the JMS provider fails to complete the request due to some internal error.

    - #### close

          public void close()
                     throws javax.jms.JMSException

      Closes the `TimeoutEnabledQueueRequestor` and its session.

      Since a provider may allocate some resources on behalf of a `TimeoutEnabledQueueRequestor` outside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

      This method closes the `Session` object passed to the `TimeoutEnabledQueueRequestor` constructor.

      Throws:
        `javax.jms.JMSException` - if the JMS provider fails to close the `TimeoutEnabledQueueRequestor` due to some internal error.

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.