Back to Notification Service Examples Page Back

Notification Service Example: News

Description

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

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.java: 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.java: 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.java: 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.java: The weatherman is interested in all news concerning weather.

This example uses two generic IDL interfaces (defined in News.idl): Broadcaster and Listener. The interfaces are then implemented to create instances of Broadcasters (stock market and weather station) and Listeners (the analyst and weatherman).

In the Notification Service, the proxies the Listeners are attached to also have filters attached to them. These filters only allow events through that are of a certain type and filter out all other events passed over the channel that are not of this type.

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

Using the Notification Service

How To Run This Example

  1. Start the Notification Service.
  2. If using an ORB which requires persistent POAs to be registered before they can be activated, ensure that the OpenFusion.NotificationNewsAnalyst, OpenFusion.NotificationNewsWeatherMan, OpenFusion.NotificationNewsStockQuote, and OpenFusion.NotificationNewsWeatherStation POAs are registered.
  3. Run the stock market Analyst program at the command prompt as follows:
    run com.prismt.cos.CosNotification.examples.News.Analyst

    The Analyst Program should display "Creating Consumer...Success" upon successful execution of the program. The Analyst program will then wait for events to come across the channel (which is the reason why it appears to be doing nothing).

  4. Run the WeatherMan program at a new command prompt as follows:
    run com.prismt.cos.CosNotification.examples.News.WeatherMan

    The WeatherMan program, like the stock market Analyst program, will display "Creating Consumer...Success" upon successful execution of the program. The WeatherMan program will then await events from the channel.

  5. Run the StockQuote program at a new command prompt as follows:
    run com.prismt.cos.CosNotification.examples.News.StockQuote

    This program will display the message, "Ready to broadcast events. Press enter to start..." upon successful execution. Pressing enter will initiate the transmission of stock quotes over the channel. These will then be received by the Analyst. The StockQuote program will send messages indefinitely.

  6. Finally, we need to run the WeatherStation program. To do this, open a new command-prompt window and type:
    run com.prismt.cos.CosNotification.examples.News.WeatherStation

    Again, the program should display "Ready to broadcast events. Press enter to start..." upon successful execution. Press enter to start sending events over the event channel to be received by the WeatherMan. The WeatherStation program will send messages indefinitely.


PrismTech TOP
Top