Notification Service Example: News

Description

This example uses a simple Notification Service Push model to broadcast and receive "news" across the event channel.

Synopsis

The news consists of stock market updates and weather reports for certain regions. There are people listening for this news, namely a weatherman and a stock market analyst.

StockQuote: The stock market sends real-time news across the channel of share information for companies. The news consists of the company name and the change in share price for that company.

Analyst: There is a stock market analyst who is interested in stock market news. However, the analyst is a busy man and he is only interested in important news (that is, news with a high priority).

WeatherStation: The weather station broadcasts news about weather changes around the country. The news consists of a region and the current weather in that region.

WeatherMan: The weatherman is interested in all news concerning weather.

Design

This example uses structured push suppliers (stock market and weather station) and structured push consumers (the analyst and weatherman). The consumer-side proxies have filters attached to them, only allowing events through that are of a certain type and filtering out all other events passed over the channel that are not of this type.

The example uses a single event channel and the following classes:

Below is a diagram of how the example uses the Notification Service.

Using the Notification Service

How to Build This Example

UNIX

These instructions are based on the Solaris gcc3.2 compiler makefiles.

  1. Ensure that the following environment variables are set:
  2. Ensure that your environment is set up for your compiler and linker. For example, for gcc3.2:

    PATH=/usr/local/gcc-3.2/bin:/usr/ccs/bin:$PATH; export PATH

    LD_LIBRARY_PATH=/usr/local/gcc-3.2/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

  3. Change to the <TAO install dir>/examples/cc directory.
  4. If you have not done so already, enter the make command to run the makefile. This will compile all of the OpenFusion examples.

Windows NT

  1. Set the environmental property TAO_ROOT=<TAO install dir> where <TAO install dir> is the location into which you have installed TAO.
  2. A global example Microsoft Visual C++ project has been provided. This is called <TAO install dir>\examples\examples.sln. Double-click on the project file to load it into Microsoft Visual C++. For each of the projects lised below, change the project from debug mode to release mode using the Build | Configuration Manager menu option.
  3. Build the OFCommon files.
  4. Build the OFNotificationNewsExample files.
  5. Build the stockquote files.
  6. Build the weatherstation files.
  7. Build the analyst files.
  8. Build the weatherman files.

How to Run This Example

UNIX: Ensure that the environment variable LD_LIBRARY_PATH includes the path to where the common files and the News files were compiled:

LD_LIBRARY_PATH=<TAO install dir>/examples/cc/Common:<TAO install dir>/examples/cc/Notification/news:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH

Windows NT: Start a DOS window. Ensure that your path contains:

<TAO install dir>\bin;<TAO install dir>\examples\cc\bin

  1. Ensure that the Notification Service is running. In order to run the OpenFusion Notification Service you must first install the OpenFusion TCS - JacORB with OpenFusion CORBA Services distribution. This can be obtained from the downloads page by following the OpenFusion CORBA Products software link.

  2. Run the stock market Analyst program at the command prompt as follows:
    analyst -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    where OF_INSTALL_DIR is the OpenFusion TCS - JacORB with OpenFusion CORBA Services installation directory.

    The Analyst program will display "Waiting to receive events", and will then wait for events to come across the channel.

  3. Run the WeatherMan program at a new command prompt as follows:
    weatherman -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    where OF_INSTALL_DIR is the OpenFusion TCS - JacORB with OpenFusion CORBA Services installation directory.

    The WeatherMan program, like the stock market Analyst program, will display "Waiting to receive events" and will then await events from the channel.

  4. Run the stock market StockQuote program at a new command prompt as follows:
    stockquote -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    where OF_INSTALL_DIR is the OpenFusion TCS - JacORB with OpenFusion CORBA Services installation directory.

    The StockQuote program will send 100 stock quotes over the channel. These will be received by the Analyst if they are of sufficiently high priority (>5).

  5. Run the WeatherStation program at a new command prompt as follows:
    weatherstation -ORBInitRef NotificationService=file://<OF_INSTALL_DIR>/domains/OpenFusion/localhost/NotificationService/NotificationSingleton/NotificationSingleton.ior

    where OF_INSTALL_DIR is the OpenFusion TCS - JacORB with OpenFusion CORBA Services installation directory.

    The WeatherStation will send 100 weather reports over the channel. These will be received by the WeatherMan.

top
[top]


© PrismTech Limited 2002