org.redisson.api.CronSchedule Java Examples
The following examples show how to use
org.redisson.api.CronSchedule.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchedulerServiceExamples.java From redisson-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) { Config config = new Config(); config.useClusterServers() .addNodeAddress("127.0.0.1:7001", "127.0.0.1:7002", "127.0.0.1:7003"); RedissonClient redisson = Redisson.create(config); RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config); nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 5)); RedissonNode node = RedissonNode.create(nodeConfig); node.start(); RScheduledExecutorService e = redisson.getExecutorService("myExecutor"); e.schedule(new RunnableTask(), 10, TimeUnit.SECONDS); e.schedule(new CallableTask(), 4, TimeUnit.MINUTES); e.schedule(new RunnableTask(), CronSchedule.of("10 0/5 * * * ?")); e.schedule(new RunnableTask(), CronSchedule.dailyAtHourAndMinute(10, 5)); e.schedule(new RunnableTask(), CronSchedule.weeklyOnDayAndHourAndMinute(12, 4, Calendar.MONDAY, Calendar.FRIDAY)); e.shutdown(); node.shutdown(); }
Example #2
Source File: RedisJobScheduleImpl.java From earth-frost with Apache License 2.0 | 5 votes |
@Override public String addCronJob(String jobId, String cron) { String taskId = redissonClient.getExecutorService(Container.WORKER) .scheduleAsync(new JobDispatchWrapper(jobId), CronSchedule.of(cron)).getTaskId(); redissonClient.<String, String>getListMultimap(Container.TASK_ID).put(jobId, taskId); return taskId; }