AsyncEventListener (Apache Geode 1.15.4)

org.apache.geode.cache.asyncqueue

## Interface AsyncEventListener

- All Superinterfaces:
    CacheCallback, Declarable
  All Known Implementing Classes:
    JdbcAsyncWriter

      public interface AsyncEventListener
      extends CacheCallback

  A callback for events passing through the `AsyncEventQueue` to which this listener is attached. Implementers of interface `AsyncEventListener` process batches of `AsyncEvent` delivered by the corresponding `AsyncEventQueue`.
  A sample implementation of this interface is as follows:

       public class MyEventListener implements AsyncEventListener {

         public boolean processEvents(List<AsyncEvent> events) {
           for (Iterator i = events.iterator(); i.hasNext();) {
             AsyncEvent event = (AsyncEvent) i.next();

             String originalRegionName = event.getRegion().getName();
             // For illustration purpose, use the event to update the duplicate of above region.
             final Region duplicateRegion =
                 CacheHelper.getCache().getRegion(originalRegionName + "_DUP");

             final Object key = event.getKey();
             final Object value = event.getDeserializedValue();
             final Operation op = event.getOperation();

             if (op.isCreate()) {
               duplicateRegion.create(key, value);
             } else if (op.isUpdate()) {
               duplicateRegion.put(key, value);
             } else if (op.isDestroy()) {
               duplicateRegion.destroy(key);
             }

           }
           return true;
         }
       }

  Since:
    GemFire 7.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `processEvents(List<AsyncEvent> events)` Process the list of `AsyncEvent`s.

    - ### Methods inherited from interface org.apache.geode.cache.CacheCallback

      `close`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Method Detail

    - #### processEvents

          boolean processEvents(List<AsyncEvent> events)

      Process the list of `AsyncEvent`s. This method will asynchronously be called when events are queued to be processed. The size of the list will be up to batch size events where batch size is defined in the `AsyncEventQueueFactory`.
      Parameters:
        `events` - The list of `AsyncEvent` to process
      Returns:
        boolean True represents whether the events were successfully processed, false otherwise.