jboss7.xjboss-eap-6mod-cluster

Session replication on EAP JBOSS 6.0


I am working on Struts 2 framework with EAP Jboss 6. My project session variables were stored and retrieved using 'HTTP Session Map'. When I moved on to the Domain mode of Jboss with Clustering my session values were lost while switching between different nodes of the server. Then I configured Sticky session and stored the session values in Cookies. Even though I could able to retrieve value from cookie on the first request, the HTTP session was lost. Currently I'm using Apache Mod Cluster for clustering the configuration is as follows.

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

LoadModule proxy_cluster_module modules/mod_proxy_cluster.so

LoadModule manager_module modules/mod_manager.so
LoadModule slotmem_module modules/mod_slotmem.so
LoadModule advertise_module modules/mod_advertise.so

Listen 192.168.5.30:80

<VirtualHost 192.168.5.30:80>
 ManagerBalancerName my-cluster
 ServerName NSN
<Directory />
    Order deny,allow
    Allow from all
</Directory>
<Location /mod_cluster-manager>
    SetHandler mod_cluster-manager
    Order deny,allow
    Allow from all
</Location>
EnableMCPMReceive
#ProxyPass / balancer://my-cluster stickysession=JSESSIONID|jsessionid nofailover=On
 ProxyPass / balancer://my-cluster stickysession=off nofailover=On
 ProxyPassReverse / balancer://my-cluster
 ProxyPreserveHost On

      KeepAliveTimeout 60

      ServerAdvertise On

Now searched and found something about mod_cluster(https://github.com/modcluster/mod_cluster). In that it is mentioned to put the folder to 'deploy directory of a JBoss server profile'. But in EAP Jboss 6.0 domain mode I don't know where is deploy directory and how to configure that mod cluster?


Solution

  • I solved session replication by configuring jboss-web.xml under WEB-INF folder as follows...

    <?xml version="1.0" encoding="UTF-8"?>
    <jboss-web version="6.0"
           xmlns="http://www.jboss.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_6_0.xsd">
    <replication-config>
        <!-- The default value is SET_AND_NON_PRIMITIVE_GET, therefore the byte array which is carrying the data is considered
    non-primitive and would cause replication even in read only scenario. -->
        <replication-trigger>SET</replication-trigger>
    
        <!-- Replicating entire session is the default. -->
        <replication-granularity>SESSION</replication-granularity>
       <replication-mode>SYNCHRONOUS</replication-mode>
    </replication-config>
    

    In this case no need to use cookies to store values...