Configuring a Client/Server Architecture

To use the GemFire client/server architecture, you configure both cache servers and client caches.

Cache servers operate in a peer-to-peer relationship with other cache servers. Multiple client processes can connect to cache servers to retrieve and update data. Clients connect using connection pools.

The following Spring application context XML configuration (from the basic/replicated-cs example) declares a cache server:
<gfe:cache-server/>
The following Java class (from the basic/replicated-cs example) references the Spring application context XML configuration file to create the server:
public class Server {
	 public static void main(String args[]) throws IOException {
  ...		

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

You configure a GemFire client cache to access data from a cache server. In this type of architecture, many clients can connect to a smaller number of cache servers. The clients can use connection pools to connect to the servers.

The following Spring application context XML configuration (from the basic/replicated-cs example) creates a client cache:
<gfe:client-cache />
The following Java code (from the basic/replicated-cs example) uses a client cache to update data:
public class Client {

	@SuppressWarnings("unchecked")
	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");
		region.put(dave.getId(),dave);
		region.put(alicia.getId(),alicia);
		 
	}
}

Additional Resources