Forums de discussion
Liferay DXP cluster - scheduled job not triggered on any node
Ilenia Zedda, modifié il y a 6 années.
Liferay DXP cluster - scheduled job not triggered on any node
New Member Publications: 16 Date d'inscription: 28/05/15 Publications récentes
Hi,
we've implemented a scheduler as follows (thanks to this blog post!)
This works fine except in our clustered environment, where the job doesn't get triggered in any of the 2 nodes.
When both nodes are running, if we check the details of the jobs retrieved with SchedulerEngineHelperUtil.getScheduledJobs(), we can see that our custom scheduled job has no trigger details
Our job details
While any other liferay job have info about START_TIME, NEXT_FIRE_TIME and the Trigger dates
There are no errors in the logs and this code works fine in single nodes environments, it's just an issue in a clustered env.
Any suggestion?
Many Thanks,
Ilenia
we've implemented a scheduler as follows (thanks to this blog post!)
@Component(immediate = true, service = DailyJobMessageListener.class, configurationPolicy = ConfigurationPolicy.OPTIONAL, configurationPid = "com.test.configuration.DefaultActivityNotificationsJobConfiguration")
public class DailyJobMessageListener extends BaseMessageListener {
private volatile DefaultActivityNotificationsJobConfiguration defaultActivityNotificationsJobConfiguration;
private volatile boolean initialized;
private SchedulerEntryImpl schedulerEntry = null;
private NotificationJobService notificationJobService;
private SchedulerEngineHelper schedulerEngineHelper;
private TriggerFactory triggerFactory;
@Activate
@Modified
protected void activate(Map<string, object> properties) {
defaultActivityNotificationsJobConfiguration = ConfigurableUtil.createConfigurable(DefaultActivityNotificationsJobConfiguration.class, properties);
String dailyJobCronExpression = defaultActivityNotificationsJobConfiguration.dailyJobCronExpression();
String className = getClass().getName();
Date startDate = new Date();
Trigger trigger = triggerFactory.createTrigger(className, className, startDate, null, dailyJobCronExpression);
if (initialized) {
deactivate();
}
schedulerEntry = new SchedulerEntryImpl(className, trigger);
//This is deprecated schedulerEntry.setTrigger(trigger);
schedulerEngineHelper.register(this, schedulerEntry, DestinationNames.SCHEDULER_DISPATCH);
initialized = true;
}
@Deactivate
protected void deactivate() {
if (initialized) {
try {
schedulerEngineHelper.unschedule(schedulerEntry, StorageType.MEMORY_CLUSTERED);
} catch (SchedulerException se) {
}
schedulerEngineHelper.unregister(this);
}
initialized = false;
}
@Override
protected void doReceive(Message message) throws Exception {
notificationJobService.runNotificationJobForAllCompanies(NotificationFrequency.DAILY);
}
@Reference(target = ModuleServiceLifecycle.PORTAL_INITIALIZED, unbind = "-")
protected void setModuleServiceLifecycle(ModuleServiceLifecycle moduleServiceLifecycle) {
}
@Reference(unbind = "-")
protected void setNotificationJobService(NotificationJobService notificationJobService) {
this.notificationJobService = notificationJobService;
}
@Reference(unbind = "-")
protected void setTriggerFactory(TriggerFactory triggerFactory) {
this.triggerFactory = triggerFactory;
}
@Reference(unbind = "-")
protected void setSchedulerEngineHelper(SchedulerEngineHelper schedulerEngineHelper) {
this.schedulerEngineHelper = schedulerEngineHelper;
}
}</string,>
This works fine except in our clustered environment, where the job doesn't get triggered in any of the 2 nodes.
When both nodes are running, if we check the details of the jobs retrieved with SchedulerEngineHelperUtil.getScheduledJobs(), we can see that our custom scheduled job has no trigger details
Our job details
message:{destinationName=null, response=null, responseDestinationName=null, responseId=null, payload=null, values={GROUP_NAME=com.test.messaging.DailyJobMessageListener, EXCEPTIONS_MAX_SIZE=0, JOB_STATE=com.liferay.portal.kernel.scheduler.JobState@4cc7956d, JOB_NAME=com.test.messaging.DailyJobMessageListener}}
storageType:MEMORY_CLUSTERED
While any other liferay job have info about START_TIME, NEXT_FIRE_TIME and the Trigger dates
message:{destinationName=null, response=null, responseDestinationName=null, responseId=null, payload=null, values={GROUP_NAME=com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener, START_TIME=Wed Jul 26 20:14:13 GMT 2017, NEXT_FIRE_TIME=Wed Jul 26 20:14:13 GMT 2017, EXCEPTIONS_MAX_SIZE=0, JOB_STATE=com.liferay.portal.kernel.scheduler.JobState@78b90a1a, JOB_NAME=com.liferay.asset.publisher.web.internal.messaging.CheckAssetEntryMessageListener}}
storageType:MEMORY_CLUSTERED
Trigger StartDate:Wed Jul 26 20:14:13 GMT 2017
Trigger EndDate:null
There are no errors in the logs and this code works fine in single nodes environments, it's just an issue in a clustered env.
Any suggestion?
Many Thanks,
Ilenia
David H Nebinger, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
Liferay Legend Publications: 14919 Date d'inscription: 02/09/06 Publications récentes
Another user contacted me about something along these lines where the SchedulerEngineHelperUtil.getScheduledJobs() was actually not returning all scheduled job details.
I don't remember all of the specifics, but it sticks in my head that the jobs were actually scheduled, they just didn't appear in the listing.
I'm guessing though that you're indicating the job isn't running at all?
Personally I'd suggest using a try/catch block in the doReceive() method to log any errors thrown by the notificationJobService just to make sure some failure isn't going unreported somehow.
Come meet me at Devcon 2017 or 2017 LSNA!
I don't remember all of the specifics, but it sticks in my head that the jobs were actually scheduled, they just didn't appear in the listing.
I'm guessing though that you're indicating the job isn't running at all?
Personally I'd suggest using a try/catch block in the doReceive() method to log any errors thrown by the notificationJobService just to make sure some failure isn't going unreported somehow.
Come meet me at Devcon 2017 or 2017 LSNA!
Gary Nguyen, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
New Member Envoyer: 1 Date d'inscription: 04/06/15 Publications récentes
So I have implemented the schedule as well, but no one explains the higher level information thats important. What kind of portlet template is used? Is this just a portlet? activator??
Dharmen Panchal, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
New Member Publications: 7 Date d'inscription: 27/11/12 Publications récentes
Hi Ileana, have you got your scheduler working on cluster?
If you were successful please post the correct way.
If you were successful please post the correct way.
Ilenia Zedda, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
New Member Publications: 16 Date d'inscription: 28/05/15 Publications récentes
Hi,
no sorry, we still have that issue in a clustered environment.
To make sure the job is triggered, we have to refresh the module via gogoshell in the master cluster node. After the module refresh the job works fine (have to do this after each restart)
Will try out fixpack 30 as it includes some clustered scheduler issue fixes.
no sorry, we still have that issue in a clustered environment.
To make sure the job is triggered, we have to refresh the module via gogoshell in the master cluster node. After the module refresh the job works fine (have to do this after each restart)
Will try out fixpack 30 as it includes some clustered scheduler issue fixes.
Ilenia Zedda, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node (Réponse)
New Member Publications: 16 Date d'inscription: 28/05/15 Publications récentes
This issue is fixed after installing fixpack 32
Dharmen Panchal, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
New Member Publications: 7 Date d'inscription: 27/11/12 Publications récentesIlenia Zedda:
This issue is fixed after installing fixpack 32
Hi Ilenia,
Thank you for the update.
I will try fixpack 32.
-
Dharmen
Dharmen Panchal, modifié il y a 6 années.
RE: Liferay DXP cluster - scheduled job not triggered on any node
New Member Publications: 7 Date d'inscription: 27/11/12 Publications récentes
Liferay fixpack 32 solves problem for us as well.