How an 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 a single thread dispatches a batch of events at a time to the user-implemented callback class in first in, first out (FIFO) order. The frequency of dispatching events to the listener is governed by the configuration of the AsyncEventListener in GemFire XD.

Note: GemFire XD invokes a listener only for single DML events; bulk DML or batch SQL statements do not invoke listeners.
To receive DML callbacks, you create a class that implements the AsyncEventListener interface. The callback method processEvents(List<Event> events) provides a list of DML events from the batch, and each Event object provides methods that you can use to obtain the 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.

Use the information provided in the list of events to perform the work of your listener implementation. Your processEvents method should return TRUE if it successfully processes all of the events, in which case GemFire XD deletes the processed events from the queue. Return FALSE if if you are unable to successfully process the events and you want GemFire XD to preserve and re-send the events, rather than deleting them from the queue.

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.