This is a simple example that demonstrates asynchronous event queues and listeners.
An asynchronous event queue is an ordered collection of events that occurred on a region, e.g., create a new entry, update an existing entry. An asynchronous event listener has its method invoked from time to time with batches of events that have occurred previously. The method invocation occurs inside the JVM of the server and can not affect the operation on the region.
In this example, an asynchronous event queue is created for the region of incoming words. An asynchronous event listener is specified for that asynchronous event queue. Whenever the
processEvents method is invoked on the listener, it uses the Levenshtein distance for each word to perform simplistic spell-checking. The proposed revision is the put in the outgoing region. A cache listener is installed that captures all of the creation events for the outgoing region and displays the proposal on the terminal. In other applications, the asynchronous event listener could perform some other calculation on the data.
This example assumes you have installed Java and Geode.
geode-examples/async directory, build the example, and run unit tests.
$ ../gradlew build
Next start a locator, start two servers, create two regions, and deploy the asynchronous event listener.
$ gfsh run --file=scripts/start.gfsh
Run the example to put entries into the incoming region and get entries from the outgoing region.
$ ../gradlew run
Notice the output.
that -> that teh -> the wil -> will i -> I
Shut down the system.
$ gfsh run --file=scripts/stop.gfsh