• The Introductory sample application shows the simplest usage of the Notification Service. It demonstrates how to use the Oracle Simple Events API, the CosNotification API, transient subscriptions, and transient object references. It does not demonstrate the use of persistent subscriptions or data filtering. For a sample application that uses persistent subscriptions and data filtering, see Chapter 6, “Building the Advanced Sample Application.”Figure 5‑1 Introductory Sample Application ComponentsThe event poster, the Reporter application, uses the structured event domain_name, type_name, and filterable_data fields to construct the event. The domain name defines the industry. In this application, domain_name is set to “News”. The type_name defines the kind of event in the industry and it is set to the category of news story (for example, “Sports”). The application user specifies this value. In the filterable_data fields, a field named “Story” is added, which contains the text of the news story being posted. This text is also specified by the application user.The Subscriber application uses the structured event domain_name and type_name fields to create a subscription to the Notification Service. The subscription defines the domain_name as a fixed string with the content of “News”. At run time, the Subscriber application queries the user for the “News Category” and uses the input to define the type_name field in the subscription. Obviously, the users of both applications, the reporter and the subscriber, must collaborate on the “News Category” string for the subscription to match an event, otherwise, no events will be delivered to the subscriber. The subscription does not do any checking of the filterable_data field, but rather assumes that the body of the story will be a string, and that the story will be in the first Named/Value pair in the filterable_data field of a structured event.To post events, the Reporter application uses the push_structured_event method to push news events to the Notification Service. For each event, the Reporter application queries the user for a “News category” (for example, “Sports”) and a story (a multiple-line text string).To subscribe to news events, the Subscriber application invokes the Notification Service to subscribe to news events. For each subscription, the Subscriber application queries the user for a “News category” (for example, “Sports”). The Subscriber application also implements a callback object (via the NewsConsumer_i servant class) which is used to receive and process news events. When the Subscriber subscribes, it gives the Notification Service a reference to this callback object. When a matching event occurs; that is, when the Reporter posts an event with a “News category” that matches the news category of the subscription, the Notification Service invokes the push_structured_event method on the callback object to deliver the event to the callback object in the subscriber. This method prints out the event, invokes the unsubscribe method on the Notification Service to cancel the subscription, and shuts down the Subscriber. For simplicity, the push_structured_event method assumes that the domain_name, type_name, length, and name field match and the story is in the value field.
1. Verify that the "TUXDIR" environment variable are set to the correct directory path.
2. Unset “JAVA_HOME”
5. For UNIX, ensure the make file is in your path. For Microsoft Windows, ensure the nmake file is in your pathBefore you build and run the Introductory sample application, you need to ensure that the TUXDIR environment variable is set on your system. In most cases, this environment variable is set as part of the installation procedure. However, you need to check the environment variables to ensure they reflect correct information.Table 5‑1 lists the environment variables required to run the Introductory sample application.
5. Check the setting for TUXDIRksh prompt>export TUXDIR=directorypathcsh> setenv TUXDIR=directorypath
Note: For the C++ Introductory sample:
drive:\tuxdir\samples\corba\notification\introductory_simple_cxx
drive:\tuxdir\samples\corba\notification\commonFor the C++ Introductory sample:
/usr/local/tuxdir/samples/corba/notification/
introductory_simple_cxx
/usr/local/tuxdir/samples/corba/notification/commonYou use the files listed in Table 5‑2 and Table 5‑3 to build and run the C++ Introductory sample application, which is implemented using the Oracle Simple Events API.
Table 5‑3 lists other files that the Introductory sample application uses.
The following files are needed only for the application that was developed using CosNotification Service API.
1. In a DOS window, change (cd) to your work directory.
2.
3. On UNIX systems, you also need to change the permission of setenv.ksh to give execute permission to the file, as follows:You use the make command to run makefiles, which are provided for Microsoft Windows and UNIX, to build the sample application. For UNIX, use make. For Microsoft Windows, use nmake.The makefile automates the following steps:
1. Checks that the set environment command (setenv.cmd) has been run. If the environment variables have not been set, the makefile prints an error message to the screen and exits.
2. Includes the common.nt (for Microsoft Windows) or common.mk (for UNIX) command file. This file defines the makefile symbols used by the samples. These symbols allow the UNIX and Microsoft Windows makefiles to delegate the build rules to platform-independent makefiles.
3. Includes the makefile.inc command file. This file builds the is_reporter and is_subscriber executables, and cleans up the directory of unneeded files and directories.
4. Includes the introductory.inc command file. This file creates the UBBCONFIG file and executes the tmloadcf -y ubb command to create the TUXCONFIG file. This is a platform-independent makefile fragment that defines the administrative build rules common to the Introductory sample application.Before executing the makefile, you need to check the following:
• On Microsoft Windows, verify that nmake is in the path of your machine.
• On UNIX, verify that make is in the path of your machine.To build the Introductory sample application, enter the make command as follows:
•
• For C++: prompt>is_subscriberTo start another Subscriber, open another window, change (cd) to your work directory, set the environment variables (by running setenv.cmd or setenv.ksh), and enter the start command that is appropriate for your platform.For C++: prompt>is_reporterTo start another Reporter, open another window, change (cd) to your work directory, set the environment variables (by running setenv.cmd or setenv.ksh), and enter the start command that is appropriate for your platform.
1. When you start the Subscriber application (prompt>is_subscriber), the following prompts are displayed:Name? (Enter a name (without spaces).)
Category (or all)? (Enter the category of news you want or "all".)
1. When you start the Reporter application (prompt> is_reporter), the following prompts are displayed:
2. Enter r to report news. The following prompt is displayed:
4. Enter your story. It can span multiple lines. Finish the story by typing a period only (".") on a line, followed by a carriage return.