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 configuration of the AsyncEventListener in GemFire XD.

To receive DML callbacks, you create a class that implements the AsyncEventListener interface.

Note: GemFire XD invokes a listener only for single DML events; bulk DML or batch SQL statements do not invoke listeners.
The callback method processEvents(List<Event> events) provides information related to manipulated rows, such as the new row values. Each Event object provides following information.
Event Information Description
Type of Event Object of EVENT.Type enumeration. This can be AFTER_INSERT, AFTER_UPDATE, AFTER_DELETE, BEFORE_DELETE, BEFORE_INSERT, BEFORE_UPDATE, BULK_DML, or BULK_INSERT depending upon the type of CRUD operation.
Schema and Table Name The schema and table name for the current operation.
Old Row A result set of column values representing the old row that is being updated.
New Row A result set of column values representing the new rows that are being inserted or updated.
Table MetaData Information about the type, properties, and positions of the columns being returned.
Primary Key A result set representing the primary key columns of the changed rows.
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.