VMware GemFire Java API Reference
Interface AsyncEventListener
-
- All Superinterfaces:
CacheCallback,Declarable
- All Known Implementing Classes:
JdbcAsyncWriter
public interface AsyncEventListener extends CacheCallback
A callback for events passing through theAsyncEventQueueto which this listener is attached. Implementers of interfaceAsyncEventListenerprocess batches ofAsyncEventdelivered by the correspondingAsyncEventQueue.
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 Description booleanprocessEvents(java.util.List<AsyncEvent> events)Process the list ofAsyncEvents.-
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(java.util.List<AsyncEvent> events)
Process the list ofAsyncEvents. 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 theAsyncEventQueueFactory.- Parameters:
events- The list ofAsyncEventto process- Returns:
- boolean True represents whether the events were successfully processed, false otherwise.
-
-