Details

    • Similar Issues:
      Show 5 results 

      Description

      We would like a way we can set the time zone for each scheduled job dynamically.

      QUARTZ_CRON_TRIGGERS table - TIME_ZONE_ID column

      Example:
      Trigger 1 - TIME_ZONE_ID = GMT
      Trigger 2 - TIME_ZONE_ID = EST...

      NOTE: We have this API in regular Quartz but not in Liferay based in Quartz API.

        Activity

        Hide
        Tim Telcik added a comment -

        Hello Kenneth,

        I also see a requirement for supporting timezones in the Liferay Portal scheduler API that wraps the Quartz API.

        One possible approach to support timezones for Quartz is to define the timezone ID in the “liferay-portlet.xml” config file.

        <trigger>
          <cron>
            <cron-trigger-value>0 15 17 * * ?</cron-trigger-value>
            <cron-trigger-timezone>Australia/Brisbane</cron-trigger-timezone>
          </cron>
        </trigger>
        

        The revised “liferay-portlet.xml” config could then be loaded by class “com.liferay.portal.scheduler.quartz.QuartzSchedulerEngine”.

        package com.liferay.portal.scheduler.quartz;
        
        public class QuartzSchedulerEngine implements SchedulerEngine {
        
           protected Trigger getQuartzTrigger(
              com.liferay.portal.kernel.scheduler.Trigger trigger)
              throws SchedulerException {
        
        // code removed for clarity
        
        		if (triggerType.equals(TriggerType.CRON)) {
        			TriggerBuilder<Trigger>triggerBuilder = TriggerBuilder.newTrigger();
        
        			triggerBuilder.endAt(endDate);
        			triggerBuilder.forJob(jobName, groupName);
        			triggerBuilder.startAt(startDate);
        			triggerBuilder.withIdentity(jobName, groupName);
        
        			CronScheduleBuilder cronScheduleBuilder =
        				CronScheduleBuilder.cronSchedule(
        					(String)trigger.getTriggerContent());
        
        
                                //
                                // BEGIN LPS-36180 PATCH
                                //
                                // NOTE: Class “com.liferay.portal.kernel.scheduler.Trigger” must also be updated with “timezone” member/setter/getter
                                //
                                cronScheduleBuilder.inTimezone(trigger.getTriggerTimezone());
                                //
                                // END   LPS-36180 PATCH
                                //
        
        			triggerBuilder.withSchedule(cronScheduleBuilder);
        
        			quartzTrigger = triggerBuilder.build();
        		}
               }
        
        // code removed for clarity
        
        }
        

        This potential approach will need to reviewed, but may provide a starting point for a solution.

        Regards,

        Tim

        Show
        Tim Telcik added a comment - Hello Kenneth, I also see a requirement for supporting timezones in the Liferay Portal scheduler API that wraps the Quartz API. One possible approach to support timezones for Quartz is to define the timezone ID in the “liferay-portlet.xml” config file. <trigger> <cron> <cron-trigger-value>0 15 17 * * ?</cron-trigger-value> <cron-trigger-timezone>Australia/Brisbane</cron-trigger-timezone> </cron> </trigger> The revised “liferay-portlet.xml” config could then be loaded by class “com.liferay.portal.scheduler.quartz.QuartzSchedulerEngine”. package com.liferay.portal.scheduler.quartz; public class QuartzSchedulerEngine implements SchedulerEngine { protected Trigger getQuartzTrigger( com.liferay.portal.kernel.scheduler.Trigger trigger) throws SchedulerException { // code removed for clarity if (triggerType.equals(TriggerType.CRON)) { TriggerBuilder<Trigger>triggerBuilder = TriggerBuilder.newTrigger(); triggerBuilder.endAt(endDate); triggerBuilder.forJob(jobName, groupName); triggerBuilder.startAt(startDate); triggerBuilder.withIdentity(jobName, groupName); CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule( ( String )trigger.getTriggerContent()); // // BEGIN LPS-36180 PATCH // // NOTE: Class “com.liferay.portal.kernel.scheduler.Trigger” must also be updated with “timezone” member/setter/getter // cronScheduleBuilder.inTimezone(trigger.getTriggerTimezone()); // // END LPS-36180 PATCH // triggerBuilder.withSchedule(cronScheduleBuilder); quartzTrigger = triggerBuilder.build(); } } // code removed for clarity } This potential approach will need to reviewed, but may provide a starting point for a solution. Regards, Tim

          People

          • Votes:
            8 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Days since last comment:
              8 weeks, 3 days ago

              Development

                Structure Helper Panel