Overview
One of the high availability methods provided by glassfish, is session replication.
With session replication enabled, the server distributes session data across the cluster. If one cluster instances crashes, the session is still available on the other instances.
Requirements
- A recent glassfish installation (versions prior to 2.1.1 had some bugs).
- A configured cluster (Look here who to install a glassfish cluster).
- All cluster instances located in the same subnet. (later glassfish version should support different subnets)
Configure session replication
- Add a <distributable /> tag to your web.xml
<web-app> <distributable /> ... </web-app>
- Add following lines to your sun-web.xml
<session-config> <session-manager persistence-type="replicated"> <manager-properties> <property name="persitencerequency" value="web-method" /> </manager-properties> <store-properties> <property name="persistenceScope" value="session" /> </store-properties> </session-manager> </session-config>- persistenceType=”replicated” says, that the session should be replicated along the cluster.
- persistenceFrequency=”web-method” says that the session state should be stored after processing a request, but before sending the response. (other values: time-based)
- persistenceScope=”session” says that the whole session state should be stored. (other values: modified-session, modified-attribute)
- Deploy application
- using the web-interface: check the Availability checkbox.
- using the cli: add –availabilityenabled=true parameter.
Notes
- Be sure that all classes that are going to be stored in a session implements the Serializable interface.
If not, the server can’t serialize it and replication won’t work. - As already mentioned, the instances have to be on the same subnet, otherwise session replication will not work.
June 23rd, 2010 on 09:46
How can I disable the session ?
June 30th, 2010 on 11:16
What do you mean with “disable the session” ?