|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.openeai.OpenEaiObject
org.openeai.jms.consumer.MessageConsumer
public abstract class MessageConsumer
The ancestor class for PubSub and PointToPoint consumers. These are the counterparts to OpenEAI MessageProducers. These classes (PubSub and PointToPoint Consumers) consume and potentially respond to messages sent by OpenEAI MessageProducers (PointToPoint and PubSub Producers)
ConsumerConfig,
MessageProducer| Nested Class Summary | |
|---|---|
protected class |
MessageConsumer.MessageTransaction
This is the class that is used to execute the SyncCommand associated to a message consumed by the Consumer. |
| Field Summary | |
|---|---|
protected int |
_maxThreadPoolShutdownWaitTime
|
protected static java.lang.String |
CONNECTED
|
protected static java.lang.String |
DISCONNECTED
|
protected static java.lang.String |
INITIALIZED
|
protected java.util.HashMap |
m_commandConfigs
|
protected java.util.Vector |
m_inProcessMessages
|
protected java.util.HashMap |
m_messages
|
protected int |
m_numThreads
|
protected java.lang.String |
m_password
|
protected boolean |
m_startOnInitialization
|
protected ThreadPool |
m_threadPool
|
protected java.lang.String |
m_userName
|
protected static java.lang.String |
NOT_INITIALIZED
|
protected static java.lang.String |
STARTED
|
protected static java.lang.String |
STOPPED
|
| Fields inherited from class org.openeai.OpenEaiObject |
|---|
logger |
| Constructor Summary | |
|---|---|
MessageConsumer()
|
|
| Method Summary | |
|---|---|
void |
addCommandConfig(java.lang.String name,
CommandConfig cConfig)
Adds a CommandConfig Java object to the list of Commands associated to this consumer. |
void |
addSyncCommand(java.lang.String commandName,
java.lang.String className)
Adds an initialized SyncCommand object to the list of SyncCommands that might be executed by this Consumer. |
boolean |
consumptionStopped()
This is the method each consumer calls whenever they consume a message to see if they can continue to consume messages. |
java.lang.String |
getAbsoluteCommandName()
Returns the name of the Absolute command that should be executed by this consumer NO MATTER what the COMMAND_NAME JMS Property might be. |
CommandConfig |
getCommandConfig(java.lang.String name)
Returns a CommandConfig Java object from the list of ConsumerCommands associated to this consumer by name. |
ConsumerConfig |
getConfig()
Returns the ConsumerConfig object associated to this Consumer. |
java.lang.String |
getConnectionFactoryName()
Returns the connection factory name (QueueConnectionFactory or TopicConnectionFactory) that this Consumer should retrieve and use to initialize its connection to the broker with. |
java.lang.String |
getConsumerName()
Returns the name of this consumer as specified in the Consumer's configuration information. |
java.lang.String |
getConsumerStatus()
Returns the current status of the Consumer. |
java.lang.String |
getDefaultCommandName()
Returns the name of the Default command that should be executed if a Message consumed does not have a COMMAND_NAME JMS Property associated to it. |
java.lang.String |
getDestinationName()
Returns the destination name (Queue or Topic) that this Consumer should connect to and consume from. |
org.jdom.Document |
getGenericErrorDoc()
Returns the generic response document that this consumer should use to reply to incomming requests if it has problems executing the command associated to the request consumed. |
protected javax.naming.directory.DirContext |
getInitialContext()
Establishes an InitialContext to be used by the calling application to retrieve ConnectionFactories and Destination objects via JNDI. |
java.lang.String |
getInitialContextFactory()
Returns 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. |
java.lang.String |
getInitializationStatus()
Returns the initialization status of the consumer. |
java.lang.String |
getInstanceName()
Returns the instance name of this consumer. |
int |
getMaximumThreadPoolShutdownWaitTime()
Returns the maximum amount of time the consumer will wait for the thread pool to empty itself. |
java.lang.String |
getPassword()
Returns the broker user password that should be used when establishing a connection with the broker. |
java.lang.String |
getProviderUrl()
Returns the location where the administered objects can be retrieved from. |
java.lang.String |
getSecurityCredentials()
Returns the LDAP security credentials (password) this consumer should use when connecting to the directory server to retrieve JMS administered objects (ConnectionFactories and Destinations). |
java.lang.String |
getSecurityPrincipal()
Returns the LDAP security principal this consumer should use when connecting to the directory server to retrieve JMS administered objects (ConnectionFactories and Destinations). |
boolean |
getStartOnInitialization()
Returns a boolean indicating whether or not this consumer should be started (connected to the broker and ready to consume messages) when it is initialized. |
protected SyncCommand |
getSyncCommand(java.lang.String commandName)
Returns a SyncCommand from the HashMap of SyncCommands supported by this Consumer. |
ThreadPool |
getThreadPool()
Returns the ThreadPool object that will be used by this Consumer to execute ConsumerCommands in. |
boolean |
getTransacted()
Returns the JMS property indicating whether or not this consumer operates in transacted mode or not. |
java.lang.String |
getUserName()
Returns the broker user name that should be used when establishing a connection with the broker. |
protected void |
handleSync(int messageNumber,
javax.jms.Message aMessage)
Default SyncCommand execution routine. |
protected void |
init(java.util.Properties props)
Takes the Properties object contained within the ConsumerConfig object passed to the constructor of this consumer and sets all the appropriate instance variables on this consumer during initialization. |
void |
initializeConsumer()
Calls the initSyncCommands() method that will retrieve all SyncCommands from the ConsumerConfig object passed to the constructor and initialize those commands making them available for use. |
protected void |
initSyncCommands()
Iterates through all SyncCommands that were listed in the CommandConfig objects associated to this Consumer in its deployment document and instantiates those SyncCommands by calling the addSyncCommand method. |
boolean |
isStarted()
Returns a boolean that indicates whether or not the consumer is started. |
void |
setAbsoluteCommandName(java.lang.String name)
Sets the name of the Absolute command that should be executed by this consumer NO MATTER what the COMMAND_NAME JMS Property might be. |
void |
setCommandConfigs(java.util.HashMap cConfigs)
Sets the HashMap of CommandConfigs to the value passed in. |
void |
setConfig(ConsumerConfig config)
Sets the ConsumerConfig object associated to this Consumer. |
void |
setConnectionFactoryName(java.lang.String name)
Sets the connection factory name (QueueConnectionFactory or TopicConnectionFactory) that this Consumer should retrieve and use to initialize its connection to the broker with. |
void |
setConsumerName(java.lang.String name)
Sets the name of this consumer as specified in the Consumer's configuration information. |
void |
setConsumerStatus(java.lang.String status)
Sets the current status of the Consumer. |
void |
setDefaultCommandName(java.lang.String name)
Sets the name of the Default command that should be executed if a Message consumed does not have a COMMAND_NAME JMS Property associated to it. |
void |
setDestinationName(java.lang.String name)
Sets the destination name (Queue or Topic) that this Consumer should connect to and consume from. |
void |
setGenericErrorDoc(org.jdom.Document doc)
Sets the generic response document that this consumer should use to reply to incomming requests if it has problems executing the command associated to the request consumed. |
void |
setInitialContextFactory(java.lang.String in)
Sets 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. |
void |
setInitializationStatus(java.lang.String status)
Sets the initialization status of the consumer. |
void |
setInstanceName(java.lang.String instanceName)
Sets the instance name of this consumer. |
void |
setMaximumThreadPoolShutdownWaitTime(int maxWaitTime)
Sets the maximum amount of time (in milliseconds) that the consumer will wait for the ThreadPool to empty when the consumer's shutdown hook is triggered. |
void |
setPassword(java.lang.String in)
Sets the broker user password that should be used when establishing a connection with the broker. |
void |
setProviderUrl(java.lang.String in)
Sets the location where the administered objects can be retrieved from. |
void |
setSecurityCredentials(java.lang.String credentials)
Sets the LDAP security credentials (password) this consumer should use when connecting to the directory server to retrieve JMS administered objects (ConnectionFactories and Destinations). |
void |
setSecurityPrincipal(java.lang.String principal)
Sets the LDAP security principal this consumer should use when connecting to the directory server to retrieve JMS administered objects (ConnectionFactories and Destinations). |
void |
setStartOnInitialization(boolean start)
Sets a boolean indicating whether or not this consumer should be started (connected to the broker and ready to consume messages) when it is initialized. |
void |
setThreadPool(ThreadPool tPool)
Sets the ThreadPool object that will be used by this Consumer to execute ConsumerCommands in. |
void |
setTransacted(boolean trans)
Sets the JMS property indicating whether or not this consumer operates in transacted mode or not. |
void |
setUserName(java.lang.String in)
Sets the broker user name that should be used when establishing a connection with the broker. |
abstract void |
stop()
This method should process any pending jobs that are currently in progress and then disconnect this Consumer from the broker. |
void |
stopConsumption()
Puts the consumer in a state that will prohibit it from consuming any more messages. |
| Methods inherited from class org.openeai.OpenEaiObject |
|---|
getAppName, getDebug, getFromAddr, 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 |
| Field Detail |
|---|
protected java.util.HashMap m_messages
protected java.lang.String m_userName
protected java.lang.String m_password
protected java.util.HashMap m_commandConfigs
protected static java.lang.String STOPPED
protected static java.lang.String STARTED
protected static java.lang.String DISCONNECTED
protected static java.lang.String CONNECTED
protected static java.lang.String NOT_INITIALIZED
protected static java.lang.String INITIALIZED
protected ThreadPool m_threadPool
protected int m_numThreads
protected int _maxThreadPoolShutdownWaitTime
protected boolean m_startOnInitialization
protected java.util.Vector m_inProcessMessages
| Constructor Detail |
|---|
public MessageConsumer()
| Method Detail |
|---|
public final void setMaximumThreadPoolShutdownWaitTime(int maxWaitTime)
The default value for this is 15000 (15 seconds).
maxWaitTime - public final int getMaximumThreadPoolShutdownWaitTime()
public final void setDefaultCommandName(java.lang.String name)
name - String name of the default command as specified in the Command's
configuration object in the gateway's deployment document.CommandConfig.isDefault()public final java.lang.String getDefaultCommandName()
CommandConfig.isDefault()public final void setAbsoluteCommandName(java.lang.String name)
name - String name of the absolute command as specified in the Command's
configuration object in the gateway's deployment document.CommandConfig.isAbsolute()public final java.lang.String getAbsoluteCommandName()
CommandConfig.isAbsolute()public final void setConsumerName(java.lang.String name)
name - String name of the consumer.public final java.lang.String getConsumerName()
public final java.lang.String getInstanceName()
public final void setInstanceName(java.lang.String instanceName)
instanceName - String the consumer's instance name.public final void setSecurityPrincipal(java.lang.String principal)
principal - String the LDAP principalConsumerConfigpublic final java.lang.String getSecurityPrincipal()
ConsumerConfigpublic final void setSecurityCredentials(java.lang.String credentials)
credentials - String the LDAP credentialsConsumerConfigpublic final java.lang.String getSecurityCredentials()
ConsumerConfigpublic final void setGenericErrorDoc(org.jdom.Document doc)
doc - org.jdom.DocumentConsumerConfigpublic final org.jdom.Document getGenericErrorDoc()
ConsumerConfigpublic final java.lang.String getConsumerStatus()
public final void setConsumerStatus(java.lang.String status)
status - String the status of the consumer.public final boolean isStarted()
public final void stopConsumption()
public final boolean consumptionStopped()
Both PubSub and PointToPoint consumers check to see if consumption has been stopped each time they consume a message.
public final void setTransacted(boolean trans)
See JMS Specification for details regarding JMS and transactions.
trans - boolean true means the consumer is transacted false means it is not.public final boolean getTransacted()
See JMS Specification for details regarding JMS and transactions.
public final void addCommandConfig(java.lang.String name,
CommandConfig cConfig)
name - String name of the ConsumerCommand that will be initialized with the CommandConfig objectcConfig - CommandConfig the CommandConfig object that holds initialization information
for the Command that will be instantiated and executed by the Consumer.CommandConfig,
ConsumerCommand,
RequestCommand,
RequestCommandImpl,
SyncCommand,
SyncCommandImplpublic final CommandConfig getCommandConfig(java.lang.String name)
name - String name of the Command that will be initialized with the CommandConfig object
CommandConfig,
ConsumerCommand,
RequestCommand,
RequestCommandImpl,
SyncCommand,
SyncCommandImplpublic final void setCommandConfigs(java.util.HashMap cConfigs)
cConfigs - HashMappublic final boolean getStartOnInitialization()
ConsumerConfigpublic final void setStartOnInitialization(boolean start)
ConsumerConfigpublic final void setConfig(ConsumerConfig config)
config - ConsumerConfig the ConsumerConfig Java object that has been built
from contents of the deployment document for the gateway being started.public final ConsumerConfig getConfig()
public final void setDestinationName(java.lang.String name)
See JMS Specification for a description of Destinations.
name - String the destination (Queue or Topic) name.ConsumerConfigpublic final java.lang.String getDestinationName()
See JMS Specification for a description of Destinations.
ConsumerConfigpublic final void setConnectionFactoryName(java.lang.String name)
See JMS Specification for a description of Connection Factories.
name - String name of the Connection Factory.ConsumerConfigpublic final java.lang.String getConnectionFactoryName()
See JMS Specification for a description of Connection Factories.
ConsumerConfigpublic final java.lang.String getInitializationStatus()
public final void setInitializationStatus(java.lang.String status)
public final void setThreadPool(ThreadPool tPool)
This ThreadPool is configured in the ConsumerConfig Element of the gateway's deployment document and is passed to the Consumer as part of the ConsumerConfig Java object.
tPool - org.openeai.threadpool.ThreadPoolThreadPool,
ConsumerConfig,
ThreadPoolConfigpublic final ThreadPool getThreadPool()
This ThreadPool is configured in the ConsumerConfig Element of the gateway's deployment document and is passed to the Consumer as part of the ConsumerConfig Java object.
ThreadPool,
ConsumerConfig,
ThreadPoolConfigpublic final void setUserName(java.lang.String in)
in - String broker user nameConsumerConfigpublic final java.lang.String getUserName()
ConsumerConfigpublic final void setPassword(java.lang.String in)
in - String broker user nameConsumerConfigpublic final java.lang.String getPassword()
ConsumerConfigpublic final void setProviderUrl(java.lang.String in)
in - String the URL that resolves to the location of the JMS Administered Objects
(ConnectionFactories and Destinations).ConsumerConfigpublic final java.lang.String getProviderUrl()
ConsumerConfigpublic final void setInitialContextFactory(java.lang.String in)
Typically, this is com.sun.jndi.ldap.LdapCtxFactory.
in - String initial context factory class name.ConsumerConfigpublic final java.lang.String getInitialContextFactory()
Typically, this is com.sun.jndi.ldap.LdapCtxFactory.
ConsumerConfig
protected javax.naming.directory.DirContext getInitialContext()
throws javax.naming.NamingException
javax.naming.NamingException
protected SyncCommand getSyncCommand(java.lang.String commandName)
throws java.io.IOException
It will use the "COMMAND_NAME" JMS Property from the message to retrieve that SyncCommand from its list.
commandName - String the name of the SyncCommand to find (COMMAND_NAME property on the JMS Message)
java.io.IOException - if a SyncCommand with the specified name cannot be found.
public void initializeConsumer()
throws javax.jms.JMSException
This method is extended by the PointToPoint Consumer because it also needs to initialize RequestCommands.
javax.jms.JMSException - if errors occur initializing the SyncCommands.initSyncCommands(),
PointToPointConsumer.initializeConsumer()
public final void addSyncCommand(java.lang.String commandName,
java.lang.String className)
throws javax.jms.JMSException
It is here that the determination is made wether or not the command is the "default" or "absolute" command based on information found in the CommandConfig object associated to the Command.
commandName - String name of the commandclassName - String class name of the command that should be instantiated and
initialized as specified in the CommandConfig Element/Java object
javax.jms.JMSExceptionCommandConfig,
ConsumerConfig,
ConsumerCommand,
RequestCommand,
RequestCommandImpl,
SyncCommand,
SyncCommandImplpublic abstract void stop()
protected void initSyncCommands()
throws javax.jms.JMSException
javax.jms.JMSException - if errors occur initializing the SyncCommandsaddSyncCommand(String, String)
protected void handleSync(int messageNumber,
javax.jms.Message aMessage)
throws javax.jms.JMSException
The method will look for a JMS String property called "COMMAND_NAME". If the property is found, it will execute the SyncCommand associated to that name. This property is automatically set by the OpenEAI Message Object API (MOA) foundation when a message is sent using an organization's MOA implementation (a business object).
If an "Absolute" command has been associated to the consumer, it will execute that command implementation NO MATTER what.
If no COMMAND_NAME is found on the Message passed in and there has been a "Default" command associated to the consumer, it will execute that command implementation.
If no COMMAND_NAME property exists and there has been no "Default" or "Absolute" command associated to this consumer, an error will occur.
If a COMMAND_NAME property DOES exist but it doesn't map to a known command implementation and no "Absolute" command has been specified, an error will occur.
messageNumber - int a message number managed by the consumer (the number of messages consumed by the consumer).aMessage - Message the JMS Message consumed by the consumer.
javax.jms.JMSException - if errors occur executing the Command. Note, this should be a very
rare occurrence because Commands are generally responsible for handling their own errors.
The most common place where an exception might be thrown by a command is if it
had problems retrieving the data from the Message passed to it. Otherwise, the Command
should either publish a Sync-Error or return an Error to the requesting application depending
on the type of command being executed (RequestCommand vs. SyncCommand)
protected void init(java.util.Properties props)
throws java.io.IOException
props - Properties the Java properties object retrieved from the ConsumerConfig
object built from the ConsumerConfig Element in the gateway's deployment document.
java.io.IOException - if errors occur populating the instance variables from the
Properties object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||