Slide 1

Slide 1 text

Introducing Spring Session 2 Vedran Pavić @vedran_pavic

Slide 2

Slide 2 text

Agenda • About me • New in Spring Session 2 • Project Modules • Spring WebFlux Support • Improvements • Migrating to Spring Session 2 • Custom Session Repository

Slide 3

Slide 3 text

About Me - Vedran Pavić • Spring user for 9 years • Contributor to Spring projects for 2.5 years • Spring Session committer for 1.5 year

Slide 4

Slide 4 text

Project Modules • Spring Session 1.x was a single JAR • Convenient, but hard to evolve and maintain • Spring Session 2.0 is JAR per session store • Arrangement similar to Spring Data • Community extensions are welcome • Dedicated section in reference manual • Spring Boot and Initializr impact

Slide 5

Slide 5 text

Project Modules - Spring Session 1.3 • spring-projects/spring-session • spring-session (Core, Redis, Gemfire, MongoDB, JDBC, Hazelcast) • spring-session-data-redis (starter module) • spring-session-data-gemfire (starter module) • spring-session-data-mongo (starter module) • spring-session-jdbc (starter module) • spring-session-hazelcast (starter module)

Slide 6

Slide 6 text

Project Modules - Spring Session 2.0 • spring-projects/spring-session • spring-session-core • spring-session-data-redis • spring-session-jdbc • spring-session-hazelcast • spring-projects/spring-session-data-geode • spring-session-data-geode • spring-session-data-gemfire • spring-projects/spring-session-data-mongodb • spring-session-data-mongodb • spring-projects/spring-session-bom • spring-session-bom

Slide 7

Slide 7 text

Spring WebFlux Support • Follows the familiar Spring Session patterns • e.g. @EnableRedisHttpSession vs @EnableRedisWebSession • Much simpler than Servlet support • Key APIs are a part of spring-web • Redis & MongoDB session stores

Slide 8

Slide 8 text

Spring WebFlux Support Demo

Slide 9

Slide 9 text

Improvements - Core • Move to Java 8 & Spring 5 as baseline • Core API improvements • Refreshed Session & SessionRepository • HttpServletRequest#changeSessionId support • Configuration improvements • SessionCookieConfig support • Alignment of Servlet & WebFlux support • HttpSessionStrategy → HttpSessionIdResolver

Slide 10

Slide 10 text

Improvements - Repositories • Performance improvements • JdbcOperationsSessionRepository • HazelcastSessionRepository • Configuration improvements • Qualifier annotations for data stores • Data access components (e.g. RedisTemplate, JdbcTemplate) no longer registered as beans

Slide 11

Slide 11 text

Improvements Demo

Slide 12

Slide 12 text

Migrating to Spring Session 2 • Check your dependencies • spring-session JAR doesn’t exist in 2.0 • spring-session-data-mongo → spring-session-data-mongodb • Adapt to core API changes • Session, SessionRepository • Adapt to session resolution changes • HttpSessionStrategy → HttpSessionIdResolver • removed support for multiple sessions in a single browser

Slide 13

Slide 13 text

Custom Session Repository • Core Spring Session infra is easy to reuse • @EnableSpringHttpSession & @EnableSpringWebSession • Implementing session repository • Beware of race conditions - optimize session writes • Take care to purge the expired sessions • Support session event publishing, if possible • Provide supporting configuration classes

Slide 14

Slide 14 text

Custom Session Repository Demo

Slide 15

Slide 15 text

Contribute to Spring Session • Issue tracker • https://github.com/spring-projects/spring-session/issues • Gitter chat • https://gitter.im/spring-projects/spring-session • Stack Overflow tag • https://stackoverflow.com/questions/tagged/spring-session • From Zero to Open Source Hero @ Spring I/O 2017 • https://www.youtube.com/watch?v=D7OJFWNx-ks

Slide 16

Slide 16 text

Related Talks • Under the Hood of Reactive Data Access • Thursday @ 17:30 • Spring Boot 2.0 Web Applications • Friday @ 9:00 • Next Generation OAuth Support with Spring Security 5 • Friday @ 17:00

Slide 17

Slide 17 text

THANKS! Q & A Vedran Pavić @vedran_pavic