留言板

Liferay scheduler does not work after tomcat restart

Hemanth KN,修改在6 年前。

Liferay scheduler does not work after tomcat restart

New Member 帖子: 4 加入日期: 17-3-8 最近的帖子
Hello,
I am working on Liferay 6.2 scheduler, I have noticed that when the tomcat server is restarted , the scheduler does not work.
Lets say i have scheduled for tomorrow and today i re start it for some reason. Then the scheduler does not trigger tomorrow at all.
Am i missing something to re set when the server is started. Please find the snippet below.

Code snippet to create a scheduler
com.liferay.portal.kernel.messaging.Message message = new com.liferay.portal.kernel.messaging.Message();
message.put(SchedulerConstants.DI_ID, diId);
message.put(SchedulerConstants.CAPS_ENABLEMENT_DATE, goLiveDate);
String cronExpression = getCronExpression(goLiveDate);
Trigger trigger = new CronTrigger(SchedulerConstants.CAPS_ENABLEMENT_JOB +"_"+diId+"_"+goLiveDate, diId, new Date(), null, cronExpression);
MessageBusUtil.registerMessageListener(DestinationNames.SCHEDULER_DISPATCH, capsEnablementJob);
SchedulerEngineHelperUtil.schedule(trigger, StorageType.PERSISTED, trigger.getJobName(), DestinationNames.SCHEDULER_DISPATCH, message, 10);

And on receive i have the code snippet as below
public void receive(Message message) throws MessageListenerException {
Map<String,Object> map = message.getValues();
String diId = (String) map.get(SchedulerConstants.DI_ID);
Date capsEnablementDate = (Date) map.get(SchedulerConstants.CAPS_ENABLEMENT_DATE);

String jobName = map.get(SchedulerConstants.JOB_NAME).toString();

if(!jobName.startsWith(SchedulerConstants.CAPS_ENABLEMENT_JOemoticon){
return;
}
//LOGIC GOES HERE
}
thumbnail
Denis Signoretto,修改在6 年前。

RE: Liferay scheduler does not work after tomcat restart

Expert 帖子: 375 加入日期: 09-4-21 最近的帖子
HI Hemanth KN,

do have already read this thread? [1] I found useful it in the past about scheduling.

Bye,
Denis.

[1] https://web.liferay.com/community/forums/-/message_boards/message/11799978