This website uses cookies to ensure you get the best experience. Learn More.
Session Replication in Liferay DXP 7.4 with JBoss EAP 7.4.0
The following Pre-requisites are required before enabling session Replication:
Session Replication Overview
Session replication ensures that client sessions of distributable applications are not disrupted by failovers of nodes in a cluster. Each node in the cluster shares information about ongoing sessions and can take over sessions if a node disappears.
Session replication is the mechanism by which mod_cluster, mod_jk, mod_proxy, ISAPI, and NSAPI clusters provide high availability.
(More information regarding JBoss Session Replication can be found here )
We will be covering the below points:
Note: All the above points from 1 - 4 shall be followed in both the nodes
Making Liferay DXP Distributable:
Enabling Clustering in JBoss App Server:
For Clustering/HA JBoss Documentation suggests using standalone-ha.xml/standalone-full-ha.xml. We will be using standalone-full-ha.xml because it includes support for every possible subsystem, including those required for high availability. Also, it contains all the interfaces which are required for clustering and session replication. JBoss uses multicast, mod cluster, and UDP/TCP protocol for internode communications.
Adding Outbound socket to configure with Web Server (Optional):
The following steps are basic and can be amended as per the real-time requirements. We have used the basic setup of JBoss with JBCS HTTPD server with mod_cluster setup. You can use the Apache HTTPD web server, etc with mod_cluster setup, and can configure a similar kind of setup.
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> Just before the closing of the above tag i.e. </socket-binding-group> add the outbound socket, so that the App server is able to recognize the Frontend Server. <outbound-socket-binding name="lb1"> <remote-destination host="x.x.x.x" port="80"/> </outbound-socket-binding> where x.x.x.x is the Web server IP and 80 is the port on which it is Running. (You can change to 443 or another port as per the Web server Setup)
Now find the following tag <proxy name="default" advertise-socket="modcluster" listener="ajp"> in standalone-full-ha.xml and add the following attribute to the above tag proxies="lb1" Final tag will look like this: <proxy name="default" advertise-socket="modcluster" listener="ajp" proxies="lb1"> Make sure the proxies="value" is the same as the name attribute mentioned in the outbound socket in the previous step.
Below is a sample Virtual Host setting done in httpd.conf which is configured on the Web server. Listen x.x.x.x:80 <VirtualHost x.x.x.x:80> <Location /> Order deny,allow Require all granted Allow from tomcat </Location> KeepAliveTimeout 60 MaxKeepAliveRequests 0 EnableMCPMReceive On ManagerBalancerName lb1 ServerAdvertise On </VirtualHost> Note: Above settings are basic/generic, feel free to do changes as per the Web Server Admin's suggestions.
Session Replication Validation:
Once all the above changes are in place, we can now start both the nodes and web server to validate the Session replication behavior.
For Windows: standalone.bat -u 230.0.0.4 -Djboss.messaging.cluster.password=***** For Linux: ./standalone.sh -u 230.0.0.4 -Djboss.messaging.cluster.password=***** (Remember to make standalone.sh as executable if it is not already)
where 230.0.0.4 is the default multicast address (refer standalone-full-ha.xml)
There may be ample ways to configure Session Replication, the above is one of them If you are getting error like the following: Caused by: java.lang.IllegalArgumentException 'exmapleBean' attribute with type 'com.demo.portlet.example.' cannot be replicated at org.jboss.as.web.session.ClusteredSession.setAttribute(ClusteredSession.java:824) at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130) at com.liferay.portlet.PortletSessionImpl.setAttribute(PortletSessionImpl.java:200) Make sure all session objects and their attributes/variables are made Serializable.