org.openeai.jms.producer
Class PointToPointProducer

java.lang.Object
  |
  +--org.openeai.OpenEaiObject
        |
        +--org.openeai.jms.producer.MessageProducer
              |
              +--org.openeai.jms.producer.PointToPointProducer

public class PointToPointProducer
extends MessageProducer

The PointToPointProducer produces messages to a Queue. If the method being called to produce the message is 'produceRequest' the Producer will use the QueueRequestor object to produce the message and wait for a response from the consuming application. If the method called is 'produceMessage' it will not wait for a response.

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

Nested Class Summary
protected  class PointToPointProducer.MonitorProducer
          This Thread will sleep for 30 seconds and then wake up and check the status of the producer by attempting to create/delete a TemporaryQueue.
 
Field Summary
 
Fields inherited from class org.openeai.jms.producer.MessageProducer
m_messages, STARTED, STOPPED, STOPPING
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
PointToPointProducer()
           
PointToPointProducer(ProducerConfig pConfig)
          As AppConfig reads through an application's deployment document, it will build a ProducerConfig Java object and pass that object to this constructor.
 
Method Summary
 javax.jms.TextMessage createTextMessage()
          Convenience method that allows calling applications to use this producer to create a JMS TextMessage that is used during message production.
 javax.jms.Queue getQueue()
          Returns the Producers's Queue object.
 javax.jms.QueueConnection getQueueConnection()
          Returns the Producers's QueueConnection object.
 javax.jms.QueueConnectionFactory getQueueConnectionFactory()
          Returns the Producers's QueueConnectionFactory object.
 QueueRequestor getQueueRequestor()
          Returns the Producers's QueueRequestor object.
 javax.jms.QueueSender getQueueSender()
          Returns the Producers's QueueSender object.
 javax.jms.QueueSession getQueueSession()
          Returns the Producers's QueueSession object.
 int getRequestTimeoutInterval()
          Returns the request timeout interval that will be used by this producer to determine when a timeout occurrs.
protected  void init(java.util.Properties props)
          Invokes MessageProducer.init(Properties).
 void produceMessage(javax.jms.Message aMessage)
          Creates a QueueSender and produces the message passed in to the Queue the producer is connected to.
 javax.jms.Message produceRequest(javax.jms.Message aMessage)
          Uses the pre-started QueueRequestor to send a request to a consumer and wait for a response.
 void setQueue(javax.jms.Queue queue)
          Sets the Producers's Queue object.
 void setQueueConnection(javax.jms.QueueConnection queueConnection)
          Sets the Producers's QueueConnection object.
 void setQueueConnectionFactory(javax.jms.QueueConnectionFactory qcf)
          Sets the Producers's QueueConnectionFactory object.
 void setQueueRequestor(QueueRequestor queueRequestor)
          Sets the Producers's QueueRequestor object.
 void setQueueSender(javax.jms.QueueSender queueSender)
          Sets the Producers's QueueSender object.
 void setQueueSession(javax.jms.QueueSession session)
          Sets the Producers's QueueSession object.
 void setRequestTimeoutInterval(int timeout)
          Sets the request timeout interval that will be used by this producer to determine when a timeout occurrs.
 boolean startProducer()
          Starts the producer making it ready to produce messages to the Queue that it connects to.
 void stopProducer()
          Attempts to cleanly shutdown the Producer.
 
Methods inherited from class org.openeai.jms.producer.MessageProducer
getAcknowledgementMode, getConnectionFactoryName, getDefaultCommandName, getDeliveryMode, getDestinationName, getInitialContext, getInitialContextFactory, getMessageSeq, getPassword, getProducerId, getProducerIdUrl, getProducerName, getProducerStatus, getProviderUrl, getSecurityCredentials, getSecurityPrincipal, getStartOnInitialization, getTransacted, getUserName, incrementMessageSequence, isStarted, setAcknowledgementMode, setConnectionFactoryName, setDefaultCommandName, setDeliveryMode, setDestinationName, setInitialContextFactory, setMessageSeq, setPassword, setProducerId, setProducerIdUrl, setProducerName, setProducerStatus, setProviderUrl, setSecurityCredentials, setSecurityPrincipal, setStartOnInitialization, setTransacted, setUserName
 
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

PointToPointProducer

public PointToPointProducer()

PointToPointProducer

public PointToPointProducer(ProducerConfig pConfig)
                     throws java.io.IOException,
                            javax.jms.JMSException
As AppConfig reads through an application's deployment document, it will build a ProducerConfig Java object and pass that object to this constructor. Then this producer will have all the information it needs to initialize itself which.

See Also:
ProducerConfig, PubSubProducer
Method Detail

init

protected void init(java.util.Properties props)
             throws java.io.IOException
Invokes MessageProducer.init(Properties). Additionally, since this is a PointToPointProducer it sets the default "request timeout interval" and the TempPoolSize based on information found in the deployment document for this Producer.

Overrides:
init in class MessageProducer
Throws:
java.io.IOException
See Also:
MessageProducer.init(Properties)

getRequestTimeoutInterval

public final int getRequestTimeoutInterval()
Returns the request timeout interval that will be used by this producer to determine when a timeout occurrs. The default value is 10000 or 10 seconds. This is how long the producer will wait on a response to a request it makes. If the response takes longer than this, it will catch a 'Timeout' exception from the QueueRequestor and try the request again. If the second attempt fails, it will throw a JMSException that will be caught by the requesting application.

Returns:
int timeout interval in milliseconds.

setRequestTimeoutInterval

public final void setRequestTimeoutInterval(int timeout)
Sets the request timeout interval that will be used by this producer to determine when a timeout occurrs. The default value is 10000 or 10 seconds. This is how long the producer will wait on a response to a request it makes. If the response takes longer than this, it will catch a 'Timeout' exception from the QueueRequestor and try the request again. If the second attempt fails, it will throw a JMSException that will be caught by the requesting application. This method can be called at runtime prior to sending a request if an application needs to use something larger than the default.


getQueueConnectionFactory

public final javax.jms.QueueConnectionFactory getQueueConnectionFactory()
Returns the Producers's QueueConnectionFactory object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.QueueConnectionFactory

setQueueConnectionFactory

public final void setQueueConnectionFactory(javax.jms.QueueConnectionFactory qcf)
Sets the Producers's QueueConnectionFactory object.

See the JMS Specification to learn more about JMS objects.


getQueue

public final javax.jms.Queue getQueue()
Returns the Producers's Queue object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.Queue

setQueue

public final void setQueue(javax.jms.Queue queue)
Sets the Producers's Queue object.

See the JMS Specification to learn more about JMS objects.


getQueueConnection

public final javax.jms.QueueConnection getQueueConnection()
Returns the Producers's QueueConnection object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.QueueConnection

setQueueConnection

public final void setQueueConnection(javax.jms.QueueConnection queueConnection)
Sets the Producers's QueueConnection object.

See the JMS Specification to learn more about JMS objects.


getQueueSession

public final javax.jms.QueueSession getQueueSession()
Returns the Producers's QueueSession object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.QueueSession

setQueueSession

public final void setQueueSession(javax.jms.QueueSession session)
Sets the Producers's QueueSession object.

See the JMS Specification to learn more about JMS objects.


getQueueSender

public final javax.jms.QueueSender getQueueSender()
Returns the Producers's QueueSender object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.QueueSender

setQueueSender

public final void setQueueSender(javax.jms.QueueSender queueSender)
Sets the Producers's QueueSender object.

See the JMS Specification to learn more about JMS objects.


getQueueRequestor

public final QueueRequestor getQueueRequestor()
Returns the Producers's QueueRequestor object.

See the JMS Specification to learn more about JMS objects.

Returns:
org.openeai.jms.QueueRequestor
See Also:
QueueRequestor

setQueueRequestor

public final void setQueueRequestor(QueueRequestor queueRequestor)
Sets the Producers's QueueRequestor object.

See the JMS Specification to learn more about JMS objects.

See Also:
QueueRequestor

stopProducer

public final void stopProducer()
Attempts to cleanly shutdown the Producer. This includes closing all JMS resources (QueueRequestor, QueueSession and QueueConnection). If errors occur, it will log those errors as warnings. However, regardless of the outcome of the "clean" shutdown attempt, the producer will be stopped. This method is called anytime the producer detects connection problems to the broker or when specifically called from an application or gateway using this Producer.

See Also:
PointToPointProducer.MonitorProducer

startProducer

public boolean startProducer()
                      throws javax.jms.JMSException
Starts the producer making it ready to produce messages to the Queue that it connects to. This follows the typical JMS pattern of starting a message producer. This includes:

Returns:
boolean indicating whether or not the start was successful.
Throws:
javax.jms.JMSException
See Also:
PubSubProducer.startPublisher(), QueueRequestor

createTextMessage

public final javax.jms.TextMessage createTextMessage()
Convenience method that allows calling applications to use this producer to create a JMS TextMessage that is used during message production. This is used most commonly by the OpenEAI Message Object API (MOA) foundation.

Returns:
a JMS TextMessage

produceMessage

public final void produceMessage(javax.jms.Message aMessage)
                          throws javax.jms.JMSException
Creates a QueueSender and produces the message passed in to the Queue the producer is connected to. Does not wait for any response from the consumer of that message.

Throws:
javax.jms.JMSException - if errors occur.

produceRequest

public final javax.jms.Message produceRequest(javax.jms.Message aMessage)
                                       throws javax.jms.JMSException
Uses the pre-started QueueRequestor to send a request to a consumer and wait for a response. If a JMSException occurs producing the request it will attempt to restart the Producer and try to send the message again. This typically occurs when there have been critical network issues and the Producer's Monitor has not restarted it yet.

Returns:
javax.jms.Message the response from the consumer that processed the request
Throws:
javax.jms.JMSException - if errors occur and the producer can't successfully restart itself and re-send the message.


Copyright © 2002, OpenEAI Software Foundation