コード例 #1
0
  protected void update(
      Scheduler scheduler,
      com.liferay.portal.kernel.scheduler.Trigger trigger,
      StorageType storageType)
      throws Exception {

    Trigger quartzTrigger = getQuartzTrigger(trigger, storageType);

    if (quartzTrigger == null) {
      return;
    }

    TriggerKey triggerKey = quartzTrigger.getKey();

    if (scheduler.getTrigger(triggerKey) != null) {
      scheduler.rescheduleJob(triggerKey, quartzTrigger);
    } else {
      JobKey jobKey = quartzTrigger.getJobKey();

      JobDetail jobDetail = scheduler.getJobDetail(jobKey);

      if (jobDetail == null) {
        return;
      }

      synchronized (this) {
        scheduler.deleteJob(jobKey);
        scheduler.scheduleJob(jobDetail, quartzTrigger);
      }

      updateJobState(scheduler, jobKey, TriggerState.NORMAL, true);
    }
  }
コード例 #2
0
  protected void schedule(
      Scheduler scheduler,
      StorageType storageType,
      Trigger trigger,
      String description,
      String destinationName,
      Message message)
      throws Exception {

    if (_jsonFactory == null) {
      throw new IllegalStateException("JSON factory not initialized");
    }

    try {
      JobBuilder jobBuilder = JobBuilder.newJob(MessageSenderJob.class);

      jobBuilder.withIdentity(trigger.getJobKey());

      jobBuilder.storeDurably();

      JobDetail jobDetail = jobBuilder.build();

      JobDataMap jobDataMap = jobDetail.getJobDataMap();

      jobDataMap.put(SchedulerEngine.DESCRIPTION, description);
      jobDataMap.put(SchedulerEngine.DESTINATION_NAME, destinationName);
      jobDataMap.put(SchedulerEngine.MESSAGE, _jsonFactory.serialize(message));
      jobDataMap.put(SchedulerEngine.STORAGE_TYPE, storageType.toString());

      JobState jobState =
          new JobState(
              TriggerState.NORMAL, message.getInteger(SchedulerEngine.EXCEPTIONS_MAX_SIZE));

      jobDataMap.put(SchedulerEngine.JOB_STATE, JobStateSerializeUtil.serialize(jobState));

      unregisterMessageListener(scheduler, trigger.getJobKey());

      synchronized (this) {
        scheduler.deleteJob(trigger.getJobKey());
        scheduler.scheduleJob(jobDetail, trigger);
      }
    } catch (ObjectAlreadyExistsException oaee) {
      if (_log.isInfoEnabled()) {
        _log.info("Message is already scheduled");
      }
    }
  }
コード例 #3
0
 public void jobScheduled(Trigger trigger) {
   getLog().debug("Trigger " + trigger.getKey() + " scheduled Job " + trigger.getJobKey() + ".");
 }