wildfly-clustering-spring is a set of Spring modules providing distributed session management for Spring Session and Spring Flux using Infinispan. This brings the same clustering features of WildFly's distributed session managers to the Spring ecosystem, including:
- Servlet 6.0 specification compliance (excluding limitations inherent to Spring Session and Spring Web).
- Including support for standard session event notifications
- Session attribute replication via an embedded cache or persistence to a remote Infinispan cluster.
- Configurable session replication/persistence strategies, i.e. per session vs per attribute.
- Similar semantics to that of an in-memory session repository, including a high level of consistency under concurrent request access, and support for mutable session attributes.
- Ability to limit the number of active sessions to retain in local memory
- Configurable session attribute marshallers.
-
Clone this repository.
$ git clone [email protected]:wildfly-clustering/wildfly-clustering-spring.git $ cd wildfly-clustering-spring -
Build using Java 17 or higher and Apache Maven 3.8.x or higher.
$ mvn clean install
- Spring Session, providing traditional HttpSession management for use with Jakarta Servlet applications and Spring MVC.
- Spring Web, providing reactive WebSession management for use with Spring Flux.
Because Spring Session and Spring Web operate entirely within user/application space (i.e. external to a servlet container's native session manager), its session management behavior will inherently deviate from the Jakarta Servlet specification in several areas. In particular, applications using Spring Session or Spring Web should be aware of the following aberrant behavior that affects every SessionRepository/WebSessionManager implementation:
-
ServletContextmethods affecting session behavior, e.g.ServletContext.setSessionTimeout(int), do not propagate to theSessionRepositoryorWebSessionManagerimplementation and thus will not affect runtime behavior. -
Spring Session and Spring Web lack any facility to notify standard listeners (instances of
HttpSessionListenerdeclared in web.xml or annotated with @WebListener) of newly created or destroyed sessions. Users must instead rely on Spring's own event mechanism. -
Spring Session and Spring Web lack any facility to notify standard listeners (instances of
HttpSessionAttributeListenerdeclared in web.xml or annotated with @WebListener) of new, replaced and removed session attributes. Spring has no mechanism for triggering these events. -
Spring Session and Spring Web lack any facility to notify standard listeners (instances of
HttpSessionIdListenerdeclared in web.xml or annotated with @WebListener) of session identifier changes resulting fromHttpServletRequest.changeSessionId(). Users must instead rely on Spring's own event mechanism. -
Applications using Spring Session or Spring Web will generally need to rely on Spring Security for authentication and authorization. Many authentication mechanisms store user identity in the
HttpSessionor will need to change the session ID following authentication - a common practice for preventing session fixation attacks. Since the servlet container has no access to sessions created by Spring, most container managed security mechanisms will not work.