liferay Create a Quartz scheduler in liferay Create a quartz scheduler to display some information


In order to create a scheduler,the entry needs to be created in


provding scheduler class and trigger value for timing of scheduler triggering

        <scheduler-description>This scheduler logs User count from portal</scheduler-description>

The given entry provides

  1. Scheduler description

  2. Class name,which implements MessageListener class

  3. Trigger,which provides intervals for defining trigger point for scheduler

    -Using Cron

    -Using Simple trigger value

In the given example,the scheduler will trigger after every 5 mins.

Next up we need to create scheduler class

package com.example.scheduler;

import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;
import com.liferay.portal.service.UserLocalServiceUtil;

public class SchedulerSample implements MessageListener {

    public void receive(Message arg0) throws MessageListenerException {
        Log log=LogFactoryUtil.getLog(SchedulerSample.class);
        try {
  "User Count for portal:"+UserLocalServiceUtil.getUsersCount());
        } catch (SystemException e) {
  "User count is currently unavailable");


This scheduler simply displays output portal user count after every trigger interval to server console.