001
014
015 package com.liferay.portal.messaging;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.messaging.BaseMessageListener;
020 import com.liferay.portal.kernel.messaging.Message;
021 import com.liferay.portal.kernel.util.Time;
022 import com.liferay.portal.util.SubscriptionSender;
023
024 import org.apache.commons.lang.time.StopWatch;
025
026
029 public class SubscriptionSenderMessageListener extends BaseMessageListener {
030
031 @Override
032 protected void doReceive(Message message) throws Exception {
033 SubscriptionSender subscriptionSender =
034 (SubscriptionSender)message.getPayload();
035
036 StopWatch stopWatch = null;
037
038 if (_log.isInfoEnabled()) {
039 stopWatch = new StopWatch();
040
041 stopWatch.start();
042
043 _log.info(
044 "Sending notifications for {mailId=" +
045 subscriptionSender.getMailId() + "}");
046 }
047
048 subscriptionSender.flushNotifications();
049
050 if (_log.isInfoEnabled()) {
051 _log.info(
052 "Sending notifications for {mailId=" +
053 subscriptionSender.getMailId() + "} completed in " +
054 (stopWatch.getTime() / Time.SECOND) + " seconds");
055 }
056 }
057
058 private static Log _log = LogFactoryUtil.getLog(
059 SubscriptionSenderMessageListener.class);
060
061 }