Back to Notification Service Examples Page
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.
OpenFusion.NotificationNewsAnalyst
,
OpenFusion.NotificationNewsWeatherMan
,
OpenFusion.NotificationNewsStockQuote
,
and OpenFusion.NotificationNewsWeatherStation
POAs are registered.
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).
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.
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.
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.