NonStop Software

Using the Event Service

Previous Topic | Next Topic | Contents | Index
Getting Started Guide | Administration Guide | Reference Guide

Subtopics

Implementing a Push Consumer
Implementing a Pull Consumer
Implementing a Push Supplier
Implementing a Pull Supplier

Once created, an event channel is available for use. Depending on the role of the process using an event channel, the preparation and processing steps vary. This section summarizes the required preparation steps prior to sending or receiving events and the event processing activity.

Implementing a Push Consumer

The push consumer implements the PushConsumer interface so it can receive method invocations from the event channel. The PushConsumer interface is specified in the file CosEventComm.idl. A class derived from PushConsumer provides implementations of the push( ) and disconnect_push_consumer( ) methods. The push consumer process implements a servant that hosts the PushConsumer object.

Preparation

At runtime, the following activities take place:

  1. Locate an event channel object to use
  2. Invoke the for_consumers( ) operation on it. This operation returns a ConsumerAdmin object.
  3. Since we are using the push model, invoke the obtain_push_supplier( ) operation on the ConsumerAdmin object. This operation returns a ProxyPushSupplier object.
  4. Using the ProxyPushSupplier object, invoke the connect_push_consumer( ) operation. This operation takes a PushConsumer object as an argument, which is the PushConsumer interface you created previously.

Processing

  1. push( ). The event channel invokes this method when a new event is available.
  2. disconnect_push_consumer( ). The event channel invokes this method if it needs to disconnect. The process can take the necessary actions to effect an orderly shutdown.

Implementing a Pull Consumer

The pull consumer can implement the PullConsumer interface, or it can act as only an event channel client. If it implements the PullConsumer interface it can receive the disconnect_pull_consumer( ) method invocation. The PullConsumer interface is specified in the file CosEventComm.idl. A class derived from PullConsumer provides an implementation of the disconnect_pull_consumer( ) method. The pull consumer process implements a servant that hosts the PullConsumer object.

If the pull consumer acts as only a client, it will not be able to receive disconnect_pull_consumer( ) requests from the event channel. However, it can pull events from the event channel.

Preparation

At runtime, the following activities take place:

  1. Locate an event channel object to use.
  2. Invoke the for_consumers( ) operation on it. This operation returns a ConsumerAdmin object.
  3. Since we are using the pull model, invoke the obtain_pull_supplier( ) operation on the ConsumerAdmin object. This operation returns a ProxyPullSupplier object.
  4. Using the ProxyPullSupplier object, invoke the connect_pull_consumer( ) operation. This operation takes a PullConsumer object as an argument. If you want to be notified when the event channel needs to disconnect your pull consumer, you must provide a PullConsumer interface as described later. If you do not want to be notified, pass NULL as the argument to connect_pull_consumer( ) method.

Processing

  1. Invoke the pull( ) method on the ProxyPullSupplier when a new event is required. The pull( )method returns only a when a new event is available.
  2. Invoke the try_pull( ) method on the ProxyPullSupplier when you want to get an event or determine that one is not yet available. The try_pull( ) method returns with an indication of whether or not an event is available. If an event is available, try_pull( ) returns the event as well.
  3. If the PullConsumer interface has been implemented, the event channel may invoke the disconnect_pull_consumer( ) method. When this method is invoked, it indicates that the pull consumer can no longer issue pull or try_pull( ) requests.

Implementing a Push Supplier

The push supplier can implement the PushSupplier interface, or it can act as only an event channel client. If it implements the PushSupplier interface, it can receive the disconnect_push_supplier( ) method invocation. The PushSupplier interface is specified in the file CosEventComm.idl. A class derived from PushSupplier provides an implementation of the disconnect_pull_consumer( ) method. The push supplier process implements a servant that hosts the PushSupplier object.

If the push supplier acts only as a client, it will not be able to receive disconnect_push_supplier( ) requests from the event channel. However it can push events to the event channel.

Preparation

At runtime the following activities take place:

  1. Locate an event channel object to use.
  2. Invoke the for_suppliers( ) operation on it. This operation returns a SupplierAdmin object.
  3. Since we are using the push model, invoke the obtain_push_consumer( ) operation on the SupplierAdmin object. This operation returns a ProxyPushConsumer object.
  4. Using the ProxyPushConsumer object, invoke the connect_push_supplier( ) operation. This operation takes a PushSupplier object as an argument. If you want to be notified when the event channel needs to disconnect your supplier you must provide a PushSupplier interface as described later. If you do not want to be notified, pass NULL as the argument to connect_push_supplier( ).

Processing

  1. To push an event, first construct the event in an any variable. The any variable can describe an arbitrary data structure to be sent to the event channel. Then invoke the push operation on the ProxyPushConsumer.
  2. If the PushConsumer interface has been implemented, the event channel may invoke the disconnect_push_supplier( ) method. When this method is invoked it indicates that the push supplier can no longer push events to the event channel.

Implementing a Pull Supplier

The pull supplier implements the PullSupplier interface so it can receive method invocations from the event channel. The PullSupplier interface is specified in the file CosEventComm.idl. A class derived from PullSupplier provides implementations of the pull( ), try_pull( ) and disconnect_pull_supplier( ) methods. The pull supplier process implements a servant that hosts the PullSupplier object.

Preparation

At runtime, the following activities take place:

  1. Locate an event channel object to use.
  2. Invoke the for_suppliers( ) operation on it. This operation returns a SupplierAdmin object.
  3. Since we are using the pull model, invoke the obtain_pull_consumer( ) operation on the SupplierAdmin object. This operation returns a ProxyPullConsumer object.
  4. Using the ProxyPullConsumer object, invoke the connect_pull_supplier( ) operation. This operation takes a PullSupplier object as an argument, which is the PullSupplier interface you created previously.

Processing

  1. pull( ) The event channel invokes this method when an event is needed. You need to construct an event in a any variable. The event is returned as the value of the pull( ) method. When a try_pull( ) request arrives, the try_pull( ) method should either supply an event or indicate that no event is available.
  2. try_pull( ) The event channel invokes this method when it wants to determine if an event is available. If an event is available, it is returned as the value of the try_pull( ) method and the has_event variable is set to true. If no event is available, the has_event variable is set to false and a void any value is returned from the try_pull( ) method.
  3. disconnect_pull_supplier( ) The event channel invokes this method to indicate that the pull supplier will no longer receive pull or try_pull( ) requests.

      Previous Topic | Next Topic | Contents | Top
      Getting Started Guide | Administration Guide | Reference Guide
      Bibliography | Glossary | Index
      © Tandem, a division of Compaq. All rights reserved. Legal notices.