Configuring Continuous Querying

Continuous querying allows you to create a query and then receive notifications when new data is added that matches the query. Continuous querying requires a client/server topology and the pool must enable the subscription property.

The following client Spring application context XML configuration (from the quickstart/cq example) declares a pool and a continuous query listener container, and enables continuous query for a POJO (the cqListener bean).
<gfe:client-cache pool-name="client-pool" properties-ref="gemfire-props"/>

<gfe:pool id="client-pool" subscription-enabled="true">
    <gfe:server host="localhost" port="40404"/>
</gfe:pool>
    
<gfe:cq-listener-container>
     <gfe:listener 
      ref="cqListener"  
      query="select * from /Order where customerId = 2"/>
</gfe:cq-listener-container> 
    
<bean id="cqListener" 
      class="org.springframework.data.gemfire.examples.CQListener"/>
    
The following Java class (from the quickstart/cq example) creates a continuous query listener from the POJO defined in the XML configuration.
public class CQListener {
	
	private static Log log = LogFactory.getLog(CQListener.class);

	public void handleEvent(CqEvent event) {
		log.info("Received a CQ event " + event);
	}
}

Additional Resources