Sun Java Communications Suite 5 Event Notification Service Guide

Building and Running Custom Applications

To assist you in building your own custom publisher and subscriber applications, Messaging Server and 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.

Note –

This section applies to the C API only.

Location of Sample Code

Calendar Server

Calendar Server includes four simple sample programs to help you get started. The code for these samples resides in the following directory:


Messaging Server

Messaging Server 5.1 and higher contains sample programs to help you learn how to receive notifications. These sample programs are located in the following directory:


Location of Include Files

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:


Messaging Server

The default include path for Messaging Server is:


Dynamically Linked/Shared Libraries

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:

  1. libgap

  2. libcyrus

  3. libyasr

  4. libasync

  5. libnspr3

  6. libplsd4

  7. libplc3

Calendar Server uses these libraries; therefore, they are located in the server’s bin directory. The default libens path is:


Note –

For Windows, 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:


Messaging Server

The libraries for Messaging Server are located in the following directory:


Refer to msg-server-base/examples/enssdk/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. The following listing shows a sample makefile.sample file.

Example 1–1 Makefile.sample File

# Sample makefile
# your C compiler
CC = gcc

# Your library path should include <msg-server-base>/lib
LIBS = -lens -lgap -lxenp -lcyrus -lchartable -lyasr -lasync

all: apub asub

apub: apub.c
        $(CC) -o apub -I ../include apub.c $(LIBS)

asub: asub.c
        $(CC) -o asub -I ../include asub.c $(LIBS)

        @echo ’run <msg-server-base>/start-ens’
        @echo run asub localhost 7997
        @echo run apub localhost 7997


Note –

The Windows distribution includes the following additional files:












To build on Windows platforms:

  1. A sample VC++ workspace is provided in asub.dsw. It has two projects in it: asub.dsp and apub.dsp.

    The required .lib files to link is in the same directory as asub.c and apub.c.

  2. To run, it requires that the following DLLs are in your path.


    The simplest way to accomplish this is to include msg-server-base in\msg\lib in your PATH.

Runtime Library Path Variable

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:

Messaging Server

For Messaging Server, you need to set your LD_LIBRARY_PATH to msg-server-base/lib.