Back to Notification Service Examples Page Back

Notification Example: Persistence

Description

The Persistence example provides a simple example of a persistent Notification Service client. The example illustrates the use of a persistent consumer in order to guarantee event delivery if the Notification Service consumer crashes. In order for persistence to be guaranteed, the QoS settings EventReliability and ConnectionReliability on the Notification Service channel must be set to Persistent.

Setting the EventReliabilty to Persistent means the event channel will store the events persistently until it has been sent to all proxy suppliers attached to the Notification Service. If one of the Consumers that is attached to a proxy supplier has crashed at the time the event arrived at its proxy then the proxy will realise the consumer is unavailable but keep trying to send the event. It will do this until the event is sent successfully.

The persistent consumer needs to be reactivated so that the proxy will know that it is available again to receive the events. The persistent consumer will then receive all the events that have been sent to it while it was inactive. If the Notification Service crashes with events in the channel destined for the consumer, when the Notification Service restarts the persistent consumer will also receive all the events.

This example consists of two components:

PersistentConsumer.java: The Persistent Consumer uses the simple push model to receive events from the event channel. The consumer checks on start up to see if it is the first time it has been started. If it is the first time it has started it creates a new consumer instance, otherwise it will reactivate itself.

The Persistent Consumer will perform the following tasks:

MyPushSupplier.java: The Supplier uses the simple push model to send events to the event channel. This is the same Supplier that is used in the Supplier-Consumer Using Push Model example. The MyPushSupplier will perform the following tasks:

How To Run This Example

  1. Make sure your PATH contains the bin directory of the JDK and the bin directory of the OpenFusion distribution.
  2. Make sure the appropriate ORB daemon is running.
  3. Start the Notification Service.

    From the command line:

    server -start NotificationService

    From the Administration Manager:

    Start the Administration Manager, right click on the NotificationService node and select Start from the pop-up menu.

  4. Start the Consumer:
    run com.prismt.cos.CosNotification.examples.Persistence.PersistentConsumer
  5. In a new window start the Supplier:
    run com.prismt.cos.CosNotification.examples.Persistence.MyPushSupplier
  6. To demonstrate that the consumer is persistent and will receive events sent after it has crashed, stop the consumer using Ctrl-C. Allow the supplier to continue to send events.
  7. Restart the Consumer:
    run com.prismt.cos.CosNotification.examples.Persistence.PersistentConsumer

    The consumer should receive all the events it has missed and continue to receive new events.

  8. Entering Ctrl-C in each window will stop the processes.

PrismTech TOP
Top