1.1

Table Of Contents
Note: You can optionally install the AsyncEventListener conguration after you associate a table with
the listener name. Make sure that you use the same listener name with both the CREATE
ASYNCEVENTLISTNER command and the CREATE TABLE command.
This example installs TestAsyncEventListener with the identier "MyListener" on members of the server group
"SG1." See CREATE ASYNCEVENTLISTENER for more information about other parameters to the procedure.
Start the AsyncEventListener Configuration
After you install the AsyncEventListener implementation, you can start it by specifying the unique identier for
the implementation in the SYS.START_ASYNC_EVENT_LISTENER procedure. For example:
java.sql.Connection conn = getConnection();
CallableStatement cs = conn.prepareCall("call
SYS.START_ASYNC_EVENT_LISTENER( ? )");
cs.setString(1, "MyID");
cs.execute();
On execution, a thread would service the queue of the AsyncEventListener and dispatch events to the callback
class.
Associate a Table with an AsyncEventListener Configuration
You associate a table with an AsyncEventListener conguration using the AsyncEventListener clause in
the table's CREATE TABLE statement. For example, to associate the table "TestTable" with an
AsyncEventListenerConguration identied by "MyID" use the statement:
java.sql.Connection conn = getConnection();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE TESTTABLE (ID int NOT NULL, DESCRIPTION
varchar(1024),
ADDRESS varchar(1024) ) AsyncEventListener(MyID) " );
Note: Because the associated listener conguration does not have to be available at the time you create
the table, SQLFire does not display an error message if the specied listener name does not yet exist.
Make sure that you use the same listener name with both the CREATE ASYNCEVENTLISTNER command
and the CREATE TABLE command.
Note: You can optionally associate the table with an AsyncEventListener conguration after you create
the table, using the SQLFire ALTER TABLE statement.
Display Installed AsyncEventListeners
You can join the SYSTABLES, MEMBERS, and ASYNCEVENTLISTENERS tables to display the listener
implementations associated with a table as well as the data store ID on which the listener is installed:
select t.*, m.ID DSID from SYS.SYSTABLES t, SYS.MEMBERS m,
SYS.ASYNCEVENTLISTENERS a
where t.tablename='<table>' and groupsintersect(a.SERVER_GROUP,
m.SERVERGROUPS)
and groupsintersect(t.ASYNCLISTENERS, a.ID);
See SYSTABLES on page 657 and ASYNCEVENTLISTENERS on page 635.
197
Handling DML Events Asynchronously