![]() |
![]() |
![]() |
![]() |
![]() |
Table 3‑1 outlines the development process for creating Notification Service applications.
Table 3‑1 Development Process The design of events is basic to any notification service. The design impacts not only the volume of information that is delivered to matching subscriptions, but the efficiency and performance of the Notification Service as well. Therefore, careful planning should be done to ensure that your Notification Service will be able to handle your needs now and allow for future growth. For a discussion of event design, see “Designing Events” on page -6.This development step is illustrated in Listing 3‑1. Listing 3‑1 is based on the Notification Service sample applications that use the Oracle Simple Events API.To get the event channel factory object reference, the resolve_initial_references method is invoked on the Bootstrap object using the "Tobj_SimpleEventsService" environmental object. The object reference is used to get the channel factory, which is in turn is used to get the event channel. Listing 3‑1 show code examples in C++.Listing 3‑1 Getting the Event Channel (C++)// Get the Simple Events channel factory object reference.
CORBA::Object_var channel_factory_oref =
bootstrap.resolve_initial_references(
"Tobj_SimpleEventsService");
Tobj_SimpleEvents::ChannelFactory_var channel_factory =
Tobj_SimpleEvents::ChannelFactory::_narrow(
channel_factory_oref.in());
// Use the channel factory to get the default channel.
Tobj_SimpleEvents::Channel_var channel =
channel_factory->find_channel(
Tobj_SimpleEvents::DEFAULT_CHANNEL);Listing 3‑2 show how this is implemented in C++. To report news to the events channel, this application executes the following steps:
3. Uses the push_structured_event operation to post the event to the Notification Service.Listing 3‑2 Creating and Posting the Event (C++)
• Implement a CosNotifyComm OMG IDL interface that supports the push_structured_event operation.In order for the callback object to receive events, it must implement the CosNotifyComm::StructuredPushConsumer interface that supports the push_structured_event operation. When an event occurs that has a matching subscription, the Notification Service invokes this operation on the callback object to push the event to the subscriber application.The CosNotifyComm::StructuredPushConsumer interface also defines the operations offer_change and disconnect_structured_push_consumer. The Notification Service never invokes these operations, so you should implement stubbed out versions that throw CORBA::NO_IMPLEMENT.Listing 3‑3 and Listing 3‑4 show how this interface is implemented in C++.Listing 3‑3 Sample CosNotifyComm::StructuredPushConsumer Interface Implementation (NewsConsumer_i.h)Listing 3‑4 Sample CosNotifyComm::StructuredPushConsumer Interface Implementation (NewsConsumer_i.cpp)This step is the same for event posters and event subscribers. For a discussion of this step, see “Implementing the CosNotifyComm::StructuredPushConsumer Interface” on page -5.For a complete description of the BEAWrapper Callbacks object and its methods, see the Joint Client/Servers chapter in the CORBA Programming Reference.pay attention to”BEAWrapper”
Note: Using the BEAWrapper Callback object to create a callback object is discussed below. For a discussion of how to implement a callback object using the POA, see Using CORBA Server-to-Server Communication.Listing 3‑5 show show to use the BEAWrapper Callbacks object to create a callback object in C++. In the code examples, the NewsConsumber_i servant is created and the start_transient method is used to create a transient object reference.Listing 3‑6 from the Introductory sample application, show how to create a transient subscription in C++.
2.
3. Create the subscription. The subscription sets the domain_name, type_name, and data_filter (optional), the Quality of Service (QoS), and supplies the object reference to the subscriber’s callback object to the Notification Service.Listing 3‑6 Creating a Transient Subscription (C++)
Note: Listing 3‑7, which show code in the Advanced sample application in C++, illustrates the coding steps required to create a persistent subscription to the Notification Service. The steps required to create a persistent subscription are the same as those required to create a transient subscription, as described previously.
Note: While the code examples shown here assume that the news_consumer callback object has a persistent object reference, you can also create persistent subscriptions with transient callback object references. For a discussion of transient versus persistent callback object references, see Table 2‑3.If a method in the server portion of a joint client/server application invokes ORB::shutdown(), all server activity stops and control is returned to the statement after ORB::run() is invoked in the server portion of the joint client/server application. Only under this condition does control return to the client functionality of the joint client/server application.To generate the client stub and skeleton files, you must execute the idl command for each of the Notification IDL files that your application uses. Table 3‑2 shows the idl commands used for each type of subscriber.
Table 3‑2 idl Command Requirements The following is an example of an idl command:Table 3‑3 lists the IDL files required by each type of Notification Service application that uses the Oracle Simple Events Interface.
CosEventComm.idl CosNotification.idl CosNotifyComm.idl Tobj_Events.idl Tobj_SimpleEvents.idl CosEventComm.idl CosNotification.idl CosNotifyComm.idl Tobj_Events.idl Tobj_SimpleEvents.idlThe build procedure differs depending on the type of Notification Service application you are building. Table 3‑4 provides an overview of the commands and types of files used to build each type of the Notification Service application.
Table 3‑4 Application Build Requirements Use the buildobjclient command to compile the application files and the IDL stubs. Use the buildobjclient command with the -P option to compile the application files and the IDL stubs. Use the buildobjserver command to compile the application files and the IDL client stubs. Use the buildobjclient command with the -P option to compile the application files, the IDL stubs, the IDL skeletons, and link with the BEAWrapper library. Use the buildobjserver command to compile the application files, the IDL stubs, and the IDL skeletons.Listing 3‑8 shows the commands used for a C++ poster application (Reporter.cpp) on a Microsoft Windows system. To form a C++ executable, the idl command is run on the required IDL file and the buildobjclient command compiles the C++ client application file and the IDL stubs.Listing 3‑9 and Listing 3‑10 show the commands used for a C++ subscriber application (Subscriber.cpp) on Microsoft Windows and UNIX respectively. To form a C++ executable, the buildobjclient command, with the -P option, compiles the joint client/server application files (Subscriber.cpp and NewsConsumer_i.cpp), the IDL stubs, and the IDL skeleton (CosNotifyComm_s.cpp).