@Override
    public void cancel(TaskInstanceId taskInstanceId) {
      String taskName = taskInstanceId.getTaskName();
      String instanceId = taskInstanceId.getId();
      Optional<Execution> execution = taskRepository.getExecution(taskName, instanceId);
      if (execution.isPresent()) {
        if (execution.get().isPicked()) {
          throw new TaskInstanceCurrentlyExecutingException(taskName, instanceId);
        }

        taskRepository.remove(execution.get());
      } else {
        throw new TaskInstanceNotFoundException(taskName, instanceId);
      }
    }
Will cause getScheduledExecutions(..) to return executions in priority order.
db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/SchedulerClient.java