org.openeai.jms.producer
Class QueueRequestor


java.lang.Object

  |

  +--org.openeai.OpenEaiObject

        |

        +--org.openeai.jms.producer.QueueRequestor


public class QueueRequestor
extends OpenEaiObject

JMS provides a QueueRequestor helper class to simplify making service requests. This is the OpenEAI version of that class which leverages several other OpenEAI foundation components like TempQueuePool to increase the performance of request production. It is thread safe so multiple threads can make requests using the same producer and queue requestor.

Version:
3.0 beta2 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)
See Also:
TempQueuePool, PointToPointProducer

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
QueueRequestor(javax.jms.QueueSession session, javax.jms.Queue queue)
          Constructor for the QueueRequestor class.
 
Method Summary
 void close()
          Since a provider may allocate some resources on behalf of a QueueRequestor outside the JVM, clients should close them when they are not needed.
 TempQueuePool getTempQueuePool()
          Returns the Temporary Queue Pool associated to this QueueRequestor.
 int getTimeoutInterval()
          Returns the request timeout interval assoicated to this QueueRequestor.
 javax.jms.Message request(javax.jms.Message message)
          Send a request and wait for a reply.
 void setTempQueuePool(TempQueuePool tempQueuePool)
          Sets the Temporary Queue Pool associated to this QueueRequestor.
 void setTimeoutInterval(int timeout)
          Sets the request timeout interval assoicated to this QueueRequestor.
 
Methods inherited from class org.openeai.OpenEaiObject
addLog4jProperty, getAppName, getDebug, getFromAddr, getLog4jProperties, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setAppName, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueRequestor


public QueueRequestor(javax.jms.QueueSession session,
                      javax.jms.Queue queue)
               throws javax.jms.JMSException
Constructor for the QueueRequestor class.

This implementation assumes the session parameter to be non-transacted and either AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE.

Parameters:
session - the queue session the queue belongs to.
queue - the queue to perform the request/reply call on.
Throws:
javax.jms.JMSException - if a JMS error occurs.
Method Detail

getTempQueuePool


public TempQueuePool getTempQueuePool()
Returns the Temporary Queue Pool associated to this QueueRequestor.

Returns:
TempQueuePool
See Also:
TempQueuePool

setTempQueuePool


public void setTempQueuePool(TempQueuePool tempQueuePool)
Sets the Temporary Queue Pool associated to this QueueRequestor. The PointToPointProducer creates a TempQueuePool and calls this method when it's being initialized based it's configuration information found in the ProducerConfig object.

Returns:
TempQueuePool
See Also:
TempQueuePool, ProducerConfig

getTimeoutInterval


public int getTimeoutInterval()
Returns the request timeout interval assoicated to this QueueRequestor. This value is used by the QueueRequestor when it waits for a response to a request. If the response takes longer than this interval, a JMSTimeoutException will be thrown by the request method.

Returns:
int the currently assigned timeout interval for requests.

setTimeoutInterval


public void setTimeoutInterval(int timeout)
Sets the request timeout interval assoicated to this QueueRequestor. This value is used by the QueueRequestor when it waits for a response to a request. If the response takes longer than this interval, a JMSTimeoutException will be thrown by the request method.

This method is called by the PointToPointProducer when it uses the QueueRequestor to send a request in the produceRequest method.

See Also:
PointToPointProducer.produceRequest(Message)

request


public javax.jms.Message request(javax.jms.Message message)
                          throws JMSTimeoutException,
                                 javax.jms.JMSException
Send a request and wait for a reply. The temporary queue is used for replyTo, and only one reply per request is expected.

This method retrieves a PooledTempQueue object from the TempQueuePool associated to this QueueRequestor and uses the TemporaryQueue and QueueReceiver associated to that PooledTempQueue for the request and subsequent response.

Parameters:
message - the message to send.
Returns:
the reply message.
Throws:
javax.jms.JMSException - if a JMS error occurs.
JMSTimeoutException - if the response isn't returned in the allowed time.

close


public void close()
           throws javax.jms.JMSException
Since a provider may allocate some resources on behalf of a QueueRequestor outside the JVM, 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 the Session object passed to the QueueRequestor constructor and all objects in the TempQueuePool.

Throws:
javax.jms.JMSException - if a JMS error occurs.


Copyright © 2002, OpenEAI Software Foundation