org.openeai.config
Class ConsumerConfig

java.lang.Object
  extended by org.openeai.OpenEaiObject
      extended by org.openeai.config.EnterpriseConfigurationObjectImpl
          extended by org.openeai.config.ConsumerConfig
All Implemented Interfaces:
EnterpriseConfigurationObject

public class ConsumerConfig
extends EnterpriseConfigurationObjectImpl
implements EnterpriseConfigurationObject

A ConsumerConfig is a wrapper class that takes information stored in an OpenEAI Deployment document (ConsumerConfig Element) and stores it in a Java object. Then the configuration object is passed to the constructor of the OpenEAI consumers and they are able to configure themselves with the information found in the config object.

Both PubSub and PointToPoint consumers use the same configuration information to initialize themselves. However, some items listed in a ConsumerConfig Element are only used by PubSubConsumers and some are only used by PointToPointConsumers. Where this is the case, it is noted.

Configuration Parameters:

These are the configuration parameters specified by the ConsumerConfig Element in the Deployment document. NOTE: Like all other OpenEAI configuration objects, there is a "container" level associated to ConsumerConfig objects. Many Elements and attributes are required at that level and may be optionally overridden at this level. This is to avoid having to enter redundant information in the Deployment document if all (or most) Consumers being configured should use the same configuration information. Therefore, many of the Consumer configuration parameters are optional at this level but required at the "container" level. Where this is the case, it will be indicated by an "*".

Many of the parameters specified for a consumer are simply JMS parameters required by the JMS Specification.

Name Required Description
name yes Name of the Consumer. This will be used in many logged messages as well as when creating durable subscriptions (in the case of PubSubConsumers). Therefore it should be unique.
startOnInitialization (true | false) no (defaults to false) Indicates whether or not this consumer should be "started" after it is initialized. For the purpose of Consumers, started means it has established it's connection to the Broker and is ready to receive messages.
transacted (true | false) no (defaults to false) Indicates whether or not messages consumed by this consumer should be treated as "transacted" or not. Transacted is defined by the JMS specification.
ConnectionFactoryName no* The name of the JMS Administered object (TopicConnectionFactory or QueueConnectionFactory) that this Consumer will use to initialize itself from a JMS perspective. To maintain broker independance, this administered object should be stored in a Directory server.
DestinationName yes The name of the JMS Administered object (Topic or Queue) that this Consumer will consume messages from. To maintain broker independance, this administered object should be stored in a Directory server.
InitialContextFactory no* The class name of the JNDI context factory that will be used to retrieve the JMS administered objects from a Directory Server or wherever the administered objects are stored.

Typically, this is "com.sun.jndi.ldap.LdapCtxFactory".

ProviderURL no* Location where the administered objects can be retrieved from. To maintain broker independance, this should reference a location in a Directory server.
SecurityPrincipal no* The user with which to create the InitialContext when retrieving the Administered objects.
SecurityCredentials no* The credentials associated to the user with which to create the InitialContext when retrieving the Administered objects.
Username no* Broker user with which to connect to the broker as. Generally, this is stored within the ConnectionFactory administered object so it is not needed here. However, if it isn't stored or you wish to override what's stored in the AO, you can specify that here.
Password no* Password associated to the broker user with which to connect to the broker as. Generally, this is stored within the ConnectionFactory administered object so it is not needed here. However, if it isn't stored or you wish to override what's stored in the AO, you can specify that here.
Commands yes Lists the Commands that this Consumer executes.
ConfigClass no* Name of the configuration class that wraps the config Element (this class)
ObjectClass yes Name of the Java object that will be instantiated with this Config class (currently, PointToPointConsumer or PubSubConsumer)
GenericResponse no* Contains information that the Consumer uses to initialize a generic response 'primed' document. This is only relevant to PointToPointConsumers and is only ever used if the Consumer has errors executing the Command associated to the JMS Message it consumes. In all other cases, the Commands themselves are responsible for returning the appropriate response to the calling application.
ThreadPoolConfig no* Contains information that the Consumer uses to initialize a ThreadPool object that it uses to process incomming messages. Depending on how this ThreadPool is configured (checkBeforeProcessing), the consumer may pause message consumption if the ThreadPool is busy and only continue when it has available Threads that can process jobs.
DbConnectionPoolConfig no* Contains information that PubSubConsumers use to initialize a EnterpriseConnectionPool object that they use to verify another PubSubConsumer is not already processing the message. This is called the PubSubMessageBalancer component. Since all PubSubConsumers consume each message delivered to a topic, there has to be a way to run muliple instances of a PubSubConsumer and ensure that only one consumer processes the message. This is the mechanism by which OpenEAI PubSubConsumers do this. NOTE: this is only relevant to PubSubConsumers.

Version:
3.0 - 28 January 2003
Author:
Tod Jackson (tod@openeai.org), Steve Wheat (steve@openeai.org)
See Also:
CommandConfig, ThreadPoolConfig, DbConnectionPoolConfig, PubSubMessageBalancer

Field Summary
 
Fields inherited from class org.openeai.OpenEaiObject
logger
 
Constructor Summary
ConsumerConfig()
          This is the constructor used by AppConfig to instantiate the config object.
ConsumerConfig(org.jdom.Element configElement)
           
ConsumerConfig(java.lang.String configDocUrl, java.lang.String consumerName)
           
 
Method Summary
 void addCommandConfig(java.lang.String name, CommandConfig cConfig)
          Adds a CommandConfig Java object to the list (HashMap) of CommandConfigs that this consumer will execute.
 CommandConfig getCommandConfig(java.lang.String name)
          Returns a specific CommandConfig Java object by name that will be used to initialize an actual Command object during Consumer initialization.
 java.util.HashMap getCommandConfigs()
          Returns the entire list (HashMap) of all CommandConfig objects assciated to this consumer.
 DbConnectionPoolConfig getDbConnectionPoolConfig()
          Returns the DbConnectionPoolConfig Java object associated to this consumer.
 ThreadPoolConfig getThreadPoolConfig()
          Returns the ThreadPoolConfig Java object associated to this consumer.
 void init(org.jdom.Element configElement)
          Implements the init(Element) method that all EnterpriseConfiguration objects must implement.
 void setDbConnectionPoolConfig(DbConnectionPoolConfig dbConfig)
          Sets the DbConnectionPoolConfig Java object associated to this consumer.
 void setThreadPoolConfig(ThreadPoolConfig tConfig)
          Sets the ThreadPoolConfig Java object associated to this consumer.
 
Methods inherited from class org.openeai.config.EnterpriseConfigurationObjectImpl
addProperty, getAppName, getConfigDoc, getConfigElementByAttributeValue, getElementByAttributeValue, getName, getType, getValidation, refresh, setAppName, setConfigDoc, setName, setRefresh, setType, setValidation
 
Methods inherited from class org.openeai.OpenEaiObject
getDebug, getFromAddr, getMailHost, getMailService, getProperties, getToAddr, initializeLog4j, initializeLog4j, initializeLog4j, setDebug, setFromAddr, setMailHost, setMailService, setProperties, setToAddr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openeai.config.EnterpriseConfigurationObject
getAppName, getProperties, refresh, setAppName
 

Constructor Detail

ConsumerConfig

public ConsumerConfig()
This is the constructor used by AppConfig to instantiate the config object. Then, AppConfig calls this object's init(Element) method passing the configuration element it retrieved from the XML configuration document which this object uses to configure itself. After this object has initialized itself, it will be used to instantiate and initialize the framework object (MessageObject, Producers, Consumers, ThreadPools etc.) with the properties it's been initialized with.


ConsumerConfig

public ConsumerConfig(java.lang.String configDocUrl,
                      java.lang.String consumerName)
               throws EnterpriseConfigurationObjectException
Throws:
EnterpriseConfigurationObjectException

ConsumerConfig

public ConsumerConfig(org.jdom.Element configElement)
               throws EnterpriseConfigurationObjectException
Throws:
EnterpriseConfigurationObjectException
Method Detail

getCommandConfigs

public java.util.HashMap getCommandConfigs()
Returns the entire list (HashMap) of all CommandConfig objects assciated to this consumer.

Returns:
HashMap of all CommandConfig Java objects.

addCommandConfig

public void addCommandConfig(java.lang.String name,
                             CommandConfig cConfig)
Adds a CommandConfig Java object to the list (HashMap) of CommandConfigs that this consumer will execute. As the ConsumerConfig reads and processes the consumer's Configuration Element it determines which commands this consumer may execute. For each one of those commands found, it instantiates and configures a CommandConfig Java object associated to that Command's configuration. Then, when the Consumer itself is initialized with this ConsumerConfig object, it will instantiate and initialize those commands that the consumer needs to know about.

Parameters:
name - String the name of the command being configured
cConfig - CommandConfig the CommandConfig Java object that has been initialized with information found in the Command's Configuration Element specified in the deployment document.
See Also:
CommandConfig

getCommandConfig

public CommandConfig getCommandConfig(java.lang.String name)
Returns a specific CommandConfig Java object by name that will be used to initialize an actual Command object during Consumer initialization.

Parameters:
name - String name of the command being configured.

setThreadPoolConfig

public void setThreadPoolConfig(ThreadPoolConfig tConfig)
Sets the ThreadPoolConfig Java object associated to this consumer. All consumers may execute their Commands in Threads by using the ThreadPool foundation object. The Configuration Element of a Consumer allows developers to specify how this threadpool should be configured. The ThreadPoolConfig Java object is a wrapper around that configuration Element. When the ConsumerConfigs's init method is called by AppConfig it retrieves this ThreadPool Configuration information and initializes the ThreadPoolConfig object with that information. Then, when the Consumer itself is initialized, it can use that ThreadPoolConfig Java object to initialize the ThreadPool Java object associated to the Consumer.

Parameters:
tConfig - ThreadPoolConfig the Java object that wraps the ThreadPoolConfig Element in the deployment document.
See Also:
ThreadPoolConfig, ThreadPoolImpl

getThreadPoolConfig

public ThreadPoolConfig getThreadPoolConfig()
Returns the ThreadPoolConfig Java object associated to this consumer. All consumers may execute their Commands in Threads by using the ThreadPool foundation object. The Configuration Element of a Consumer allows developers to specify how this threadpool should be configured. The ThreadPoolConfig Java object is a wrapper around that configuration Element. When the ConsumerConfigs's init method is called by AppConfig it retrieves this ThreadPool Configuration information and initializes the ThreadPoolConfig object with that information. Then, when the Consumer itself is initialized, it can use that ThreadPoolConfig Java object to initialize the ThreadPool Java object associated to the Consumer.

Returns:
ThreadPoolConfig the Java object that wraps the ThreadPoolConfig Element in the deployment document.
See Also:
ThreadPoolConfig, ThreadPoolImpl

setDbConnectionPoolConfig

public void setDbConnectionPoolConfig(DbConnectionPoolConfig dbConfig)
Sets the DbConnectionPoolConfig Java object associated to this consumer. PubSubConsumer's use a built in Message Balancer foundation component that allows them to determine if another Consumer is already processing a particular message. This balancer is currently implemented by persisting unique information to a table in a database. As PubSubConsumers consume messages, they consult this store to determine if the message they've consumed is already being processed by another consumer. This DbConnectionPoolConfig Java object wraps the DbConnectionPoolConfig Element found in the deployment document. It is associated to the PubSubConsumers and then when the consumers themselves are started, they use this Java object to initialized the EnterpriseConnectionPool foundation object associated to the consumer that will be used to balance PubSub messages.

Parameters:
dbConfig - DbConnectionPoolConfig to be associated to the PubSubMessageBalancer for this consumer.
See Also:
DbConnectionPoolConfig, EnterpriseConnectionPool, PubSubMessageBalancer

getDbConnectionPoolConfig

public DbConnectionPoolConfig getDbConnectionPoolConfig()
Returns the DbConnectionPoolConfig Java object associated to this consumer. PubSubConsumer's use a built in Message Balancer foundation component that allows them to determine if another Consumer is already processing a particular message. This balancer is currently implemented by persisting unique information to a table in a database. As PubSubConsumers consume messages, they consult this store to determine if the message they've consumed is already being processed by another consumer. This DbConnectionPoolConfig Java object wraps the DbConnectionPoolConfig Element found in the deployment document. It is associated to the PubSubConsumers and then when the consumers themselves are started, they use this Java object to initialized the EnterpriseConnectionPool foundation object associated to the consumer that will be used to balance PubSub messages.

Returns:
DbConnectionPoolConfig to be associated to the PubSubMessageBalancer for this consumer.
See Also:
DbConnectionPoolConfig, EnterpriseConnectionPool, PubSubMessageBalancer

init

public void init(org.jdom.Element configElement)
          throws EnterpriseConfigurationObjectException
Implements the init(Element) method that all EnterpriseConfiguration objects must implement. This init method takes the Configuration element passed in and pulls out configuration information specific to the Consumer (PubSub or PointToPoint) being initialized. Then it sets various instance variables and properties on itself which will be used by the Consumer when AppConfig instantiates it passing this configuration object. The Consumer will then use the configuration java object to initialize itself.

Specified by:
init in interface EnterpriseConfigurationObject
Overrides:
init in class EnterpriseConfigurationObjectImpl
Parameters:
configElement - Element the configuration element that AppConfig has pulled from the configuration document relevant to the Command being configured. Or, the element that was found in the init() method.
Throws:
EnterpriseConfigurationObjectException - if errors occur processing the configuration Element.
See Also:
PubSubConsumer, PointToPointConsumer


Copyright © 2002,2003 OpenEAI Software Foundation