java.lang.Object | +--javax.jms.TopicRequestor
TheTopicRequestor
helper class simplifies making service requests.
TheTopicRequestor
constructor is given a non-transactedTopicSession
and a destinationTopic
. It creates aTemporaryTopic
for the responses and provides arequest
method that sends the request message and waits for its reply.
This is a basic request/reply abstraction that should be sufficient for most uses. JMS providers and clients are free to create more sophisticated versions.
QueueRequestor
TopicRequestor(TopicSession session,Topic topic) Constructor for the TopicRequestor class. |
close() Closes the TopicRequestor and its session. | |
request(Message message) 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 |
publicTopicRequestor(TopicSession session,Topic topic) throwsJMSException
TopicRequestor
class.This implementation assumes the session parameter to be non-transacted, with a delivery mode of eitherAUTO_ACKNOWLEDGE
orDUPS_OK_ACKNOWLEDGE
.
session
- theTopicSession
the topic belongs totopic
- the topic to perform the request/reply call onJMSException
- if the JMS provider fails to create theTopicRequestor
due to some internal error.InvalidDestinationException
- if an invalid topic is specified.publicMessagerequest(Message message) throwsJMSException
JMSReplyTo
destination; the first reply is returned, and any following replies are discarded.message
- the message to sendJMSException
- if the JMS provider fails to complete the request due to some internal error.public voidclose() throwsJMSException
TopicRequestor
and its session.Since a provider may allocate some resources on behalf of aTopicRequestor
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.
Note that this method closes theTopicSession
object passed to theTopicRequestor
constructor.
JMSException
- if the JMS provider fails to close theTopicRequestor
due to some internal error.