Overview of Application Development with Spring Data GemFire

In Pivotal GemFire, a common architecture that separates the business logic from the system configuration is the client/server architecture. In this type of system, client application processes are cache clients that produce and consume data while server processes manage the distribution of data among the nodes of the system.

This type of architecture allows for a scalable, highly-available, low latency system where a farm of cache servers provide services to many clients.

For example, consider the basic/replicated-cs code example (See Spring Data GemFire Code Examples.) In the this example, The Server.java class, and the server/cache-config.xml file define a cache, its associated properties, a cache-server, a replicated region called Customer, and an associated cache listener. When this module is deployed, it defines a server node that can service data requests for the Customer data region.

Note: The cache-config.xml file discussed in this section is a Spring Framework application context XML file that is using the Spring Data GemFire namespace. See Configuring GemFire Components with the Spring Framework.

The server/cache-config.xml file contains the following configurations:

<util:properties id="gemfire-props">
  <prop key="log-level">warning</prop>
<gfe:cache properties-ref="gemfire-props"/>
<gfe:replicated-region id="Customer">
     <bean class="org.springframework.data.gemfire.examples.util.LoggingCacheListener"/>

The Server.java class only needs to reference the server/cache-config.xml file:

public class Server {
	 public static void main(String args[]) throws IOException {
		new ClassPathXmlApplicationContext("server/cache-config.xml");

The following configuration for the client creates a client cache, client region, and a connection pool to get data from the Customer region that was defined for the server.

<util:properties id="gemfire-props">
   <prop key="log-level">warning</prop>
<gfe:client-cache properties-ref="gemfire-props"/>
<gfe:client-region id="Customer" data-policy="empty"/>
	  <gfe:server host="localhost" port="40404"/>

The Client.java class uses the client cache to update data in the Customerclient region.

public class Client {

	public static void main(String args[]) throws IOException {
		ApplicationContext context = new ClassPathXmlApplicationContext("client/cache-config.xml");
		Region<Long,Customer> region = context.getBean(Region.class);
		Customer dave = new Customer(1L,new EmailAddress("dave@matthews.com"),"Dave","Matthews");
		Customer alicia = new Customer(2L,new EmailAddress("alicia@keys.com"),"Alicia","Keys");

You can enable subscriptions for client regions to synchronize data from a region defined in a cache server. The client can register interest in certain keys to receive notifications when data changes. To balance usage and improve performance, a client region uses connection pools to connect to a cache server.

For complete documentation of Spring Data GemFire, see the Spring Data GemFire Reference Guide . This guide, Pivotal GemFire User's Guide, provides complete documentation of Pivotal GemFire.