Wednesday, 19 September 2012

Liferay Scheduler

Implement Scheduler in Liferay 6.1

Many times we want our logic to be executed at certain Date/Time .Liferay 6.X comes with in built capability of scheduler. Here is the example which can help you ..!!
1) Make below entry in Liferay-portlet.xml

      <cron-trigger-value>0 0 18 * * ? *</cron-trigger-value>
This (<cron -trigger-value>0 0 18 * * ? *<cron -trigger-value>) indicates that the scheduler will run every day at 18:00 PM. To know how to write cron expression you can visit below links.
Cron Trigger
Cron Maker

2) create scheduler class.

package com.test.scheduler;
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.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
public class UploadJob implements MessageListener
    private static final Log LOGGER = LogFactoryUtil.getLog(UploadJob.class);
     * Job that we need to run on scheduler
    public void receive(Message arg0) throws MessageListenerException {
  "Scheduler----> receive()");
     //write your logic.
Source :

Refer Apporva Blog also :

1 comment:

  1. can we implement liferay shedular in 6.0 , in case yes how ??