This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Tomcat session replication on failover in a cluster Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat session replication on failover in a cluster" Watch "Tomcat session replication on failover in a cluster" New topic
Author

Tomcat session replication on failover in a cluster

Paul Jacob
Greenhorn

Joined: Jul 25, 2009
Posts: 15
Hi, I am running two instances of Tomcat 6.0.20 on the same Windows XP machine with apache 2.2.14 in the front and using mod_jk 1.2.28 for load balancing.

I want to enable session replication. I followed all the http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html but it does not behave as expected. I am using the following configuration in server.xml on both instances:

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">


<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="true"
useDirtyFlag="true"
notifyListenersOnReplication="true"/>

<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4"
port="45564"
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto"
port="4000" (4001 on the second node)
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>

<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
</Channel>

<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.html;.*\.css;.*\.txt;"/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" enabled="true" sessionIdAttribute="takeoverSessionid"/>

<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>


</Host>

I tried the above with the <Cluster> element within the <Engine> element too. But the result was the same as given below.

Unfortunately I am getting a message saying 'skipping state transfer. No members active in cluster group' on the second node.
Also, the behaviour is as follows:
1) Start node1, Start node2
2) Hit url ... it goes to node1
3) shutdown node1 and refresh url ... it goes to node2
4) Now, shutdown node2 & start node1
5) User is logged out.

This is not seamless session replication with failover. Am I missing something in the configuration or is it something that just cannot be done?


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61447
    
  67

"Morgan Stanley", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Jacob
Greenhorn

Joined: Jul 25, 2009
Posts: 15

Anyone faced the same problem?? This is really urgent for a project.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10239
    
168

Also, the behaviour is as follows:
1) Start node1, Start node2
2) Hit url ... it goes to node1
3) shutdown node1 and refresh url ... it goes to node2
4) Now, shutdown node2 & start node1
5) User is logged out.

This is not seamless session replication with failover. Am I missing something in the configuration or is it something that just cannot be done?


When you shutdown node1 in step#3, then there's no way the session will be replicated from node2 to node1. So in step#4 when you shutdown node#2 and start node#1, it would start afresh.

[My Blog] [JavaRanch Journal]
 
Consider Paul's rocket mass heater.
 
subject: Tomcat session replication on failover in a cluster