Enabling database change notification

This feature allows the use of database triggers to notify EAServer's entity object cache of changes to the underlying table rows. The notification mechanism works as follows:

  1. Database triggers call a stored procedure sp_publish to publish a message for each SQL insert, update or delete.

  2. sp_publish “publishes” the messages by placing them in a table cms_notify.

  3. A cluster-wide singleton service, CtsComponents/DatabaseNotify, pulls notification messages from the cms_notify table using stored procedure sp_notify. These messages are then published to the EAServer message service. The expected latency for message delivery (from trigger to cache entry removal) is approximately one second at most.

  4. The storage component (when using CtsComponents/JdbcStorage) listens for messages on selected topics, parses the messages for key fields, and notifies the Object Cache to remove the relevant entries.

StepsEnabling database change notification

  1. Install the required stored procedures in the target database(s). See “Sample script for database stored procedures”.

  2. In the EAServer Manager properties for your server, use the Advanced tab to configure the property com.sybase.jaguar.server.services to include the Message Service and Database Notify components, for example:

    CtsComponents/MessageService,CtsComponents/DatabaseNotify
    

    If you have never run the message service in your installation, configure the message service as described in Chapter 8, “Setting up the Message Service,” in the EAServer System Administration Guide. Database change notification requires a working message service.

  3. Optionally add an entry to MessageServiceConfig.props to specify the name(s) of connection caches for databases which need to be monitored for notification messages. These connection caches must have type JDBC, for example:

    dn.caches=SybaseCache,OracleCache
    

    By default, the cache referenced by the cms.cache property will be used.

  4. Optionally add an entry to MessageServiceConfig.props to specify the JDBC callable statement (or prepared statement) to be used to pull change notification messages from the database, for example:

    sp_notify={call my_own_notify_proc ?,?}
    

    By default, the callable statement is:

    {call sp_notify ?,?}
    
  5. For each entity component that is to be configured for database notification, enable the Create Database Triggers option on the Persistence/General subtab in the Component Properties dialog box. This option requests automatic creation of triggers.

  6. Optionally change the message service topic names associated with database tables. The default topic name is the unqualified table name. You must change the topic name if multiple databases contain tables with the same name. To change the topic name associated with a table, set the table mapping property for the table’s notify operation, as described on “Configuring table-mapping properties” in the EAServer Programmer’s Guide.