|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmoos.ssds.jms.SubscriberComponent
SubscriberComponent provides an easy to use class that handles JMS publish-subscribe messaging. The goal of this is to povide messsaging without requiring the developer to use JMS api's
Here's an example of code using a SubscriberComponent
import ssds.portal.*;
public class Subscriber1 {
SubscriberComponent sc;
SensorDataPacketListener listener = new SensorDataPacketListener();
public Subscriber1(String topicName) {
sc = new SubscriberComponent(topicName, listener);
}
public static void main(String[] args) {
try {
Subscriber1 sub = new Subscriber1(args[0]);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
Note: I tried overriding the finalize() method to close the
TopicConnection when the class was no longer used. However, the
garbage collector would call the finalize() method at seemingly random times.
Causing the program to cease. Moving the close() call out of the finalize()
method stopeed this problem.
The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement. This information should not be published or distributed to third parties without specific written permission from MBARI.
| Field Summary | |
protected javax.naming.Context |
jndiContext
This the the naming Context that will be used to look up the JMS related servcies. |
protected javax.jms.Message |
message
A dummy message |
protected javax.jms.TopicConnection |
topicConnection
This is the TopicConnection to the JMS server |
protected javax.jms.TopicConnectionFactory |
topicConnectionFactory
This is the JMS TopicConnectionFactory that is used to get the topic connection for this subscriber |
protected java.lang.String |
topicname
The topic name that this SubscriberComponent will subscribe to |
protected javax.jms.TopicSession |
topicSession
This is the TopicSession that will be used to listen and process messages coming from JMS |
protected javax.jms.TopicSubscriber |
topicSubscriber
This is the TopicSubscriber obtained from the JMS server |
| Constructor Summary | |
SubscriberComponent(java.lang.String topicName,
javax.jms.MessageListener messageListener)
Constructor |
|
| Method Summary | |
void |
close()
Closes the topic connection. |
javax.jms.MessageListener |
getMessageListener()
Accessor for the MessageListener |
java.lang.String |
getTopicname()
Accessor for the topic name |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.String topicname
protected javax.naming.Context jndiContext
protected javax.jms.TopicConnectionFactory topicConnectionFactory
protected javax.jms.TopicSession topicSession
protected javax.jms.TopicConnection topicConnection
protected javax.jms.Message message
protected javax.jms.TopicSubscriber topicSubscriber
| Constructor Detail |
public SubscriberComponent(java.lang.String topicName,
javax.jms.MessageListener messageListener)
topicName - The name of the topic to subscribe to. For JBoss this
needs to be "topic/someTopic" whereas most other J2EE servers would
use "someTopic"messageListener - The MessageListener to be used to
handle the message.| Method Detail |
public javax.jms.MessageListener getMessageListener()
SubscriberComponentpublic java.lang.String getTopicname()
SubscriberComponent is
subscribed to.public void close()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||