Skip to content

Latest commit

 

History

History
132 lines (98 loc) · 5.45 KB

README.adoc

File metadata and controls

132 lines (98 loc) · 5.45 KB
appng logo 760px

appNG Tomcat Session

This library contains implementations of Apache Tomcats org.apache.catalina.Manager using Redis, Hazelcast and MongoDB.

Prerequisites

By default, Tomcats uses it’s own logging component named JULI, writing logfiles to CATALINA_HOME/logs.

However, if you want to see some logging in the appNG.log of your appNG installation, move the following files from APPNG_HOME/WEB-INF/lib into the CATALINA_HOME/lib directory:

  • log4j-1.2.17.jar

  • slf4j-api-1.7.25.jar

  • slf4j-log4j12-1.7.25.jar

Next, set the category for org.appng.tomcat.session in APPNG_HOME/WEB-INF/conf/log4j.properties to the required level:

log4j.category.org.appng.tomcat.session = trace

Using Redis

This implementation uses Redis to store sessions. It is based on the great work of James Coleman’s tomcat-redis-session-manager.

A few changes were made to support Tomcat 8 and the latest version of Redis.

Configuration

Add the following into your Tomcat context.xml (or the context block of the server.xml if applicable.)

<Valve className="org.appng.tomcat.session.redis.RedisSessionHandlerValve" />
<Manager className="org.appng.tomcat.session.redis.RedisSessionManager"
    host="localhost"
    port="6379"
    database="0"
    maxInactiveInterval="60"
    sessionPersistPolicies="ALWAYS_SAVE_AFTER_REQUEST" />

Copy the following files into the TOMCAT_BASE/lib directory:

Reboot the server, and sessions should now be stored in Redis.

Using MongoDB

This implementation uses MongoDB to store sessions.

Configuration

Add the following into your Tomcat context.xml (or the context block of the server.xml if applicable.)

<Valve className="org.appng.tomcat.session.mongo.MongoSessionTrackerValve" />
<Manager className="org.appng.tomcat.session.mongo.MongoPersistentManager" maxIdleBackup="30">
	<Store className="org.appng.tomcat.session.mongo.MongoStore"
		hosts="localhost:27017"
		dbName="tomcat_sessions"
		maxPoolSize="25"
	/>
</Manager>

Copy the following files into the TOMCAT_BASE/lib directory:

Reboot the server, and sessions should now be stored in MongoDB.

Using Hazelcast

The implementation is based on Hazelcast, using a ReplicatedMap

Configuration

Add the following into your Tomcat context.xml (or the context block of the server.xml if applicable.)

<Valve className="org.appng.tomcat.session.hazelcast.HazelcastSessionTrackerValve" />
<Manager className="org.appng.tomcat.session.hazelcast.HazelcastPersistentManager">

	<!-- standard configuration, using multicast -->
	<Store className="org.appng.tomcat.session.hazelcast.HazelcastStore" mode="multicast" port="5701" instanceName="appNG" group="dev"
		multicastGroup="224.2.2.3" multicastPort="54327" multicastTimeoutSeconds="2" multicastTimeToLive="32" />
	<!-- optionally, for all modes except 'classpath':
		managementCenterUrl="http://localhost:8080/hazelcast-mancenter"
	-->

	<!-- uses a config file from the classpath -->
	<!-- Store className="org.appng.tomcat.session.hazelcast.HazelcastStore" mode="classpath" configFile="hazelcast.xml" /-->

	<!-- uses tcp, allowing to use a comma separated list of addresses -->
	<!-- Store className="org.appng.tomcat.session.hazelcast.HazelcastStore" mode="tcp" port="5701" instanceName="appNG" group="dev"
		tcpMembers="localhost:5701" /-->

	<!-- client mode, allowing to use a comma separated list of addresses -->
	<!-- Store className="org.appng.tomcat.session.hazelcast.HazelcastStore" mode="client" instanceName="appNG" group="dev"
		addresses="localhost:5701" /-->

	<!-- standalone mode, for development purposes -->
	<!-- Store className="org.appng.tomcat.session.hazelcast.HazelcastStore" mode="standalone" port="5701" instanceName="appNG" group="dev" /-->
</Manager>

Copy the following files into the TOMCAT_BASE/lib directory:

When using client-mode, you also need * hazelcast-client-3.12.3.jar

Reboot the server, and sessions are now stored in Hazelcast.

License

appNG is licensed under the Apache License 2.0.