Implementation of a session manager for Tomcat using Mongo as a backing store
Java
Switch branches/tags
Nothing to show
Latest commit a5ea6ad Oct 9, 2012 @dawsonsystems dawsonsystems Remove groovy and kryo deps.
Add apache license headers to source in addition to the pom ref.
Remove gmaven usage
Permalink
Failed to load latest commit information.
src Remove groovy and kryo deps. Oct 8, 2012
.gitignore Add gitignore Nov 7, 2011
README.md Add readme Feb 24, 2011
pom.xml

README.md

Mongo Tomcat Session Manager

Overview

This is a tomcat session manager that saves sessions in MongoDB. It is made up of MongoManager, that provides the save/load functions, and MongoSessionTrackerValve that controls the timing of the save.

For those interested, PersistentManager/ an implementation of a SessionStore is non deterministic in when it saves to the DB, so isn't suitable as a distributed session replicator. This is why I've used a valve to control the save timing at the end of each request.

Usage

Add the following into your tomcat server.xml, or context.xml

<Valve className="com.dawsonsystems.session.MongoSessionTrackerValve" />
<Manager className="com.dawsonsystems.session.MongoManager" host="dbHost1,dbHost2" port="27017" database="sessions" maxInactiveInterval="84"/>

The Valve must be before the Manager.

The following parameters are available on the Manager :-

maxInactiveIntervalThe initial maximum time interval, in seconds, between client requests before a session is invalidated. A negative value will result in sessions never timing out. If the attribute is not provided, a default of 60 seconds is used.
processExpiresFrequencyFrequency of the session expiration, and related manager operations. Manager operations will be done once for the specified amount of backgrondProcess calls (i.e., the lower the amount, the more often the checks will occur). The minimum value is 1, and the default value is 6.
hostThe database hostnames(s). Multiple hosts can be entered, seperated by a comma
portThe database port to connect to. The same port will be used for each database host. The default is 27017
databaseThe database used to store sessions in, the default is 'sessions'

Put the mongo-store jar and the mongo java driver (I've tested with 2.3) into the tomcat lib directory and you're good to go.