Products
Clients
Extensions
APIs
Continuous Queries (CQ) allow clients to subscribe to server-side VMware GemFire events using a SQL-like query. When a client registers a CQ, the client will receive all events that modify the query results.
In this example, the client program will first register a CQ with the query SELECT * FROM /example-region i where i > 70. The region has keys and values that are both Integer types.
SELECT * FROM /example-region i where i > 70
The program loops, randomly generating two integers to put on the server as the key and value.
If a value is either created or updated that is greater than 70, the above CQ will trigger the RandomEventLister, which prints to stdout.
RandomEventLister
The client will generate data for 20 seconds, close the CQ and Cache, and then exit.
This example assumes you have installed JDK11 and GemFire.
From the gemfire-examples/cq directory, build the example.
gemfire-examples/cq
$ ../gradlew build
Next start a locator, start a server, and create a region.
$ gfsh run --file=scripts/start.gfsh
Run the example to demonstrate continues queries.
$ ../gradlew run
Shut down the server.
$ gfsh run --file=scripts/stop.gfsh