Creating Scheduler in liferay - creating the scheduler dynamically based on the user inputs

As we know creating the static scheduler  is very easy as we  defined in the following url as
   http://liferaytutorial.blogspot.com/2013/08/creating-scheduler-in-liferay.html

Sometimes it may require to create dynamic schedule. Liferay had some created predefined class.

Scheduling:

In Messageboard portlet , Take a look at the MBMailingListLocalServiceImpl of  "protected void scheduleMailingList(MBMailingList mailingList) " method


              Calendar startDate = CalendarFactoryUtil.getCalendar();

CronText cronText = new CronText(startDate, CronText.MINUTELY_FREQUENCY,
mailingList.getInReadInterval());

Trigger trigger = new CronTrigger(groupName, groupName, startDate.getTime(), null,
cronText.toString());


                SchedulerEngineUtil.schedule(trigger, StorageType.MEMORY_CLUSTERED, null,
DestinationNames.MESSAGE_BOARDS_MAILING_LIST, mailingListRequest,
0);

UnScheduling:

    protected void unscheduleMailingList(MBMailingList mailingList)
throws PortalException {

String groupName = getSchedulerGroupName(mailingList);

SchedulerEngineUtil.unschedule(groupName, StorageType.MEMORY_CLUSTERED);
}

Have a look at the TriggerFactoryUtil and SchedulerEngineUtil.

We can also Pause , Resume and delete the schedule.

Comments

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate