public boolean scheduleQueueJob(Notification notification, boolean forceSchedule) throws Exception { boolean scheduleInFuture = notification.getDeliver() != null; long scheduleAt = (notification.getDeliver() != null) ? notification.getDeliver() : 0; long soonestPossible = System.currentTimeMillis() + SCHEDULER_GRACE_PERIOD; if (scheduleAt < soonestPossible) { scheduleAt = soonestPossible; scheduleInFuture = false; } boolean scheduled = scheduleInFuture || forceSchedule; if(scheduled) { JobData jobData = new JobData(); jobData.setProperty("applicationId", sm.getApplicationId()); jobData.setProperty("notificationId", notification.getUuid()); jobData.setProperty("deliver", notification.getDeliver()); SchedulerService scheduler = getSchedulerService(); scheduler.createJob("queueJob", scheduleAt, jobData); if (logger.isTraceEnabled()) { logger.trace("notification {} scheduled for queuing", notification.getUuid()); } } return scheduled; } private SchedulerService getSchedulerService() {
@EntityProperty(mutable = true, indexed = true) public State getState() { if (getErrorMessage() != null) { return State.FAILED; } else if (getCanceled() == Boolean.TRUE) { return State.CANCELED; } else if (getFinished() != null) { return State.FINISHED; } else if (getStarted() != null && getDeliver() == null) { return State.STARTED; } else if (isExpired()) { return State.EXPIRED; } else if (getDeliver() != null || getQueued() != null) { return State.SCHEDULED; } return State.CREATED; }
public void scheduleBatchJob(Notification notification, long delay) throws Exception { JobData jobData = new JobData(); jobData.setProperty("applicationId", sm.getApplicationId()); jobData.setProperty("notificationId", notification.getUuid()); jobData.setProperty("deliver", notification.getDeliver()); long soonestPossible = System.currentTimeMillis() + SCHEDULER_GRACE_PERIOD + delay; SchedulerService scheduler = getSchedulerService(); scheduler.createJob("notificationBatchJob", soonestPossible, jobData); if (logger.isTraceEnabled()) { logger.trace("notification {} batch scheduled for delivery", notification.getUuid()); } } public boolean scheduleQueueJob(Notification notification) throws Exception {
if (!deliver.equals(notification.getDeliver())) { notificationQueueManager.queueNotification((Notification) response, null);