org.openeai.jms.producer
Class PubSubProducer

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

public class PubSubProducer
extends MessageProducer

The PubSubProducer produces messages to a JMS Topic.

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

Nested Class Summary
protected  class PubSubProducer.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 TemporaryTopic.
 
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
PubSubProducer()
           
PubSubProducer(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.
 PubSubProducer getLoggingProducer()
          Returns the Logging Producer associated to this producer which is simply another PubSubProducer that may be configured in the deployment document to publish messages published by this producer to a second "logging" destination.
 javax.jms.Topic getTopic()
          Returns the Producers's Topic object.
 javax.jms.TopicConnection getTopicConnection()
          Returns the Producers's TopicConnection object.
 javax.jms.TopicConnectionFactory getTopicConnectionFactory()
          Returns the Producers's TopicConnectionFactory object.
 javax.jms.TopicPublisher getTopicPublisher()
          Returns the Producers's TopicPublisher object.
 javax.jms.TopicSession getTopicSession()
          Returns the Producers's TopicSession object.
 boolean publishMessage(javax.jms.Message aMessage)
          Publishes the message passed in to the Topic the producer is connected to.
 void setLoggingProducer(PubSubProducer producer)
          Sets the Logging Producer associated to this producer which is simply another PubSubProducer that may be configured in the deployment document to publish messages published by this producer to a second "logging" destination.
 void setTopic(javax.jms.Topic topic)
          Sets the Producers's Topic object.
 void setTopicConnection(javax.jms.TopicConnection topicConnection)
          Sets the Producers's TopicConnection object.
 void setTopicConnectionFactory(javax.jms.TopicConnectionFactory tcf)
          Sets the Producers's TopicConnectionFactory object.
 void setTopicPublisher(javax.jms.TopicPublisher topicPublisher)
          Sets the Producers's TopicPublisher object.
 void setTopicSession(javax.jms.TopicSession session)
          Sets the Producers's TopicSession object.
 boolean startPublisher()
          Starts the producer making it ready to publish messages to the Topic that it connects to.
 void stopPublisher()
          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, init, 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

PubSubProducer

public PubSubProducer()

PubSubProducer

public PubSubProducer(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, PointToPointProducer
Method Detail

getTopicConnectionFactory

public final javax.jms.TopicConnectionFactory getTopicConnectionFactory()
Returns the Producers's TopicConnectionFactory object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.TopicConnectionFactory

setTopicConnectionFactory

public final void setTopicConnectionFactory(javax.jms.TopicConnectionFactory tcf)
Sets the Producers's TopicConnectionFactory object.

See the JMS Specification to learn more about JMS objects.


getTopic

public final javax.jms.Topic getTopic()
Returns the Producers's Topic object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.Topic

setTopic

public final void setTopic(javax.jms.Topic topic)
Sets the Producers's Topic object.

See the JMS Specification to learn more about JMS objects.


getTopicConnection

public final javax.jms.TopicConnection getTopicConnection()
Returns the Producers's TopicConnection object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.TopicConnection

setTopicConnection

public final void setTopicConnection(javax.jms.TopicConnection topicConnection)
Sets the Producers's TopicConnection object.

See the JMS Specification to learn more about JMS objects.


getTopicSession

public final javax.jms.TopicSession getTopicSession()
Returns the Producers's TopicSession object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.TopicSession

setTopicSession

public final void setTopicSession(javax.jms.TopicSession session)
Sets the Producers's TopicSession object.

See the JMS Specification to learn more about JMS objects.


getTopicPublisher

public final javax.jms.TopicPublisher getTopicPublisher()
Returns the Producers's TopicPublisher object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.TopicPublisher

setTopicPublisher

public final void setTopicPublisher(javax.jms.TopicPublisher topicPublisher)
Sets the Producers's TopicPublisher object.

See the JMS Specification to learn more about JMS objects.

Returns:
javax.jms.TopicPublisher

setLoggingProducer

public final void setLoggingProducer(PubSubProducer producer)
Sets the Logging Producer associated to this producer which is simply another PubSubProducer that may be configured in the deployment document to publish messages published by this producer to a second "logging" destination.

See Also:
ProducerConfig

getLoggingProducer

public final PubSubProducer getLoggingProducer()
Returns the Logging Producer associated to this producer which is simply another PubSubProducer that may be configured in the deployment document to publish messages published by this producer to a second "logging" destination.

Returns:
PubSubProducer the "logging producer"
See Also:
ProducerConfig

stopPublisher

public final void stopPublisher()
Attempts to cleanly shutdown the Producer. This includes closing all JMS resources (TopicPublisher, TopicSession and TopicConnection). 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:
PubSubProducer.MonitorProducer

startPublisher

public final boolean startPublisher()
                             throws javax.jms.JMSException
Starts the producer making it ready to publish messages to the Topic 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:
PointToPointProducer.startProducer()

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

publishMessage

public final boolean publishMessage(javax.jms.Message aMessage)
                             throws javax.jms.JMSException
Publishes the message passed in to the Topic the producer is connected to. If an error occurs publishing the message the first time, the producer will be restarted and the producer will attempt to publish the message again. If it cannot successfully restart and re-publish the message, an exception will be thrown.

If the "logging producer" is started, the message will also be published to the Topic it is connected to.

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


Copyright © 2002, OpenEAI Software Foundation