public interface Subscriber
Two kinds of exception are thrown :
This example shows a simple subscription to a topic:
try {
s = PubSubFactory.subscriber();
} catch (MOMException momEx) { ... }
try {
subToken = s.subscribe("CMW.DEVICES.PowerConverter.PC1.Current", listener, selector);
// ...
s.unSubscribe(subToken);
s.close();
}
catch (JMSException jmsEx) { ... }
catch (NamingException namingEx) { ... }
where listener is an instance of a class
implementing the SubscriptionListener interface method void onMessage(Message m) and
selector is an optional String defining
a message selector.Publisher,
SubscriptionListener,
PubSubFactory,
NotificationHelper,
MappingService| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the publisher singleton instance and dealloacate any resource.
|
void |
setExceptionListener(ExceptionListener listener)
Set the listener for exceptions handling
|
long |
subscribe(java.lang.String topic,
SubscriptionListener listener,
java.lang.String selector)
Subscribe to the given topic.
|
void |
unSubscribe(long subscriptionToken)
Close the subscription identified by the subscriptionToken.
|
void |
unSubscribeAll()
Close all the opened subscriptions.
|
void setExceptionListener(ExceptionListener listener)
listener - The exceptions listenervoid close()
long subscribe(java.lang.String topic,
SubscriptionListener listener,
java.lang.String selector)
throws JMSException,
javax.naming.NamingException
topic - The String representation of the topiclistener - An instance of a class implementing the SubscriptionListener interfaceselector - The String representation of the filter. May be null.JMSException - if JMS fails to subscribe due to some internal JMS error.javax.naming.NamingException - if there is a violation in the namespace policy.void unSubscribe(long subscriptionToken)
throws JMSException
subscriptionToken - The subscription identifierJMSException - if JMS fails to unsubscribe due to some internal JMS error.void unSubscribeAll()
throws JMSException
JMSException - if JMS fails to unsubscribe due to some internal JMS error.