001
014
015 package com.liferay.portal.kernel.cluster.messaging;
016
017 import com.liferay.portal.kernel.cluster.Address;
018 import com.liferay.portal.kernel.cluster.ClusterInvokeThreadLocal;
019 import com.liferay.portal.kernel.cluster.ClusterLinkUtil;
020 import com.liferay.portal.kernel.cluster.Priority;
021 import com.liferay.portal.kernel.log.Log;
022 import com.liferay.portal.kernel.log.LogFactoryUtil;
023 import com.liferay.portal.kernel.messaging.BaseMessageListener;
024 import com.liferay.portal.kernel.messaging.Message;
025
026
029 public class ClusterBridgeMessageListener extends BaseMessageListener {
030
031 public void setPriority(Priority priority) {
032 _priority = priority;
033 }
034
035 @Override
036 protected void doReceive(Message message) throws Exception {
037 if (!ClusterInvokeThreadLocal.isEnabled()) {
038 return;
039 }
040
041 Address address = ClusterLinkUtil.getAddress(message);
042
043 if (address == null) {
044 if (_log.isInfoEnabled()) {
045 _log.info("Bridging cluster link multicast message " + message);
046 }
047
048 ClusterLinkUtil.sendMulticastMessage(message, _priority);
049 }
050 else {
051 if (_log.isInfoEnabled()) {
052 _log.info(
053 "Bridging cluster link unicast message " + message +
054 " to " + address);
055 }
056
057 ClusterLinkUtil.sendUnicastMessage(address, message, _priority);
058 }
059 }
060
061 private static final Log _log = LogFactoryUtil.getLog(
062 ClusterBridgeMessageListener.class);
063
064 private Priority _priority;
065
066 }