Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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

void main (String[] args)

Private Attributes

Subscriber s = null
long subscriptionToken = 0

Static Private Attributes

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]
 

Constructor Client


Member Function Documentation

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

Method main

Parameters:
args 

void cern::cmw::mom::test::Client::onException MOMException  e  )  [inline]
 

Method onException

Parameters:
e 

Implements cern::cmw::mom::pubsub::ExceptionListener.

void cern::cmw::mom::test::Client::onMessage javax.jms.Message  message  )  [inline]
 

Method onMessage

Parameters:
message 

void cern::cmw::mom::test::Client::start  )  [inline]
 

Method start


Member Data Documentation

Subscriber cern::cmw::mom::test::Client::s = null [private]
 

long cern::cmw::mom::test::Client::subscriptionToken = 0 [private]
 

final String cern::cmw::mom::test::Client::TOPIC = "CMW.ALARM_SYSTEM.ALARM_CATEGORY_TREE.CERN.INSTANT" [static, private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:08:04 2009 for ACS Java API by doxygen 1.3.8