Liferay Cluster with cluster link

In this tutorial  we will see Liferay cache replication with Cluster Link.Cluster link is most preferable solution for Liferay cluster cache replication over other. This cluster link replication technique is available in Liferay Enterprise Edition only and  requires  ehcache-cluster-web plugin need to be deployed in servers.

What is Cluster Link?

  • Cluster Link is implemented with combination of MessageListener and  JGroups Framework
  • ClusterLinkPortalCacheClusterListener is a class extending BaseMessageListener   for receiving messages with destinationName as “liferay/ehcache_cluster”
  • JGroups as underlying framework for creating controlling and  transport messages over multiple channels.This is most powerful feature of JGroups to use multiple channels for cache replication.
    • Control Channel – this channel is used for controlling order of messages and retransmission of messages
    • Transport Channel – this channel is used as data channel to transfer message. This is not a retransmit layer if there are packets losses. In this case, control channel will resend losing packets.
  • With that said, Liferay need to configure JGroup properties to configure channels,one for controlling and others for transporting packets. Liferay supports up to  1 single control channel and 10 transport channels only.By default, only one UDP control channel and one UDP transport channel are enabled.
  • Liferay can be configured with multiple transport channels for better performance. The below  settings can be used  customize transport and control channels in                       
  • Ehcache-cluster-web plugin has two spring xml files to initiate cluster link message listener and channels.
    • ehcache-cluster-spring.xml – this spring config file initiate PortalCacheClusterLinkUtil and its dependencies to send cache events over JGroups channel. It has sendEvent(PortalCacheClusterEvent portalCacheClusterEvent)  method to send events
    • messaging-spring.xml  – this will  instantiate ClusterLinkPortalCacheClusterListener bean to receive message those trigger by PortalCacheClusterLinkUtil.

Liferay cluster setup with cluster link

  • Create folder myehcache in tomcat/webapps/ROOT/WEB-INF/classes and copy hibernate-clustered.xml and liferay-multi-vm-clustered.xml files. Click here to download myehcache folder
  • you no need to create myehcache folder explicitly as ehcache plugin will load all the required files. but  if you are planning to edit cache settings for Liferay core entitiy then copy this folder.
  • Now copy below properties to portal-ext.propeties
  •  If application requires more transport channels then extract jgroups.jar in lib folder and copy udp.xml, mping.xml  files into myehcache folder also. Modify udp.xml and mping.xml files to update mcast group address.  This step is not required
  • #### Not mandatory Fields If you are planning to change entities and disc memory configuration #######
    #### If planning use multiple transport channels ####

    We have completed cluster setup and delete tables prefixed with QUARTZ and start all nodes.

Other tutorials:

Liferay Cache Replication With JGroups

Liferay Cache Replication with JGroups tutorial will give you details on “How to setup cache replication with JGroups” READ MORE

Liferay Cache Replication  with RMI

In this tutorial, we will configure Liferay clustering with  RMI replication technique. RMI is default EHCache replication implementation method and uses over  TCP protocol.  READ MORE

Leave a Reply