Implement Scheduler in Liferay 6.1
1) Make below entry in Liferay-portlet.xml
<
scheduler-entry
>
<
scheduler-description
>test-scheduler</
scheduler-description
>
<
scheduler-event-listener-class
>
com.test.scheduler.UploadJob
</
scheduler-event-listener-class
>
<
trigger
>
<
cron
>
<
cron-trigger-value
>0 0 18 * * ? *</
cron-trigger-value
>
</
cron
>
</
trigger
>
</
scheduler-entry
>
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 { LOGGER.info( "Scheduler----> receive()" ); //write your logic. } } |
Refer Apporva Blog also :http://www.apoorvaprakash.in/2011/02/liferay-scheduler.html |
can we implement liferay shedular in 6.0 , in case yes how ??
ReplyDelete