Pivotal GemFire® v8.0

Overview of Application Development with Spring Data GemFire

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 this example, the 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=""/>

The class reserves the fixed port number 4040, and then references the server/cache-config.xml file for configuration:

public class Server {
	 public static void main(String args[]) throws IOException {
		try {
			new ServerPortGenerator().bind(new ServerSocket(), 40404,1);
		} catch (IOException e) {
			System.out.println("Sorry port 40404 is in use. Do you have another cache server process already running?");

		new ClassPathXmlApplicationContext("server/cache-config.xml");

		System.out.println("Press <Enter> to terminate the server");;

The client/cache-config.xml configuration file simply defines a datasource for connecting to the server:

  		<gfe-data:server host="localhost" port="40404"/>

The class uses the configuration file to create an application context and get the Customer region, and then creates and puts new Customer entries in the 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");
		Customer alicia = new Customer(2L,new EmailAddress(""),"Alicia","Keys");

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.