Initializating in-process adapters in C/C++

The tutorial ADL file on initialization enables you to work with each Sybase CEP data type.

Each of these values may be entered in a Properties View (in Sybase CEP Studio) and retrieved with the sample code:

DumpParamName(i_adapter_ptr, (C8Char*)"Filename");
DumpParamInt(i_adapter_ptr, (C8Char*)"UserDefinedInteger");
...

The parameter name gets associated with the value from the adapter's Properties View in Sybase CEP Studio. This printing of parameter values may be observed by displaying an instance of the adapter in Sybase CEP Studio. Make sure Sybase CEP Server is properly connected, then press "Start Module". The adapter initialization routine is called and the parameter printing routines display the Sybase CEP Studio values on Sybase CEP window.

To change the values and have Sybase CEP Server notice the changes, press "Stop Module" in the Sybase CEP Studio window. Change the value of the parameters and press "Start Module" when you are finished. The Sybase CEP Server log will contain the values that were entered into the adapter's Properties View in Sybase CEP Studio. This exercise demonstrates proper communication between the Sybase CEP Studio and the Sybase CEP Server.

Another useful printout for initialization is the current working directory of the server. Because Sybase CEP Studio can execute on a different machine than Sybase CEP Server, it is sometimes confusing to determine the working directory of Sybase CEP Server. Printing the directory helps with this problem.

A session state may be required if you need to initialize variables, open file/sockets/db connects, and so on. Define a single block of memory to store this data. This means that you cannot use such structures as hash maps or linked lists without formatting the data structures into and out of a single memory block.)

The initialization returns C8_TRUE to indicate a proper initialization sequence. If the code is not able to properly initialize the adapter, C8_FALSE is returned. Reasons for improper initialization include input files not found, permissions problems and connection problems.

A fatal initialization sequence should provide details to Sybase CEP Server log file in a manner that is adequate to resolve the issue.

Returning C8_TRUE continues the adapter execution while C8_FALSE produces an error condition visible on Sybase CEP Studio.

Important: The call to the initialize() function is a blocking call. Some server operations may not run while the initialize() function is running, and therefore you should write your initialize() function so it finishes quickly (preferably in less than one second).