1.1

Table Of Contents
Chapter 34
Handling DML Events Asynchronously
An AsyncEventListener receives callbacks on the execution of data manipulation language (DML) statements (create,
update, and delete operations) in SQLFire. In a caching deployment, you can use an AsyncEventListener to analyze
data in DML statements and take desired actions such as persisting the data in a specic format.
How the AsyncEventListener Works
An AsyncEventListener instance is serviced by its own dedicated thread in which a callback method is invoked.
Events that correspond to DML operations are placed in an internal queue, and the dedicated thread dispatches
a batch of events at a time to the user-implemented callback class. The frequency of dispatching events is governed
by the conguration of the AsyncEventListener in SQLFire.
To receive DML callbacks, you create a class that implements the AsyncEventListener interface.
The callback method processEvents(List<Event> events) provides information related to manipulated
rows, such as the new row values. The Event object provides following information.
DescriptionEvent Information
Object of EVENT.Type enumeration. This can be AFTER_INSERT,
AFTER_UPDATE, AFTER_DELETE, BEFORE_DELETE,
Type of Event
BEFORE_INSERT, BEFORE_UPDATE, BULK_DML, or
BULK_INSERT depending upon the type of CRUD operation.
The schema and table name for the current operation.Schema and Table Name
A result set of column values representing the old row that is being
updated.
Old Row
A result set of column values representing the new rows that are
being inserted or updated.
New Row
Information about the type, properties, and positions of the columns
being returned.
Table MetaData
A result set representing the primary key columns of the changed
rows.
Primary Key
Note: Certain data consistency problems can occur if multiple threads update data that is queued to an
AsyncEventListener implementation. See No Ordering Guarantee for DML in Separate Threads on page
146.
Implementation Requirements
Before you implement an AsynchEventListener, be aware of the requirements and guidelines.
193