Foros de discusión
Liferay scheduler does not work after tomcat restart
Hemanth KN, modificado hace 6 años.
Liferay scheduler does not work after tomcat restart
New Member Mensajes: 4 Fecha de incorporación: 8/03/17 Mensajes recientes
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_JO){
return;
}
//LOGIC GOES HERE
}
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_JO){
return;
}
//LOGIC GOES HERE
}
Denis Signoretto, modificado hace 6 años.
RE: Liferay scheduler does not work after tomcat restart
Expert Mensajes: 375 Fecha de incorporación: 21/04/09 Mensajes recientes
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
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