Issue
In the case of days in which there is a time change in summer, what happens in these cases with the Quartz library? Could some process not trigger?
Environment
- Liferay DXP 7.1
- Liferay DXP 7.2
- Liferay DXP 7.3
Resolution
Liferay makes use of the Quartz library. Therefore, the behavior that we must deduce that the product will have in this situation will be the same as the library.
If we refer to the official documentation of Quartz, on the FAQ of any published version (http://www.quartz-scheduler.org/documentation/2.3.1-SNAPSHOT/faq.html) we will see that it explains that if an hour does not occur, the action is not will execute. If we use CronTrigger:
SimpleTrigger ALWAYS fires exactly every N seconds, with no relation to the time of day. CronTrigger ALWAYS fires at a given time of day and then computes its next time to fire. If that time does not occur on a given day, the trigger will be skipped. If the time occurs twice in a given day, it only fires once, because after firing on that time the first time, it computes the next time of day to fire on.
On the other hand, being a little more precise if we access the version that is used in DXP 7.2 (2.1.7). In the javadoc (https://www.javadoc.io/doc/org.quartz-scheduler/quartz/2.1.7/org/quartz/CronTrigger.html) we will see that there is no prevention mechanism that controls the case you raise . The documentation advises us to be careful with the proposed situation.
Be careful when setting fire times between mid-night and 1:00 AM - "daylight savings" can cause a skip or a repeat depending on whether the time moves back or jumps forward.
Trigger trigger = _triggerFactory.createTrigger(
className, className, null, null,
journalServiceConfiguration.checkInterval(), TimeUnit.MINUTE);
SchedulerEntry schedulerEntry = new SchedulerEntryImpl(
className, trigger);
_schedulerEngineHelper.register(
this, schedulerEntry, DestinationNames.SCHEDULER_DISPATCH);
If we look at this class we are invoking TriggerFactory with a series of minutes as the interval, which results in a SimpleTrigger being created. This SimpleTrigger would always run regardless of the time change.
On the other hand if we look at the DeleteMBMessagesListener class:
Trigger trigger = _triggerFactory.createTrigger(
clazz.getName(), clazz.getName(), new Date(), null, cronExpression);
_schedulerEntryImpl = new SchedulerEntryImpl(clazz.getName(), trigger);
if (_initialized) {
deactivate();
}
_schedulerEngineHelper.register(
this, _schedulerEntryImpl, DestinationNames.SCHEDULER_DISPATCH);
In this case we are creating an instance of a CronTrigger type trigger. These triggers would be affected by the time change.
With all this information on our part we can conclude that a task won’t be executed on the lost hour caused by the Daylight saving time if you use the CronScheduleBuilder.