Previous Contents Index Next |
iPlanet Messaging and Collaboration Event Notification Service Manual |
Chapter 5 iPlanet Messaging Server Specific Information
This chapter describes the iPlanet Messaging Server specific items you need to use the ENS APIs.This chapter contains these sections:
iPlanet Messaging Server Events and Parameters
iPlanet Messaging Server Events and Parameters
For iPlanet Messaging Server, there is only one event reference, which can be composed of several parameters. Each parameter has a value and a payload.iPlanet Messaging Server supports the following types of events:
NewMsg - New message was received by the system into the user's mailbox.
The following applies to the above supported events:DeleteMsg - User deleted a message (in the IMAP protocol, expunged) from the mailbox.
UpdateMsg - Message was appended to the mailbox (other than by NewMsg). for example, the user copied an email message to the mailbox.
ReadMsg - Message in the mailbox was read (in the IMAP protocol, the message was marked Seen).
PurgeMsg - Message was purged (in the IMAP protocol, expunged) from the mailbox by the system.
All events relate only to the INBOX.
The NewMsg notification is issued only after the message is deposited in the user mailbox (as opposed to "after it was accepted by the server and queued in the message queue").
Both the DeleteMsg and the PurgeMsg events correspond to when a message is deleted from the user's mailbox (in the IMAP protocol, the message is expunged). It is not when a message is marked for deletion in the IMAP protocol. The only difference between the two events is who deleted the message. DeleteMsg indicates that the user deleted the message, while PurgeMsg indicates that iPlanet Messaging Server deleted the message (for example, if the message has expired).
The notification will carry several pieces of information depending on the event type, for example, NewMsg indicates the IMAP uid of the new message.
Parameters
iBiff will use the following format for the ENS event reference:enp://127.0.0.1/store?param=value¶m1=value1¶m2=value2
The event key enp://127.0.0.1/store has no significance other than its uniqueness as a string. For example, the hostname portion of the event key has no significance as a hostname. It is simply a string that is part of the URI. However, the event key is user configurable. The list of iBiff configuration parameters is listed in a separate section below.
The second part of the event reference consists of parameter/value pairs. This part of the event reference is separated from the event key by a question mark (?). The parameter and value are separated by an equals sign (=). The parameter/value pairs are separated by an ampersand (&). Note that there can be empty values, for which the value simply does not exist.
Table 5-1 describes the mandatory configuration parameters that need to be included in every notification.
Table 5-2 describes the optional configuration parameters, depending on the event type.
Note Subscribers should allow for undocumented parameters when parsing the event reference. This allows for future compatibility when new parameters are added.
Payload
Depending on the event, there may be the following data in the payload portion of the ENS notification:
The headers of the message - (string) - The length will be limited to a certain (configurable) size. See configuration parameters in a separate section below.
Table 5-3 shows the parameters that are available for each event type.The first few bytes of the body of the message - (string). The actual number of bytes will be configurable. See configuration parameters in a separate section below.
Table 5-3    Available Parameters for Each Event Type
Field Name
NewMsg, UpdateMsg
ReadMsg
DeleteMsg, PurgeMsg
Examples
The following example shows a NewMsg event reference (it is actually a single line that is broken up to several lines for readability):
enp://127.0.0.1/store?evtType=NewMsg&mailboxName=ketu310×tamp=972423964000
&process=16233&hostname=ketu&numMsgs=1&size=3339&uidValidity=972423964&
imapUid=1&hdrLen=810This is the associated payload, note that the body portion has been truncated:
This is another example, this time for the DeleteMsg event (again it is a single line that is broken up for readability). Note that this example shows a mailboxName for the userid blim in the hosted domain symult.com.
enp://127.0.0.1/store?evtType=DeleteMsg&mailboxName=blim@symult.com&
timestamp=972423953000&process=15354&hostname=ketu&numMsgs=0&
uidValidity=972423928&imapUid=2&lastUid=2And a third example showing a ReadMsg event (again the line is broken up for readability). Note that this example shows an empty value for the uidSeqSeen parameter. It also shares the same userid as the previous example, however this corresponds to a different user, a user in the default domain.
enp://127.0.0.1/store?evtType=ReadMsg&mailboxName=blim×tamp=972423952000&
process=15354&hostname=ketu&uidValidity=972423928&uidSeqSeen=&uidSeqDel=1
iPlanet Messaging Server Sample Code
iPlanet Messaging Server ships with a complete ENS implementation but by default it is not enabled. To enable ENS in iPlanet Messaging Server, see Appendix C in the iPlanet Messaging Server 5.2 Administrator's Guide.The following two code samples illustrate how to use the ENS API. The sample code is provided with the product in the following directory:
server-root/bin/msg/enssdk/examples
Sample Publisher
This sample code provides a simple interactive asynchronous publisher.* Copyright 2000 by Sun Microsystems, Inc.
* a simple interactive asynchronous publisher
* This simplistic program publishes events using the hard-coded
* and the data entered at the prompt as notification payload.
* Enter "." to end the program.
* If you happen to run the corresponding subscriber, asub, on the
* same notification server, you will notice the sent data printed
* <host> is the notification server hostname
* <port> is the notification server IP port number
static pas_dispatcher_t *disp = NULL;
static publisher_t *_publisher = NULL;
printf("\nUsage:\n apub host port\n");
static void _exit_error(const char *msg)
static void _open_ack(void *arg, int rc, void *enc)
_publisher = (publisher_t *)enc;
printf("Failed to create publisher with status %d\n", rc);
static void _publish_ack(void *arg, int rc, void *ignored)
printf("Publish failed with status %d\n", rc);
if ( !fgets(input, sizeof(input), stdin) ) {
input[strlen(input) - 1] = 0; /* Strip off the \n */
if (*input == '.' && input[1] == 0) {
message_len = strlen(message);
publish(_publisher, "enp://127.0.0.1/store",
_publish_ack, NULL, (void *)message, 0);
port = (unsigned short)atoi(argv[2]);
disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("Can't create publisher");
publisher_new_a(disp, NULL, host, port, _open_ack, disp);
Sample Subscriber
This sample code provides a simple subscriber.* Copyright 1997 by Sun Microsystems, Inc.
* This simplistic program subscribes to events matching the
* It subsequently received messages emitted by the apub processes
* if any are being used, and prints the payload of each received
* <host> is the notification server hostname
* <port> is the notification server IP port number
static pas_dispatcher_t *disp = NULL;
static subscriber_t *_subscriber = NULL;
static subscription_t *_subscription = NULL;
printf("\nUsage:\n asub host port\n");
static void _exit_error(const char *msg)
static void _subscribe_ack(void *arg, int rc, void *subscription)
printf("Subscription successful\n");
subscriber_keepalive(_subscriber, 30000);
printf("Subscription failed - status %d\n", rc);
static void _unsubscribe_ack(void *arg, int rc, void *ignored)
printf("Unsubscribe failed - status %d\n", rc);
subscriber_delete(_subscriber);
static int _handle_notify(void *arg, char *url, char *str, int len)
printf("[%s] %.*s\n", url, len, (str) ? str : "(null)");
static void _open_ack(void *arg, int rc, void *enc)
_subscriber = (subscriber_t *)enc;
printf("Failed to create subscriber with status %d\n", rc);
subscribe(_subscriber, "enp://127.0.0.1/store",
static void _unsubscribe(int sig)
unsubscribe(_subscriber, _subscription, _unsubscribe_ack, NULL);
port = (unsigned short)atoi(argv[2]);
disp = pas_dispatcher_new(NULL);
if (disp == NULL) _exit_error("Can't create publisher");
subscriber_new_a(disp, NULL, host, port, _open_ack, NULL);
Implementation Notes
The current implementation does not provide security on events that can be subscribed to. Thus, a user could register for all events, and portions of all other users' mail. Because of this it is strongly recommended that the ENS subscriber be on the "safe" side of the firewall at the very least.
Previous Contents Index Next
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated January 31, 2002