Session State Caching
with Spring Session & Apache Geode
John Blum - @john_blum
1
Our story continues…
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
How	does	Spring	help?
Apache	Geode	 Pivotal	GemFire	
Spring	Session		 SDG	 Spring	Framework	Spring	Boot
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring	Session		
SDG	
Spring	Framework	
Spring	Boot
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring	Session		
-	Replaces	H(pSession	in	app	container	(e.g.	Tomcat)	
-	Support	for	REST-ful	APIs	by	placing	Session	ID	in	headers	
-	Keeps	HIpSession	alive	when	receiving	WebSocket	messages	
-	Replaces	WebFlux’s	WebSession	in	app	container	neutral	way
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Cloud-Ready Data Management Solution…
In-Memory Data Grid (IMDG)
Apache	Geode	 Pivotal	GemFire
*	Clustered	
Par@@oned	-	Redundant	
Memory
*	Clustered	
Par@@oned	-	Redundant	
Mul@-Site
Enough Talk
Show me the code!
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
HTTP	
Spring	Session		
Request/Response	
SDG	
SessionRepositoryFilter	
<Filter>	
HIpServletRequest	
SessionRepositoryRequestWrapper	
SessionRepository	
.createSession()
.findById(sessionId)
GemFireSession	
<Session>	
.findByIndexNameAndIndexValue(..)
HIpSessionWrapper	
HIpSessionAdapter	
<H,pSession>	
hIps://docs.spring.io/spring-session/docs/2.0.2.RELEASE/reference/html5/#hIpsession-how	
Spring	Boot
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#xml-servlet-container-iniXalizaXon
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#client-configuraXon	
hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#java-servlet-container-iniXalizaXon
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring	Boot
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
H,pServletRequest	
H,pSession	
Session	
SessionRepository	
API	
Spring	Session		
-  Query	(findBy…)	
-  Indexing	
-  Deltas	
-  Custom	ExpiraXon	
-  Custom	SerializaXon
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Session for Apache Geode & Pivotal GemFire
Spring Session
Using Apache Geode or Pivotal GemFire
with Spring Session Data Geode/GemFire
Simplifies (HTTP) Session State Management
+	+	|
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring for Apache Geode & Pivotal GemFire
Spring Framework & Spring Data
Using Apache Geode or Pivotal GemFire
with Spring’s Cache Abstraction & Spring Data Geode/GemFire
Works as a JSR-107 JCache caching provider
+	| +
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Boot for Apache Geode & Pivotal GemFire
Spring Boot
Using Apache Geode or Pivotal GemFire
with Spring Boot Data Geode/GemFire
Gets you up and running as quickly and easily as possible
+	 +	|
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Apache Geode to Pivotal GemFire on PCF
System of Record (SOR)…
!  Basic CRUD and simple Querying with Spring Data Repositories (OLTP)
!  Continuous Queries for Event Stream Processing
!  Function Executions for Distributed Compute
!  WAN for Site-to-Site Replication, HA, Disaster Recovery
20
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring	Session		 SDG	 Spring	Framework	Spring	Boot	
Apache	Geode	 Pivotal	GemFire
Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
References
•  Project Page: https://github.com/spring-projects/spring-session-data-geode
•  Spring Session Data GemFire/Geode Reference Documentation:
https://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/
•  Spring Session Reference Documentation:
https://docs.spring.io/spring-session/docs/2.0.2.RELEASE/reference/html5/#introduction
•  StackOverflow: https://stackoverflow.com/questions/tagged/spring-session
•  Pivotal CloudFoundry (PCF) Pivotal Cloud Cache (PCC) with Session State Caching (SSC):
https://docs.pivotal.io/ssc-gemfire/index.html
•  Presentation Examples: https://github.com/jxblum/spring-session-data-gemfire-example
•  Apache Tomcat (9.0) Cluster (by comparison): https://tomcat.apache.org/tomcat-9.0-doc/cluster-howto.html
Me: @john_blum (Twitter) https://spring.io/team/jxblum (GitHub) https://github.com/jxblum
Questions
Answers
24© 2014	Pivotal	Soaware,	Inc.		All	rights	reserved.
Thank You

Session State Caching with Spring

  • 1.
    Session State Caching withSpring Session & Apache Geode John Blum - @john_blum 1
  • 2.
  • 4.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ How does Spring help?
  • 5.
  • 6.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Session SDG Spring Framework Spring Boot
  • 7.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Session - Replaces H(pSession in app container (e.g. Tomcat) - Support for REST-ful APIs by placing Session ID in headers - Keeps HIpSession alive when receiving WebSocket messages - Replaces WebFlux’s WebSession in app container neutral way
  • 8.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cloud-Ready Data Management Solution… In-Memory Data Grid (IMDG) Apache Geode Pivotal GemFire
  • 9.
  • 10.
  • 11.
  • 12.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ HTTP Spring Session Request/Response SDG SessionRepositoryFilter <Filter> HIpServletRequest SessionRepositoryRequestWrapper SessionRepository .createSession() .findById(sessionId) GemFireSession <Session> .findByIndexNameAndIndexValue(..) HIpSessionWrapper HIpSessionAdapter <H,pSession> hIps://docs.spring.io/spring-session/docs/2.0.2.RELEASE/reference/html5/#hIpsession-how Spring Boot
  • 13.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#xml-servlet-container-iniXalizaXon
  • 14.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#client-configuraXon hIps://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/#java-servlet-container-iniXalizaXon
  • 15.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot
  • 16.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ H,pServletRequest H,pSession Session SessionRepository API Spring Session -  Query (findBy…) -  Indexing -  Deltas -  Custom ExpiraXon -  Custom SerializaXon
  • 17.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Session for Apache Geode & Pivotal GemFire Spring Session Using Apache Geode or Pivotal GemFire with Spring Session Data Geode/GemFire Simplifies (HTTP) Session State Management + + |
  • 18.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring for Apache Geode & Pivotal GemFire Spring Framework & Spring Data Using Apache Geode or Pivotal GemFire with Spring’s Cache Abstraction & Spring Data Geode/GemFire Works as a JSR-107 JCache caching provider + | +
  • 19.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Boot for Apache Geode & Pivotal GemFire Spring Boot Using Apache Geode or Pivotal GemFire with Spring Boot Data Geode/GemFire Gets you up and running as quickly and easily as possible + + |
  • 20.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode to Pivotal GemFire on PCF System of Record (SOR)… !  Basic CRUD and simple Querying with Spring Data Repositories (OLTP) !  Continuous Queries for Event Stream Processing !  Function Executions for Distributed Compute !  WAN for Site-to-Site Replication, HA, Disaster Recovery 20
  • 21.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Session SDG Spring Framework Spring Boot Apache Geode Pivotal GemFire
  • 22.
    Unless otherwise indicated,these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ References •  Project Page: https://github.com/spring-projects/spring-session-data-geode •  Spring Session Data GemFire/Geode Reference Documentation: https://docs.spring.io/autorepo/docs/spring-session-data-geode-build/2.0.2.RELEASE/reference/html5/ •  Spring Session Reference Documentation: https://docs.spring.io/spring-session/docs/2.0.2.RELEASE/reference/html5/#introduction •  StackOverflow: https://stackoverflow.com/questions/tagged/spring-session •  Pivotal CloudFoundry (PCF) Pivotal Cloud Cache (PCC) with Session State Caching (SSC): https://docs.pivotal.io/ssc-gemfire/index.html •  Presentation Examples: https://github.com/jxblum/spring-session-data-gemfire-example •  Apache Tomcat (9.0) Cluster (by comparison): https://tomcat.apache.org/tomcat-9.0-doc/cluster-howto.html Me: @john_blum (Twitter) https://spring.io/team/jxblum (GitHub) https://github.com/jxblum
  • 23.
  • 24.