

Public Member Functions | |
| Client () | |
| void | start () |
| void | onMessage (javax.jms.Message message) |
| void | onException (MOMException e) |
Static Public Member Functions | |
| static void | main (String[] args) |
Private Attributes | |
| Subscriber | s = null |
| long | subscriptionToken = 0 |
Static Private Attributes | |
| static final String | TOPIC = "CMW.ALARM_SYSTEM.ALARM_CATEGORY_TREE.CERN.INSTANT" |
This example shows how to setup a simple client subscribing to a topic. This code shows how to get a Subscriber instance :
<blockquote>
try {
s = PubSubFactory.subscriber();
} catch (MOMException me) {
System.out.println("MOMException raised while instantiating a Subscriber");
me.printStackTrace();
}
</blockquote>
And this shows how to implement the onMessage() method for a SubscriptionListener:
<blockquote>
public void onMessage(javax.jms.Message message) {
// Subscriber implementation of the listener
try {
javax.jms.TextMessage msg = (javax.jms.TextMessage)message;
System.out.println("Got message : " + msg.getText());
if (msg.getText().equals("bye")) {
System.out.println("Time to close!");
s.unSubscribe(subscriptionToken);
s.close();
}
} catch(javax.jms.JMSException je) {
System.out.println("JMSException raised while processing message: "+message);
je.printStackTrace();
}
}
</blockquote>
| cern::cmw::mom::test::Client::Client | ( | ) | [inline] |
Constructor Client
References s, cern::cmw::mom::pubsub::Subscriber::setExceptionListener(), and start().
Referenced by main().
| static void cern::cmw::mom::test::Client::main | ( | String[] | args | ) | [inline, static] |
| void cern::cmw::mom::test::Client::onException | ( | MOMException | e | ) | [inline] |
Method onException
| e |
Implements cern::cmw::mom::pubsub::ExceptionListener.
References cern::cmw::mom::pubsub::MOMException::testException().
| void cern::cmw::mom::test::Client::onMessage | ( | javax.jms.Message | message | ) | [inline] |
Method onMessage
| message |
References cern::cmw::mom::pubsub::Subscriber::close(), s, subscriptionToken, and cern::cmw::mom::pubsub::Subscriber::unSubscribe().
| void cern::cmw::mom::test::Client::start | ( | ) | [inline] |
Method start
References s, cern::cmw::mom::pubsub::Subscriber::subscribe(), subscriptionToken, and TOPIC.
Referenced by Client().
Subscriber cern::cmw::mom::test::Client::s = null [private] |
Referenced by Client(), onMessage(), and start().
long cern::cmw::mom::test::Client::subscriptionToken = 0 [private] |
Referenced by onMessage(), and start().
final String cern::cmw::mom::test::Client::TOPIC = "CMW.ALARM_SYSTEM.ALARM_CATEGORY_TREE.CERN.INSTANT" [static, private] |
Referenced by start().
1.6.2