tree: 0d032f59114b3d41997cbecad13c25cf45a8f285 [path history] [tgz]
  1. scripts/
  2. src/

Geode Continuous Query Example

This is a simple example that demonstrates Apache Geode's Continuous Queries(CQs) feature. CQs allow clients to subscribe to server-side 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.

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.

The client will generate data for 20 seconds, close the CQ and Cache, and then exit.

This example assumes you have installed Java and Geode.


  1. From the geode-examples/cq directory, build the example.

     $ ../gradlew build
  2. Next start a locator, start a server, and create a region.

     $ gfsh run --file=scripts/start.gfsh
  3. Run the example to demonstrate continues queries.

     $ ../gradlew run
  4. Shut down the server.

     $ gfsh run --file=scripts/stop.gfsh