public class TimeoutEnabledQueueRequestor extends Object
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.
| Constructor and Description |
|---|
TimeoutEnabledQueueRequestor(javax.jms.Session session,
javax.jms.Queue queue)
Constructor for the
TimeoutEnabledQueueRequestor class. |
| 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.
|
public TimeoutEnabledQueueRequestor(javax.jms.Session session,
javax.jms.Queue queue)
throws javax.jms.JMSException
TimeoutEnabledQueueRequestor class.
This implementation assumes the session parameter to be non-transacted,
with a delivery mode of either AUTO_ACKNOWLEDGE or
DUPS_OK_ACKNOWLEDGE.
session - the QueueSession the queue belongs to, session will not be closed by TimeoutEnabledQueueRequestorqueue - the queue to perform the request/reply call onjavax.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.public javax.jms.Message request(javax.jms.Message message)
throws javax.jms.JMSException
JMSReplyTo destination, and only one reply per request
is expected. The method blocks indefinitely until a message arrives!message - the message to sendjavax.jms.JMSException - if the JMS provider fails to complete the request due to
some internal error.public javax.jms.Message request(javax.jms.Message message,
long timeout)
throws javax.jms.JMSException
JMSReplyTo destination, and only one reply per request
is expected. The client waits/blocks for the reply until the timeout is
reached.message - the message to sendtimeout - 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 arrivesjavax.jms.JMSException - if the JMS provider fails to complete the request due to
some internal error.public void close()
throws javax.jms.JMSException
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.
javax.jms.JMSException - if the JMS provider fails to close the
TimeoutEnabledQueueRequestor due to some
internal error.Copyright © 1998-2021 Apache Software Foundation. All Rights Reserved.