|Developing with Pivotal GemFire / Events and Event Handling|
You can receive events from your servers for server-side cache events and query result changes.
For cache updates, you can configure to receive entry keys and values or just entry keys, with the data retrieved lazily when requested. The queries are run continuously against server cache events, with the server sending the deltas for your query result sets.
Before you begin, set up your client/server installation and configure and program your basic event messaging.
Servers receive updates for all entry events in their client's client regions.
// Register interest in a single key and download its entry // at this time, if it is available in the server cache Region region1 = . . . ; region1.registerInterest("key-1"); // Register Interest in a List of Keys but do not do an initial bulk load // do not send values for creater/update events - just send key with invalidation Region region2 = . . . ; List list = new ArrayList(); list.add("key-1"); list.add("key-2"); list.add("key-3"); list.add("key-4"); region2.registerInterest(list, InterestResultPolicy.NONE, false); // Register interest in all keys and download all available keys now Region region3 = . . . ; region3.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS); // Register Interest in all keys matching a regular expression Region region1 = . . . ; region1.registerInterestRegex("[a-zA-Z]+_[0-9]+");
You can call the register interest methods multiple times for a single region. Each interest registration adds to the server’s list of registered interest criteria for the client. So if a client registers interest in key ‘A’, then registers interest in regular expression "B*", the server will send updates for all entries with key ‘A’ or key beginning with the letter ‘B’.
|Interest Registration Example|