Free High Performance CORBA Notification Service from AT&T Laboratories |
omniORB Home AT&T Research |
Back to Documentation Home Page
Event consumers receive events from an event channel they are connected with, without any knowledge of the suppliers of those events. omniNotify supports both push and pull event communication for consumers of events. Push consumers have to implement a push operation which is invoked by the event channel when the channel has events to forward to these consumer. On the other hand, pull consumers can retrieve events from the channel by invoking a pull operation on the proxy objects they are connected with.
The event messages sent to a push consumer by an event channel or requested from an event channel by a pull consumer belong to one of three categories:
To develop event consumer applications, you must implement these consumers as normal CORBA applications that communicate with event channels through the CORBA Notification Service IDL interfaces. These IDL definitions are supplied with omniNotify.
In the remainder of this document we will present two example event consumer applications. Both of these applications use CosNotification::StructuredEvent messages, and they differ in the event communication model they implement; one is a push consumer and the other is a pull consumer. In both applications, the following steps have to be executed before any event communication takes place:
Our consumer implements the CosNotifyComm::StructuredPushConsumer interface. This is done by inheriting from the corresponding skeleton class, which is generated by the IDL compiler, and implementing all abstract methods defined in this class. Obtaining a reference to an event channel, creating or using an existing administrative object, creating a new proxy object, and connecting the consumer to the proxy is done in the way presented in the development of a supplier application. The complete listing of the push consumer application is presented below.
// -*- Mode: C++; -*- #include
<iostream.h> class StructuredPushConsumer_i : ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) CORBA::ORB_var orb =
CORBA::ORB_init(argc, argv, "omniORB2"); // Register the consumer object with the undelying ORB consumer->_obj_is_ready(boa); // Obtain reference to the CORBA Naming Service and resolve 'EventChannel' name_service =
orb->resolve_initial_references("NameService"); // Create new ConsumerAdmin and proxy objects, and connect the consumer cadmin = channel->new_for_consumers( // Inform the BOA that we are ready to receive events/callbacks from the event channel boa->impl_is_ready(0, 1); // Wait until at least numEvents are pushed -- sleep 5 seconds between checks while ( consumer->get_num_events()
< numEvents ) // No more events to be consumed. Disconnect the consumer and destroy the admin object
prx_supl->disconnect_structured_push_supplier(); return 0; |
Our consumer implements the CosNotifyComm::StructuredPullConsumer interface. This is done by inheriting from the corresponding skeleton class, which is generated by the IDL compiler, and implementing all abstract methods defined in this class. Obtaining a reference to an event channel, creating or using an existing administrative object, creating a new proxy object, and connecting the consumer to the proxy is done in the way presented in the development of a supplier application. The complete listing of the pull consumer application is presented below.
// -*- Mode: C++; -*- #include
<iostream.h> class StructuredPullConsumer_i : ////////////////////////////////////////////////////////////////////////// int main(int argc, char** argv) CORBA::ORB_var orb =
CORBA::ORB_init(argc, argv, "omniORB2"); // Register the consumer object with the undelying ORB consumer->_obj_is_ready(boa); // Obtain reference to the CORBA Naming Service and resolve 'EventChannel' name_service =
orb->resolve_initial_references("NameService"); // Create new ConsumerAdmin and proxy objects, and connect the consumer cadmin = channel->new_for_consumers( // Inform the BOA that we are ready to receive events/callbacks from the event channel boa->impl_is_ready(0, 1); // Pull numEvents structured events from the channel for ( CORBA::Long ix = 0; ix <
numEvents; ix++ ) {
// No more events to be consumed. Disconnect the consumer and destroy the admin object
prx_supl->disconnect_structured_pull_supplier(); return 0; |
Back to Documentation Home Page
For comments, feedback, etc, please see the 'Keep in touch' page. |