You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
redisson/redisson-tomcat
Nikita Koksharov b54f4d768b [maven-release-plugin] prepare release redisson-3.13.6 4 years ago
..
redisson-tomcat-7 [maven-release-plugin] prepare release redisson-3.13.6 4 years ago
redisson-tomcat-8 [maven-release-plugin] prepare release redisson-3.13.6 4 years ago
redisson-tomcat-9 [maven-release-plugin] prepare release redisson-3.13.6 4 years ago
README.md Update README.md 4 years ago
pom.xml [maven-release-plugin] prepare release redisson-3.13.6 4 years ago

README.md

Redis based Tomcat Session Manager

Stores session of Apache Tomcat in Redis and allows to distribute requests across a cluster of Tomcat servers. Implements non-sticky session management backed by Redis.

Supports Apache Tomcat 7.x, 8.x, 9.x

Consider Redisson PRO version for advanced features and support by SLA.

Usage

1. Add session manager

Add RedissonSessionManager in tomcat/conf/context.xml or per context in tomcat/conf/server.xml

<Manager className="org.redisson.tomcat.RedissonSessionManager"
  configPath="${catalina.base}/redisson.conf" 
  readMode="REDIS" updateMode="DEFAULT" broadcastSessionEvents="false"
  keyPrefix=""/>

keyPrefix - string prefix applied to all Redis keys. Allows to connection different Tomcat envirounments to the same Redis instance.

readMode - read Session attributes mode. Two modes are available:

  • MEMORY - stores attributes into local Tomcat Session and Redis. Further Session updates propagated to local Tomcat Session using Redis-based events.
  • REDIS - stores attributes into Redis only. Default mode.

broadcastSessionEvents - if true then sessionCreated and sessionDestroyed events are broadcasted across all Tomcat instances and cause all registered HttpSessionListeners to be triggered. Default is false.

updateMode - Session attributes update mode. Two modes are available:

  • DEFAULT - session attributes are stored into Redis only through Session.setAttribute method. Default mode.
  • AFTER_REQUEST - all session attributes are stored into Redis after each request. It useful in case when some objects stored in session change own state without Session.setAttribute method execution.

configPath - path to Redisson YAML config. See configuration wiki page for more details.

Shared Redisson instance

Amount of Redisson instances created by Tomcat for multiple contexts could be reduced through JNDI registry:

  1. Add shared redisson instance produced by JndiRedissonFactory into tomcat/conf/server.xml in GlobalNamingResources tag area:
  <GlobalNamingResources>
    <Resource name="bean/redisson"
	      auth="Container"
              factory="org.redisson.JndiRedissonFactory"
              configPath="${catalina.base}/conf/redisson.yaml"
	      closeMethod="shutdown"/>
  </GlobalNamingResources>
  1. Add JndiRedissonSessionManager with resource link to redisson instance into tomcat/conf/context.xml
    <ResourceLink name="bean/redisson"
                  global="bean/redisson"
		  type="org.redisson.api.RedissonClient" />

    <Manager className="org.redisson.tomcat.JndiRedissonSessionManager"
         readMode="REDIS"
         jndiName="bean/redisson" />

2. Copy two jars into TOMCAT_BASE/lib directory:

redisson-all-3.13.5.jar

for Tomcat 7.x
redisson-tomcat-7-3.13.5.jar
for Tomcat 8.x
redisson-tomcat-8-3.13.5.jar
for Tomcat 9.x
redisson-tomcat-9-3.13.5.jar