List of Event Handlers and Events

vFabric GemFire provides many types of events and event handlers to help you manage your different data and application needs.

Event Handlers

Use either cache handlers or admin handlers in any single application. Do not use both. The event handlers in this table are cache handlers unless otherwise noted.

Handler API Events received Description
CacheCallback   Superinterface of all cache event listeners except BridgeMembershipListener. Functions only to clean up resources that the callback allocated.
CacheListener RegionEvent, EntryEvent Tracks changes to region and its data entries. Responds synchronously. Extends CacheCallback interface. Installed in region. Receives only local cache events. Install one in every member where you want the events handled by this listener. In a partitioned region, the cache listener only fires in the primary data store. Listeners on secondaries are not fired.
CacheWriter RegionEvent, EntryEvent Receives events for pending changes to the region and its data entries in this member or one of its peers. Has the ability to abort the operations in question. Extends CacheCallback interface. Installed in region. Receives events from anywhere in the distributed region, so you can install one in one member for the entire distributed region. Receives events only in primary data store in partitioned regions, so install one in every data store.
RegionMembershipListener RegionEvent Provides after-event notification when a region with the same name has been created in another member and when other members hosting the region join or leave the distributed system. Extends CacheCallback and CacheListener. Installed in region as a CacheListener.
RegionRoleListener RoleEvent, RegionEvent, EntryEvent Tracks the presence of essential membership roles in the distributed system, and changes to member, region, and data entries. Extends CacheCallback, CacheListener, and RegionMembershipListener. Installed in region as a CacheListener.
TransactionListener TransactionEvent with embedded list of EntryEvent Tracks the outcome of transactions and changes to data entries in the transaction.
Note: Multiple transactions on the same cache can cause concurrent invocation of TransactionListener methods, so implement methods that do the appropriate synchronizing of the multiple threads for thread-safe operation.
Extends CacheCallback interface. Installed in cache using transaction manager. Works with region-level listeners if needed.
TransactionWriter TransactionEvent with embedded list of EntryEvent Receives events for pending transaction commits. Has the ability to abort the transaction. Extends CacheCallback interface. Installed in cache using transaction manager. At most one writer is called per transaction. Install a writer in every transactional data host.
BridgeMembershipListener BridgeMembershipEvent Tracks changes to client/server connections. Static utility, installed at the process level using BridgeMembership.
CqListener CqEvent Receives events from the server cache that satisfy a client-specified query. Extends CacheCallback interface. Installed in the client inside a CqQuery.
GatewayEventListener GatewayEvent Tracks changes in a region for write-behind processing. Extends CacheCallback interface. Install in a gateway with no endpoints, inside a gateway hub with no incoming port specification. Then set enable-gateway on the regions whose events you need to process.
SystemMembershipListener (administrative listener) SystemMembershipEvent Tracks members as they join and leave the distributed system. Installed in any admin application, not installed in the cache. You can call this listener from anywhere in your program.
SystemMemberCacheListener (administrative listener) SystemMemberCacheEvent SystemMemberRegionEvent Tracks caches and regions as they come and go. . Installed in any admin application, not installed in the cache.

Cache Events

The events in this table are cache events unless otherwise noted.

Event Passed to handler ... Description
CacheEvent   Superinterface to RegionEvent and EntryEvent. This defines common event methods, and contains data needed to diagnose the circumstances of the event, including a description of the operation being performed, information about where the event originated, and any callback argument passed to the method that generated this event.
RegionEvent CacheListener, CacheWriter, RegionMembershipListener, RegionRoleListener Extends CacheEvent for region events. Provides information about operations that affect the whole region, such as reinitialization of the region after being destroyed.
EntryEvent CacheListener, CacheWriter, RegionRoleListener, TransactionListener (inside the TransactionEvent) Extends CacheEvent for entry events. Contains information about an event affecting a data entry in the cache. The information includes the key, the value before this event, and the value after this event. EntryEvent.getNewValue returns the current value of the data entry. EntryEvent.getOldValue returns the value before this event if it is available. For a partitioned region, returns the old value if the local cache holds the primary copy of the entry. EntryEvent provides the GemFire transaction ID if available.

You can retrieve serialized values from EntryEvent using the getSerialized* methods. This is useful if you get values from one region’s events just to put them into a separate cache region. There is no counterpart put function as the put recognizes that the value is serialized and bypasses the serialization step.

RoleEvent RegionRoleListener Extends RegionEvent for region reliability events. Contains information about an event where membership roles are lost or gained, which might affect a region’s reliability.
TransactionEvent TransactionListener, TransactionWriter Describes the work done in a transaction. This event may be for a pending or committed transaction, or for the work abandoned by an explicit rollback or failed commit. The work is represented by an ordered list of EntryEvent instances. The entry events are listed in the order in which the operations were performed in the transaction.

As the transaction operations are performed, the entry events are conflated, with only the last event for each entry remaining in the list. So if entry A is modified, then entry B, then entry A, the list will contain the event for entry B followed by the second event for entry A.

BridgeMembershipEvent BridgeMembershipListener Provides information about changes in a client or server.
CqEvent CqListener Provides information about a change to the results of a continuous query running on a server on behalf of a client. CqEvents are processed on the client.
GatewayEvent GatewayEventListener Provides information about a single event in the cache. This event is delivered to a gateway queue for batched, asynchronous delivery to a GatewayEventListener. These events are a subset of the EntryEvents.
SystemMembershipEvent (administrative event) SystemMembershipListener Provides information about member join and departure.
SystemMemberCacheEvent (administrative event) SystemMemberCacheListener Provides information about cache create and destroy.
SystemMemberRegionEvent (administrative event) SystemMemberCacheListener Provides information about region create and destroy.