Search in sources :

Example 1 with ClearExpiredEvents

use of org.keycloak.services.scheduled.ClearExpiredEvents 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();
    }
}
Also used : UserStorageSyncManager(org.keycloak.services.managers.UserStorageSyncManager) ClusterAwareScheduledTaskRunner(org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner) ScheduledTaskRunner(org.keycloak.services.scheduled.ScheduledTaskRunner) KeycloakSession(org.keycloak.models.KeycloakSession) ClusterAwareScheduledTaskRunner(org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner) TimerProvider(org.keycloak.timer.TimerProvider) ClearExpiredEvents(org.keycloak.services.scheduled.ClearExpiredEvents) ClearExpiredClientInitialAccessTokens(org.keycloak.services.scheduled.ClearExpiredClientInitialAccessTokens) ClearExpiredUserSessions(org.keycloak.services.scheduled.ClearExpiredUserSessions)

Aggregations

KeycloakSession (org.keycloak.models.KeycloakSession)1 UserStorageSyncManager (org.keycloak.services.managers.UserStorageSyncManager)1 ClearExpiredClientInitialAccessTokens (org.keycloak.services.scheduled.ClearExpiredClientInitialAccessTokens)1 ClearExpiredEvents (org.keycloak.services.scheduled.ClearExpiredEvents)1 ClearExpiredUserSessions (org.keycloak.services.scheduled.ClearExpiredUserSessions)1 ClusterAwareScheduledTaskRunner (org.keycloak.services.scheduled.ClusterAwareScheduledTaskRunner)1 ScheduledTaskRunner (org.keycloak.services.scheduled.ScheduledTaskRunner)1 TimerProvider (org.keycloak.timer.TimerProvider)1