use of org.keycloak.services.scheduled.ScheduledTaskRunner in project keycloak by keycloak.
the class KeycloakApplication method setupScheduledTasks.
public static void setupScheduledTasks(final KeycloakSessionFactory sessionFactory) {
long interval = Config.scope("scheduled").getLong("interval", 900L) * 1000;
KeycloakSession session = sessionFactory.create();
try {
TimerProvider timer = session.getProvider(TimerProvider.class);
timer.schedule(new ClusterAwareScheduledTaskRunner(sessionFactory, new ClearExpiredEvents(), interval), interval, "ClearExpiredEvents");
timer.schedule(new ClusterAwareScheduledTaskRunner(sessionFactory, new ClearExpiredClientInitialAccessTokens(), interval), interval, "ClearExpiredClientInitialAccessTokens");
timer.schedule(new ScheduledTaskRunner(sessionFactory, new ClearExpiredUserSessions()), interval, ClearExpiredUserSessions.TASK_NAME);
new UserStorageSyncManager().bootstrapPeriodic(sessionFactory, timer);
} finally {
session.close();
}
}
use of org.keycloak.services.scheduled.ScheduledTaskRunner in project keycloak by keycloak.
the class BasicTimerProvider method scheduleTask.
@Override
public void scheduleTask(ScheduledTask scheduledTask, long intervalMillis, String taskName) {
ScheduledTaskRunner scheduledTaskRunner = new ScheduledTaskRunner(session.getKeycloakSessionFactory(), scheduledTask, transactionTimeout);
this.schedule(scheduledTaskRunner, intervalMillis, taskName);
}
Aggregations