|Previous Contents Index Next|
|iPlanet Messaging and Collaboration Event Notification Service Manual|
Chapter 1 Introduction to Event Notification Service
This chapter provides an overview of the iPlanet Event Notification Service (ENS) components, architecture, and Application Programming Interfaces (APIs).
This chapter contains these sections:
Event Notification Service Overview
Event Notification Service Overview
The Event Notification Service (ENS) is iPlanet's underlying publish-and-subscribe service available in the following iPlanet products:
iPlanet Calendar Server, Release 5.0 and laterENS acts as a dispatcher used by iPlanet applications as a central point of collection for certain types of events that are of interest to them. Events are changes to the value of one or more properties of a resource. In this structure, a URI (Uniform Resource Identifier) represents an event. Any application that wants to know when these types of events occur registers with ENS, which identifies events in order and matches notifications with subscriptions. Event examples include:
Event Notification Service provides a server and APIs for publishers and subscribers. A publisher makes an event available to the notification service; and a subscriber tells the notification service that it wants to receive notifications of a specific event. See "Event Notification Service API Overview" for more information on the ENS APIs.
ENS in iPlanet Calendar Server
By default, ENS is enabled in iPlanet Calendar Server. For iPlanet Calendar Server you do not need to do anything else to use ENS.
A user who wants to subscribe to notifications other than the alarms generated by iPlanet Calendar Server needs to write a subscriber.
There is sample ENS C publisher and subscriber code bundled with iPlanet Calendar Server. See "iPlanet Calendar Server Sample Code" for that code.
Sample iPlanet Calendar Server code is provided with the product in the following directory:
ENS in iPlanet Messaging Server
ENS and iBiff (the ENS publisher for iPlanet Messaging Server, also referred to as the notification plug-in to iPlanet Messaging Server) are bundled in iPlanet Messaging Server. However, by default, they are not enabled.
To subscribe to notifications in iPlanet Messaging Server, you need to first perform the following two items on the iPlanet Messaging Server host:
A user who wants to subscribe to iPlanet Messaging Server notifications needs to write a subscriber to the ENS API. To do so, the subscriber needs to know what the various iPlanet Messaging Server notifications are. See Chapter 5 "iPlanet Messaging Server Specific Information" for that information.
iPlanet Messaging Server comes bundled with sample ENS C publisher and subscriber code. See "iPlanet Messaging Server Sample Code" for more information.
Sample iPlanet Messaging Server code is provided with the product in the following directory:
Event references identify an event handled by ENS. Event references use the following URI syntax (as specified by RFC 2396):
scheme is the access method, such as http, imap, ftp, or wcap.In general, all iPlanet Calendar Server events start with the following:
authority is the DNS domain or hostname that controls access to the resource.
The iPlanet Messaging Server notification plug-in iBiff uses the following scheme and resource by default:
iPlanet Calendar Server Event Reference Example
The following is an example event reference URI to subscribe to all event alarms with a calendar ID of jac:
iPlanet Messaging Server Event Reference Example
The following is an example event reference that requests a subscription to all NewMsg events for a user whose user ID is blim:
When using ENS with iPlanet Messaging Server, the user id you specify is case sensitive.
ENS Connection Pooling
The connection pooling feature of ENS enables a pool of subscribers to receive notifications from a single event reference. For every event, ENS chooses one subscriber from the pool to send the notification to. Thus, only one subscriber in the pool receives the notification. The ENS server balances sending of notifications among the subscribers. This enables the client to have a pool of subscribers that work together to receive all notifications from a single event reference.
For example, if notifications are being published to the event reference enp://127.0.0.1/store, a subscriber will normally subscribe to this event reference to receive notifications. To have a pool of subscribers receive all the notifications to this event reference, each subscriber in the pool only needs to subscribe to the event reference enp+pool://127.0.0.1/store instead. The ENS server chooses one subscriber from the pool to send the notification to.
Multiple Pool Extension
Connection pooling can support multiple pools of subscribers. That is, you can have two pools of subscribers, each pool receiving all the notifications from the event reference. The syntax of the event reference for the subscriber is:
where poolid is a string using only base64 alphabet. (See RFC1521, Table 1, for what the base64 alphabet contains.) So, for example, to have two pools of subscribers to the event reference enp://127.0.0.1/store, each pool could subscribe to the following event references:
enp+pool.1://127.0.0.1/store --> for first pool of subscribers enp+pool.2://127.0.0.1/store --> for second pool of subscribers
Event Notification Service Architecture
On the Solaris platform, ENS runs as a daemon, enpd, along with other iPlanet daemons in various calendar or messaging server configurations, to collect and dispatch events that occur to properties of resources. On the Windows NT platform, ENS runs as a service, enpd.exe.
For ENS, an event is a change that happens to a resource, while a resource is an entity such as a calendar or inbox. For example, adding an entry to a calendar (the resource) generates an event, which is stored by ENS. This event can then be subscribed to, and a notification would then be sent to the subscriber.
The ENS architecture enables the following three things to occur:
Notification - This is a message that describes an event occurrence. Sent by the event publisher, it contains a reference to the event, as well as any additional parameter/value pairs added to the URI, and optional data (the payload) used by the event consumers, but opaque to the notification service. Whoever is interested in the event can subscribe to it.
Subscription - This is a message sent to subscribe to an event. It contains an event reference, a client-side request identifier, and optional parameter/value pairs added to the URI. The subscription applies to upcoming events (that is, a subscriber asks to be notified of upcoming events).
ENS notifies its subscribers of an event by sending a notification. Notify is also referred to as "publish." A notification can contain the following items:
An event reference (which, optionally, can contain parameter/value pairs)The optional application-specific data is referred to as the "payload."
There are two kinds of notifications:
Unreliable notification - Notification sent from an event publisher to a notification server. If the publisher does not know nor care about whether there are any consumers, or whether they get the notification, this request does not absolutely need to be acknowledged. However, a publisher and a subscriber, who are mutually aware of each other, can agree to set up a reliable event notification link (RENL) between themselves. In this case, once the subscriber has processed the publisher's notification, it sends an acknowledgment notification back to the publisher.See "Publisher API" for more information.
Reliable notification - Notification sent from a server to a subscriber as a result of a subscription. This type of notification should be acknowledged. A reliable notification contains the same attributes as an unreliable notification.
ENS receives a request to be notified of events. The request sent by the event subscriber is a subscription. The subscription is valid during the life of the session, or until it is cancelled (unsubscribed).
A subscription can contain the following items:
ENS receives a request to cancel an existing subscription. See "Subscriber API" for more information.
How iPlanet Calendar Server Interacts with ENS
Figure 1-1 shows how ENS interacts with iPlanet Calendar Server through the alarm queue and two daemons, csadmind and csnotifyd.
Figure 1-1    ENS in iPlanet Calendar Server Overview
iPlanet Calendar Server Alarm Queue
ENS is an alarm dispatcher. This decouples alarm delivery from alarm generation. It also enables the use of multiple delivery methods, such as email and wireless communication. The csadmind daemon detects events by sensing changes in the state of the alarm queue. The alarm queue's state changes every time an alarm is placed in the queue. An alarm is queued when a calendar event generates an alarm. The following URIs represent these kind of events:
for todos (tasks):
calid is the calendar ID.The publisher csadmind dequeues the alarms and sends notifications to enpd. The enpd daemon then checks to see if anyone is subscribed to this kind of event and sends notifications to the subscriber, csnotifyd, for any subscriptions it finds. Other subscribers to alarm notifications (reminders) can be created and deployed within an iPlanet Calendar Server installation. These three daemons interacting together implement event notification for iPlanet Calendar Server.
iPlanet Calendar Server Daemons
iPlanet Calendar Server includes two daemons that communicate to the ENS daemon, enpd:
- The csadmind daemon contains a publisher that submits notifications to the notification service by sending alarm events to ENS. It manages the iPlanet Calendar Server alarm queue. It implements a scheduler, which lets it know when an alarm has to be generated. At such a point, csadmind publishes an event. ENS receives and dispatches the event notification.
- To ensure alarm transfer reliability, csadmind requires acknowledgment for certain events or event types. (See "Alarm Transfer Reliability".) The csadmind daemon uses Reliable Event Notification Links (RENLs) to accomplish acknowledgment.
- The csnotifyd daemon is the subscriber that expresses interest in particular events (subscribes), and receives notifications about these subscribed-to events from ENS, and sends notice of these events and todos (tasks) to its clients by email.
- Though the ability to unsubscribe is part of the ENS architecture, csnotifyd does not bother to unsubscribe to events for the following two reasons: there is no need to unsubscribe or resubscribe during normal runtime; and due to the temporary nature of the subscriptions store (it is held in memory), all subscriptions are implicitly unsubscribed when the connection to ENS is shutdown.
- The csnotifyd daemon subscribes to enp:///ics/alarm/. The todo (task) or event is specified in a parameter.
Alarm Transfer Reliability
To ensure that no alarm ever gets lost, csadmind and csnotifyd use the RENL feature of ENS for certain types of alarms. For these alarms, csadmind requests an end-to-end acknowledgment for each notification it sends, while csnotifyd, after successfully processing it, generates a notification acknowledgment for each RENL alarm notifications it receives.
For these RENL alarms, should the network, the ENS daemon, or csnotifyd fail to handle a notification, csadmind will not receive any acknowledgment, and will not remove the alarm from the alarm queue. The alarm will, therefore, be published again after a timeout.
iPlanet Calendar Server Example
A typical ENS publish and subscribe cycle for iPlanet Calendar Server resembles the following:
The event subscriber, csnotifyd, expresses interest in an event (subscribes).Figure 1-2 illustrates this cycle and Table 1-1 provides the narrative for the figure.
The event publisher, csadmind, detects events and sends notification (publishes).
ENS publishes the event to the subscriber.
The event subscriber cancels interest in the event (unsubscribes). This step happens implicitly when the connection to ENS is shutdown.
Figure 1-2    Example Event Notification Service Publish and Subscribe Cycle for iPlanet Calendar Server
When ENS receives a notification from a publisher, it looks up its internal subscription table to find subscriptions matching the event reference of the notification. Then for each subscription, it relays a copy of the notification to the subscriber who owns this subscription.
How iPlanet Messaging Server Interacts with ENS
Figure 1-3 shows how ENS interacts with iPlanet Messaging Server. In this figure, each oval represents a process, and each rectangle represents a host computer running the enclosed processes.
The iPlanet ENS server delivers notifications from the iPlanet Messaging Server notification plug-in to ENS clients (that is, iBiff subscribers). There is no guarantee of the order of notification prior to the ENS server because the events are coming from different processes (MTA, stored, and imapd).
Notifications flow from the iBiff plug-in in the MTA, stored, and imap processes to ENS enpd. The ENS client subscribes to the ENS, and receives notifications. When iBiff is enabled, iPlanet Messaging Server publishes the notifications with the iBiff plug-in, but no iPlanet Messaging Server services subscribe to these notifications. A customer-provided ENS subscriber or client should be written to consume the notifications and do whatever is necessary. That is, iPlanet Messaging Server itself does not depend on or use the notifications for its functions, and this is why ENS and iBiff are not enabled by default when you install iPlanet Messaging Server.
The iPlanet Messaging Server architecture enforces that a given set of mailboxes is served by a given host computer. A given mailbox is not served by multiple host computers. There are several processes manipulating a given mailbox but only one computer host serving a given mailbox. Thus, to receive notifications, end-users only need to subscribe to the ENS daemon that serves the mailbox they are interested in.
iPlanet Messaging Server enables you to have either one ENS server for all mailboxesthat is, one ENS server for all the computer hosts servicing the message storeor multiple ENS servers, perhaps one ENS server per computer host. The second scenario is more scalable. Also, in this scenario, end users must subscribe to multiple ENS servers to get the events for mailboxes they are interested in.
Thus, the architecture requires an ENS server per computer host. The ENS servers and the client processes do not have to be co-located with each other or with messaging servers.
Figure 1-3    ENS in iPlanet Messaging Server Overview
Event Notification Service API Overview
This section provides an overview of the two APIs for ENS, a C API and a Java API, which is a subset of the Java Messaging Service (JMS) API. Starting with iPlanet Messaging Server 5.2 and iPlanet Calendar Server 5.1, a Java API to ENS has been added. The Java API conforms to the Java Message Service specification (JMS). Two sample Java subscribers are provided using the JMS API.
For detailed information on the ENS C API, see Chapter 2 "Event Notification Service C API Reference." For detailed information on the Java (JMS) API, see Chapter 3 "Event Notification Service Java (JMS) API Reference." For JMS documentation, use the following URL:
ENS C API Overview
ENS implements the following three APIs:
- A publisher sends notification of a subscribed-to event to ENS, which then distributes it to the subscribers. Optionally, in iPlanet Calendar Server, the application can request acknowledgment of receipt of the notification. To do this, a Reliable Event Notification Link (RENL) is necessary. An RENL has a publisher, a subscriber, and a unique ID, which identify notifications that are subject to acknowledgment. The publisher informs the application of the receipt of an acknowledgment by invoking the end2end_ack callback passed to publish_a. Currently, only iPlanet Calendar Server supports RENL.
Publish and Subscribe Dispatcher API
- A subscriber is a client to the notification service which expresses interest in particular events. When the notification service receives a notification about one of these events from a publisher, it relays the notification to the subscriber.
- A subscriber may also unsubscribe, which cancels an active subscription.
- In iPlanet Calendar Server, to enable an RENL, the subscriber declares its existence to ENS, which then transparently generates notification acknowledgment on behalf of the subscriber application. The subscriber can revoke the RENL at any time.
- When an asynchronous publisher is used, ENS needs to borrow threads from a thread pool in order to invoke callbacks. The application can either choose to create its own thread pool and pass it to ENS, or it can let ENS create and manage its own thread pool. In either case, ENS creates and uses a dispatcher object to instantiate the dispatcher used (pas_dispatcher_t).
- GDisp (libasync) is the dispatcher supported.
ENS Java API Overview
The Java API for ENS uses a subset of the standard JMS API, with the addition of two new proprietary methods:
Building and Running Custom Applications
To assist you in building your own custom publisher and subscriber applications, iPlanet Messaging Server and iPlanet Calendar Server include sample code. This section tells you where to find the sample code, where the APIs' include (header) files are located, and where the libraries are that you need to build and run your custom programs.
Location of Sample Code
iPlanet Calendar Server
iPlanet Calendar Server includes four simple sample programs to help you get started. The code for these samples resides in the following directory:
iPlanet Messaging Server
iPlanet Messaging Server 5.1 and higher contains sample programs to help you learn how to receive notifications. These sample programs are located in the server-root/bin/msg/enssdk/examples directory.
Location of Include Files
iPlanet Calendar Server
The include (header) files for the publisher and subscriber APIs are: publisher.h, suscriber.h, and pasdisp.h (publish and subscribe dispatcher). They are located in the CSAPI include directory. The default include path is:
iPlanet Messaging Server
The default include path for iPlanet Messaging Server is:
Dynamically Linked/Shared Libraries
iPlanet Calendar Server
Your custom code must be linked with the dynamically linked library libens, which implements the publisher and subscriber APIs. On some platforms all the dependencies of libens must be provided as part of the link directive. These dependencies, in order, are:
libgapiPlanet Calendar Server uses these libraries; therefore, they are located in the server's bin directory. The default libens path is:
Note For NT, in order to build publisher and subscriber applications, you also need the archive files (.lib files) corresponding to all the earlier mentioned libraries. These are located in the CSAPI library directory, lib. The default lib path is:
iPlanet Messaging Server
The libraries for iPlanet Messaging Server are located in the following directory:
Refer to server-root/bin/msg/enssdk/examples/Makefile.sample to help determine what libraries are needed.This makefile contains instructions on how to compile and run the apub and asub programs. This file also describes what libraries are needed, and what the LD_LIBRARY_PATH should be.
Figure 1-4    Makefile.sample File
# Sample makefile
# your C compiler
CC = gcc
# Your library path should include <server-root>/bin/msg/lib
LIBS = -lens -lgap -lxenp -lcyrus -lchartable -lyasr -lasync
all: apub asub
$(CC) -o apub -I ../include apub.c $(LIBS)
$(CC) -o asub -I ../include asub.c $(LIBS)
@echo 'run <server-root>/msg-<instance>/start-ens'
@echo run asub localhost 7997
@echo run apub localhost 7997
Note The Windows NT distribution includes the following additional files:
A sample VC++ workspace is provided in asub.dsw. It has two projects in it: asub.dsp and apub.dsp.
To run, it requires that the following DLLs are in your path.
Runtime Library Path Variable
iPlanet Calendar Server
In order for your custom programs to find the necessary runtime libraries, which are located in the /opt/SUNWics5/cal/bin directory, make sure your environment's runtime library path variable includes this directory. The name of the variable is platform dependent:
iPlanet Messaging Server
For iPlanet Messaging Server, you need to set your LD_LIBRARY_PATH to server-root/bin/msg/lib.
Previous Contents Index Next
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated January 31, 2002