Using Clustering


JBoss supports clustering in the embedded Tomcat service. The steps to set up clustering of Tomcat embedded containers are as follows:

1.

If you are using a load balancer, make sure that your setup uses sticky sessions. This means that if a user starts a session on node A, all subsequent requests are forwarded to node A, as long node A is up and running. For details on configuration of Apache sticky sessions, see www.ubeans.com/tomcat.

2.

If you aren't using the all configuration, make sure that cluster-service.xml is in your deploy directory. If it isn't there, copy cluster-service.xml from server/all/deploy into your deploy directory. You also need the jgroups.jar in your lib directory. You can find it in the server/all/lib directory.

3.

Start JBoss to check whether your setup works. Look at the JMX management console (http://localhost:8080/jmx-console/). Find the jboss.cache:service=TomcatClusteringCache MBean. StateString must be Started. If it is Stopped, look in the server's log file.

4.

To enable clustering of web applications, you must mark them as distributable in the web.xml descriptor. Here's an example:

 <?xml version="1.0"?> <!DOCTYPE web-app PUBLIC     "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"     "http://java.sun.com/dtd/web-app_2_3.dtd "> <web-app>     <distributable/>     <!-- ... --> </web-app> 

5.

Deploy your WAR as usual, and it should now be clustered.

If you have deployed and accessed your application, go back to the jboss.cache:service=TomcatClusteringCache MBean and invoke the printDetails operation. You should see output resembling the following:

 /JSESSION /n6HywRwITbY-xvzaZ0LS5Q** n6HywRwITbY-xvzaZ0LS5Q**: org.jboss.invocation.MarshalledValue@9c1dddab /R1T4Dapn7c8T-+Ynd9v9MA** R1T4Dapn7c8T-+Ynd9v9MA**: org.jboss.invocation.MarshalledValue@8c0f60b6 

This output shows two separate web sessions that are being shared via JBossCache. If you don't see any output, either the application was not correctly marked as distributable or you haven't accessed the part of application that places values in the HTTP session.



JBoss 4. 0(c) The Official Guide
JBoss 4.0 - The Official Guide
ISBN: B003D7JU58
EAN: N/A
Year: 2006
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net