Using the CORBA Notification Service
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
This topic includes the following sections:
Note: The BEA Tuxedo CORBA Java client and BEA Tuxedo CORBA Java client ORB were deprecated in Tuxedo 8.1 and are no longer supported in Tuxedo 9.0.
All BEA Tuxedo CORBA Java client and BEA Tuxedo CORBA Java client ORB text references, associated code samples, etc. should only be used:
Technical support for third party CORBA Java ORBs should be provided by their respective vendors. BEA Tuxedo does not provide any technical support or documentation for third party CORBA Java ORBs.
The Introductory sample applications simulate a newsroom environment in which a news reporter posts a story and a news subscriber consumes the story.
One implementation of the Introductory sample application is provided: the C++ programming language that uses the BEA Simple Events application programming interface (API). The Introductory sample application consists of the Reporter and Subscriber applications and the Notification Service. The Reporter application implements a client application that prompts the user to enter news articles, and then posts the news articles as events to the BEA Tuxedo CORBA Notification Service. The Subscriber application implements a joint client/server application that acts as client when it subscribes and unsubscribes for events, and acts as a server when it receives events. To receive events, the subscriber implements a callback object which is invoked by the Notification Service when an event needs to be delivered.
The Introductory sample application shows the simplest usage of the Notification Service. It demonstrates how to use the BEA 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 Building the Advanced Sample Application.
This Introductory sample application provides two executables (see Figure 5-1):
Figure 5-1 Introductory Sample Application Components
The 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.
Note: The "News category" is just a string that the Reporter user and the Subscriber user agree on. There are no fixed categories in this sample. Therefore, both the Reporter user and the Subscriber user must type the same string when prompted for a category (including case and white space).
To run this sample, you must start at least one Reporter application and at least one Subscriber application; however, you may run multiple Reporters and Subscribers. Events posted by any Reporter will be delivered to all matching Subscribers (based on "News category").
Also, be sure to start any subscribers before posting events; otherwise, the events will be lost.
To build and run the Introductory sample application, you must perform these steps:
These steps are described in detail in the following sections.
Before 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.
The directory path where you installed the BEA Tuxedo software. For example: |
To verify that the information for the environment variables defined during installation is correct, perform the following steps:
To change the settings, perform the following steps:
ksh prompt>export TUXDIR=
directorypath
csh> setenv TUXDIR=directorypath
You need to copy the files for the Introductory sample application and files in the common directory into a work directory on your local machine.
Note: The application directory and the common directory must be copied to the same parent directory.
The files are located in the following directories:
For the C++ Introductory sample:drive:\tuxdir
\samples\corba\notification\introductory_simple_cxx
drive:\tuxdir
\samples\corba\notification\common
For the C++ Introductory sample:/usr/local/tuxdir
/samples/corba/notification/
introductory_simple_cxx/usr/local/tuxdir
/samples/corba/notification/common
You 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 BEA Simple Events API.
Table 5-3 lists other files that the Introductory sample application uses.
During the installation of the BEA Tuxedo CORBA software, the sample application files are marked read-only. Before you can edit or build the files in the Introductory sample application, you need to change the protection attribute of the files you copied into your work directory, as follows:
On UNIX systems, you also need to change the permission of setenv.ksh
to give execute permission to the file, as follows:
ksh prompt>chmod +x setenv.ksh
To set up the environment, enter the following command:
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:
setenv.cmd
) has been run. If the environment variables have not been set, the makefile prints an error message to the screen and exits.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.Before executing the makefile
, you need to check the following:
nmake
is in the path of your machine.make
is in the path of your machine.To build the Introductory sample application, enter the make
command as follows:
To start the Introductory sample application, enter the following commands:
TMSUSREVT
TMNTS
A BEA Tuxedo Notification Service server that processes requests for subscriptions and event postings.
TMNTSFWD_T
A BEA Tuxedo Notification Service server that forwards events to subscribers that have transient subscriptions.
ISL
To use the Introductory sample application, you must use the Subscriber application to subscribe to an event and the Reporter application to post an event. Be sure to subscribe before you post each event; otherwise, events will be lost.
Note: The Subscriber application shuts down after it receives one event.
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".)
You may type in any string for the news category; that is, there is no fixed list of news categories. However, when you use the Reporter application to post an event, make sure to specify the same string for the news category.
Note: You should always use the Subscriber application to subscribe to events before you use the Reporter application to post events; otherwise, events will be lost.
"."
) on a line, followed by a carriage return.Subscribers whose category matches the category of this story will receive, and print out the story. When a subscriber receives a story, the subscriber automatically shuts down.
(e)
option.Note: The Subscriber application shuts down after it receives one event. Therefore, always use the Subscriber application to subscribe to events before you use the Reporter application to post an event; otherwise, events will be lost.
Note: Make sure the Reporter and Subscriber processes have stopped.
![]() ![]() |
![]() |
![]() |