1.0

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
http://www.vmware.com/support/developer/vfabric-sqlre/103-api/com/vmware/sqlre/callbacks/AsyncEventListener.html
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 Enumeration Type. It could be AFTER_INSERT,
AFTER_UPDATE, AFTER_DELETE, depending upon the type of
CRUD operation.
Type of Event
List of objects representing the tuple, before modication.Old Row
List of objects, representing the tuple after modication.New Row
Object of java.sql.ResultSetMetaData interface providing information
about the type and properties of the columns.
ResultSetMetaData
An int array containing the positions of the columns that were
updated. The details of the modied columns can be retrieved from
Modied Columns
the metadata from ResultSetMetaData. The modied column values
can be obtained from the new wow from using index as column.
Object array representing the primary key of the manipulated row.
If the table has no primary key dened, then a long value uniquely
Primary Key
identifying the row would be returned. In such cases, users can
correlate the row ID during creation with that during update & delete.
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
136.
185