|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.connectors.jms.JMSConsumerBase
org.osesb.connectors.jms.JMSTopicReceiver
public class JMSTopicReceiver
This descendant of JMSConsumerBase is a blocking, Topic receiver.
An instance of a JMSTopicReceiver is associated with a particular JMS Destination. The JMS Session object is cached (but can be reset) and JMSTopicReceiver(s) can be pooled. See the org.osesb.objectpools package for JMS producer and consumer pools. Instances of JMSTopicReceiver are constructed with a org.osesb.configuration.JMSClientConfiguration, which contains properties for creating a JMS connection. JMSTopicReceiver implements Topic-specific methods for JMS message consumers.
| Field Summary | |
|---|---|
protected javax.jms.Topic |
topic
The Topic for this JMS client. |
protected javax.jms.TopicConnection |
topicConnection
The TopicConnection for this JMS client. |
protected javax.jms.TopicSession |
topicSession
The TopicSession for this JMS client. |
| Fields inherited from class org.osesb.connectors.jms.JMSConsumerBase |
|---|
connectionStarted, dateTimeOfLastMessage, dateTimeServiceStarted, heartbeatInterval, jmsClientConfiguration, jmsMessage, log, messageID, messageText, MIN_HEARTBEAT_INTERVAL, numberOfMessagesReceived, session, thisClassName |
| Constructor Summary | |
|---|---|
JMSTopicReceiver(JMSClientConfiguration jmsClientConfiguration)
Creates a new instance of JMSTopicReceiver and starts JMS. |
|
JMSTopicReceiver(JMSClientConfiguration jmsClientConfiguration,
javax.jms.Topic topic)
Creates a new instance of JMSTopicReceiver and starts JMS using the specified Topic. |
|
| Method Summary | |
|---|---|
protected void |
checkSession()
Checks the TopicSession and restarts JMS connection, if required. |
void |
close()
Release JMS resources. |
void |
createDurableSubscription()
Uses the <durableSubscriptionID>, <clientID>,
<generateUniqueClientID>, and <deleteSubscriptionOnClose>
JMSClientConfiguration elements to create a durable subscription, as follows:
<durableSubscriptionID> is required.
Either <clientID> or <generateUniqueClientID> must
be configured.
If <clientID> is set, then it's value is used as the
JMS ClientID for the connection. |
javax.jms.Connection |
getConnection()
Returns the JMS Connection for this JMS client. |
javax.jms.Destination |
getDestination()
Returns the JMS Destination for this JMS client. |
java.lang.String |
getDestinationName()
Returns the name of the JMS Destination for this JMS client. |
protected void |
logConsumerStartupMessage()
Logs a JMS startup message for JMS consumers. |
protected void |
logMessage(java.lang.String logMessage)
Log the message. |
static void |
main(java.lang.String[] args)
main() -- for testing |
javax.jms.Message |
receiveJMSMessage()
Receive a JMS Message using the configured Topic; waits for a message indefinitely. |
javax.jms.Message |
receiveJMSMessage(long receiveTimeoutMilliseconds,
java.lang.String messageSelector)
Receive a JMS Message using the configured Topic. |
void |
removeDurableSubscription()
|
protected javax.jms.Message |
retryReceiveJMSMessage(long receiveTimeoutMilliseconds,
java.lang.String messageSelector)
Retry receiving a message using the configured Topic. |
void |
startJMS()
Initialize JMS objects according to JMSClientConfiguration and start the connection. |
| Methods inherited from class org.osesb.connectors.jms.JMSConsumerBase |
|---|
checkJMSConnection, consumerStartupMessage, finalize, getDateTimeOfLastMessage, getDateTimeServiceStarted, getHeartbeatInterval, getJMSClientConfiguration, getNumberOfMessagesReceived, getSession, isConnectionStarted, onException, onMessage, run, setNumberOfMessagesReceived, setSession |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected javax.jms.TopicConnection topicConnection
protected javax.jms.TopicSession topicSession
protected javax.jms.Topic topic
| Constructor Detail |
|---|
public JMSTopicReceiver(JMSClientConfiguration jmsClientConfiguration)
throws java.lang.Exception
jmsClientConfiguration - The JMSClientConfiguration object to use for this JMS client.
java.lang.Exception - if constructed with a null JMSClientConfiguration.
public JMSTopicReceiver(JMSClientConfiguration jmsClientConfiguration,
javax.jms.Topic topic)
throws java.lang.Exception
jmsClientConfiguration - The JMSClientConfiguration object to use for this JMS client.topic - The Topic to start the JMS connection for.
java.lang.Exception - if constructed with a null JMSClientConfiguration.| Method Detail |
|---|
public void createDurableSubscription()
throws java.lang.Exception
<durableSubscriptionID>, <clientID>,
<generateUniqueClientID>, and <deleteSubscriptionOnClose>
JMSClientConfiguration elements to create a durable subscription, as follows:
<durableSubscriptionID> is required.<clientID> or <generateUniqueClientID> must
be configured.<clientID> is set, then it's value is used as the
JMS ClientID for the connection. <clientID> takes
precedence over <generateUniqueClientID>.<generateUniqueClientID> is true and <clientID>
is not set, then a unique JMS ClientID is set for the connection.
If a unique JMS ClientID is configured for the connection, then the
subscription is automatically removed (deleted) when the connection
is closed.
java.lang.Exception - if a durable subscription cannot be created.
public void removeDurableSubscription()
throws java.lang.Exception
java.lang.Exception - if a durable subscription cannot be removed.
public javax.jms.Message receiveJMSMessage()
throws java.lang.Exception
receiveJMSMessage in class JMSConsumerBasejava.lang.Exception - if a general is error encountered.
public javax.jms.Message receiveJMSMessage(long receiveTimeoutMilliseconds,
java.lang.String messageSelector)
throws java.lang.Exception
receiveJMSMessage in class JMSConsumerBasereceiveTimeoutMilliseconds - receive timeout in milliseconds.
If receiveTimeout > 0, then the receiver waits for a message for
the specified amount of time, otherwise, the receiver waits for
a message indefinitely.messageSelector - The JMS messageSelector.
java.lang.Exception - if a general is error encountered.
protected javax.jms.Message retryReceiveJMSMessage(long receiveTimeoutMilliseconds,
java.lang.String messageSelector)
throws java.lang.Exception
receiveTimeoutMilliseconds - receive timeout in milliseconds.
If receiveTimeout > 0, then the receiver waits for a message for
the specified amount of time, otherwise, the receiver waits for
a message indefinitely.messageSelector - The JMS messageSelector.
java.lang.Exception - if a general is error encountered.public java.lang.String getDestinationName()
getDestinationName in class JMSConsumerBasepublic javax.jms.Connection getConnection()
getConnection in class JMSConsumerBasepublic javax.jms.Destination getDestination()
getDestination in class JMSConsumerBaseprotected void logMessage(java.lang.String logMessage)
logMessage in class JMSConsumerBaselogMessage - The message to log.public void startJMS()
startJMS in class JMSConsumerBaseprotected void logConsumerStartupMessage()
protected void checkSession()
throws java.lang.Exception
checkSession in class JMSConsumerBasejava.lang.Exception - if there was a problem getting a TopicSession.public void close()
close in class JMSConsumerBasepublic static void main(java.lang.String[] args)
args - commandline arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||