Skip to content

kevinhou01/spring-session-data-gemfire-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Session Example Application Using Pivotal GemFire for Session Management.

This example demonstrates a highly simple Spring Boot-based Spring Session Application using Pivotal GemFire to manage (HTTP) Sessions.

Requirements

  • Java Runtime Environment (JRE) 1.8
  • Gradle 2.2 (or higher)

Build

$ gradlew clean build install -x test

Run

First, you must setup a GemFire cluster to which the example Spring Boot, GemFire cache client application, using Spring Session (SpringSessionDataGemFireCacheClient) will connect. This example conveniently provides the src/main/resources/gemfire-cluster-setup.gfsh GemFire Shell (Gfsh) script to start the GemFire cluster.

The GemFire cluster consists of 1 GemFire Locator ("LocatorX") and 1 GemFire Server ("ServerA"). The Gfsh shell script will create the necessary "ClusteredSpringSessions" PARTITION Region as well as configure the Region's entry-idle-timeout-expiration, which is set to timeout after 1 second using an action of INVALIDATE.

To call the setup Gfsh shell script, run the following command in Gfsh...

gfsh> run --file=/path/to/spring-session-data-gemfire-example/src/main/resources/gemfire-cluster-setup.gfsh

The Gfsh shell script will also list and describe the members and Region to show the configuration. Once the GemFire Cluster is up and running, you can run the SpringSessionDataGemFireClient application class.

The Spring Boot application configures a GemFire cache client, connecting directly to the server on "localhost", port "40404". The application uses the Spring Session Data GemFire GemFireOperationsSessionRepository to create and save a new Session and then asserts that it has been successfully stored in the ClusteredSpringSessions Region unaltered.

This example additionally provides a Spring Boot Web application (SpringBootWebApplicationWithSpringSessionDataGemFireEnabled) that configures and bootstraps a GemFire cache client in the webapp using Spring Session backed by GemFire to manage the webapp's HttpSession. The webapp provides a couple Spring Web MVC endpoints that you can access from within your browser (or CURL).

Also, rather than externally (from your IDE) configure the GemFire cluster using and executing the provided Gfsh shell script, a SpringBootGemFireServer application class has been provided to launch the GemFire Server. However, you may want to tweak the maxInactiveIntervalInSeconds attribute when interacting with the Webapp, manually.

About

Example project demonstrating Spring Session with Pivotal GemFire support using Spring Data GemFire in a Spring Boot application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%