Creating Continuous Queries Using Spring Data GemFire

Warning: Pivotal Cloud Cache v1.8 is no longer supported because it has reached the End of General Support (EOGS) phase as defined by the Support Lifecycle Policy. To stay up to date with the latest software and security updates, upgrade to a supported version.

To create continuous queries with the Spring Data GemFire library, you must have the following:

  • Spring Data GemFire v2.0.1 release
  • Spring Boot v2.0.0+

To create continuous queries, do the following items:

  • Specify attributes subscriptionEnabled and readyForEvents for the ClientCacheApplication annotation. Apply this annotation to the Spring Boot client application class:

    @ClientCacheApplication(name = "GemFireSpringApplication", readyForEvents = true,
      subscriptionEnabled = true)

    The annotation for a durable event queue for continuous queries also sets the durableClientId and keepAlive attributes. For example:

    @ClientCacheApplication(name = "GemFireSpringApplication",
      durableClientId = "durable-client-id", keepAlive = true,
      readyForEvents = true, subscriptionEnabled = true)
  • Annotate the method that handles the events to specify the query. To make the event queue durable across server failures and restarts, include the durable = true attribute in the annotation, as is done in the example:

    public class ContinuousQuery {
        @ContinuousQuery(name = "yourQuery",
           query = "SELECT * FROM /yourRegion WHERE someAttribute == true",
           durable = true)
        public void handleChanges(CqEvent event) {

    The class that contains the method with the @ContinuousQuery annotation must have the @Component annotation, such that the continuous query is wired up correctly for the server.

For more information, see the Spring Data GemFire documentation.