4196f45b63 | 6 years ago | |
---|---|---|
.. | ||
redisson-tomcat-6 | 6 years ago | |
redisson-tomcat-7 | 6 years ago | |
redisson-tomcat-8 | 6 years ago | |
redisson-tomcat-9 | 6 years ago | |
README.md | 6 years ago | |
pom.xml | 6 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 6.x, 7.x, 8.x, 9.x
Please consider Redisson PRO version for advanced features and support by SLA.
Advantages
Current implementation differs from any other Redis based Tomcat Session Manager in terms of efficient storage and optimized writes. Each session attribute is written into Redis during each HttpSession.setAttribute
invocation. While other solutions serialize whole session each time.
Usage
1. Add RedissonSessionManager
Add RedissonSessionManager
into tomcat/conf/context.xml
<Manager className="org.redisson.tomcat.RedissonSessionManager"
configPath="${catalina.base}/redisson.conf" readMode="REDIS" updateMode="DEFAULT"/>
readMode
- read 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.
updateMode
- attributes update mode. Two modes are available:
DEFAULT
- session attributes are stored into Redis only through setAttribute method. Default mode.AFTER_REQUEST
- all session attributes are stored into Redis after each request.
configPath
- path to Redisson JSON or YAML config. See configuration wiki page for more details.
Shared Redisson instance
Each RedissonSessionManager created per Web Application and thus creates own Redisson instance. For multiple applications, using the same Redis setup, amount of Redisson instances could be reduced using JNDI registry:
- Add shared redisson instance produced by
JndiRedissonFactory
intotomcat/conf/server.xml
inGlobalNamingResources
tag area:
<GlobalNamingResources>
<Resource name="bean/redisson"
auth="Container"
factory="org.redisson.JndiRedissonFactory"
configPath="${catalina.base}/conf/redisson.yaml"
closeMethod="shutdown"/>
</GlobalNamingResources>
- Add
JndiRedissonSessionManager
with resource link to redisson instance intotomcat/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:
-
For JDK 1.8+
redisson-all-3.10.2.jarfor Tomcat 6.x
redisson-tomcat-6-3.10.2.jar
for Tomcat 7.x
redisson-tomcat-7-3.10.2.jar
for Tomcat 8.x
redisson-tomcat-8-3.10.2.jar
for Tomcat 9.x
redisson-tomcat-9-3.10.2.jar -
For JDK 1.6+
redisson-all-2.15.2.jarfor Tomcat 6.x
redisson-tomcat-6-2.15.2.jar
for Tomcat 7.x
redisson-tomcat-7-2.15.2.jar
for Tomcat 8.x
redisson-tomcat-8-2.15.2.jar