cern::cmw::mom::test::Client Class Reference

Inheritance diagram for cern::cmw::mom::test::Client:
Inheritance graph
[legend]
Collaboration diagram for cern::cmw::mom::test::Client:
Collaboration graph
[legend]

List of all members.

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"

Detailed Description

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>

Constructor & Destructor Documentation

cern::cmw::mom::test::Client::Client (  )  [inline]

Member Function Documentation

static void cern::cmw::mom::test::Client::main ( String[]  args  )  [inline, static]

Method main

Parameters:
args 

References Client().

void cern::cmw::mom::test::Client::onException ( MOMException  e  )  [inline]
void cern::cmw::mom::test::Client::onMessage ( javax.jms.Message  message  )  [inline]
void cern::cmw::mom::test::Client::start (  )  [inline]

Method start

References s, cern::cmw::mom::pubsub::Subscriber::subscribe(), subscriptionToken, and TOPIC.

Referenced by Client().


Member Data Documentation

Referenced by Client(), onMessage(), and start().

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().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2