• 9.4.3. 通过CRON表达式设定任务计划

    9.4.3. 通过CRON表达式设定任务计划

    在分布式调度任务中,可以通过CRON表达式来为任务设定一个更复杂的计划。表达式与Quartz的CRON格式完全兼容。

    例如:

    1. RScheduledExecutorService executorService = redisson.getExecutorService("myExecutor");
    2. executorService.schedule(new RunnableTask(), CronSchedule.of("10 0/5 * * * ?"));
    3. // ...
    4. executorService.schedule(new RunnableTask(), CronSchedule.dailyAtHourAndMinute(10, 5));
    5. // ...
    6. executorService.schedule(new RunnableTask(), CronSchedule.weeklyOnDayAndHourAndMinute(12, 4, Calendar.MONDAY, Calendar.FRIDAY));