@ScheduleDelay(initialDelay = 60, delay = 60) void cleanStaleMessages() { long currentTimeMillis = System.currentTimeMillis(); delayedMessageRegistry .values() .forEach(it -> it.removeIf(m -> currentTimeMillis - m.timeMillis > 60_000)); delayedMessageRegistry.values().removeIf(Queue::isEmpty); }
private void launch(Object object, Method method, ScheduleCron annotation) { Launcher launcher = launcherProvider.get(); launcher.scheduleCron( new LoggedRunnable(object, method), annotation.cronParameterName().isEmpty() ? annotation.cron() : getValue(String.class, annotation.cronParameterName())); }
private void launch(Object object, Method method, ScheduleDelay annotation) { if (annotation.delayParameterName().isEmpty() && annotation.delay() == 0) { throw new RuntimeException("Delay parameter is not configured"); } Launcher launcher = launcherProvider.get(); launcher.scheduleWithFixedDelay( new LoggedRunnable(object, method), annotation.initialDelayParameterName().isEmpty() ? annotation.initialDelay() : getValue(annotation.initialDelayParameterName()), annotation.delayParameterName().isEmpty() ? annotation.delay() : getValue(annotation.delayParameterName()), annotation.unit()); }
private void launch(Object object, Method method, ScheduleRate annotation) { if (annotation.periodParameterName().isEmpty() && annotation.period() == 0) { throw new RuntimeException("Period parameter is not configured"); } Launcher launcher = launcherProvider.get(); launcher.scheduleAtFixedRate( new LoggedRunnable(object, method), annotation.initialDelayParameterName().isEmpty() ? annotation.initialDelay() : getValue(annotation.initialDelayParameterName()), annotation.periodParameterName().isEmpty() ? annotation.period() : getValue(annotation.periodParameterName()), annotation.unit()); }
@ScheduleRate(periodParameterName = "workspace.activity.schedule_period_s") private void scheduleActivityNotification() { if (activeDuringThreshold.compareAndSet(true, false)) { notifyActivity(); } }