Class TimeoutEnabledQueueRequestor
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
ConstructorDescriptionTimeoutEnabledQueueRequestor
(javax.jms.Session session, javax.jms.Queue queue) Constructor for theTimeoutEnabledQueueRequestor
class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes theTimeoutEnabledQueueRequestor
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.
-
Constructor Details
-
TimeoutEnabledQueueRequestor
public TimeoutEnabledQueueRequestor(javax.jms.Session session, javax.jms.Queue queue) throws javax.jms.JMSException Constructor for theTimeoutEnabledQueueRequestor
class.This implementation assumes the session parameter to be non-transacted, with a delivery mode of either
AUTO_ACKNOWLEDGE
orDUPS_OK_ACKNOWLEDGE
.- Parameters:
session
- theQueueSession
the queue belongs to, session will not be closed byTimeoutEnabledQueueRequestor
queue
- the queue to perform the request/reply call on- Throws:
javax.jms.JMSException
- if the JMS provider fails to create theTimeoutEnabledQueueRequestor
due to some internal error.javax.jms.InvalidDestinationException
- if an invalid queue is specified.
-
-
Method Details
-
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 theJMSReplyTo
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 theJMSReplyTo
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 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 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.JMSExceptionCloses theTimeoutEnabledQueueRequestor
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 theTimeoutEnabledQueueRequestor
constructor.- Throws:
javax.jms.JMSException
- if the JMS provider fails to close theTimeoutEnabledQueueRequestor
due to some internal error.
-