use of io.micronaut.session.event.SessionExpiredEvent in project redisson by redisson.
the class RedissonSessionStore method onMessage.
@Override
public void onMessage(CharSequence pattern, CharSequence channel, String body) {
if (deletedTopic.getPatternNames().contains(pattern.toString())) {
if (!body.contains(SESSION_PREFIX + "notification:")) {
return;
}
String id = body.split(SESSION_PREFIX + "notification:")[1];
loadSession(id, true).whenComplete((r, e) -> {
r.ifPresent(v -> {
eventPublisher.publishEvent(new SessionDeletedEvent(v));
});
});
} else if (expiredTopic.getPatternNames().contains(pattern.toString())) {
if (!body.contains(SESSION_PREFIX + "notification:")) {
return;
}
String id = body.split(SESSION_PREFIX + "notification:")[1];
loadSession(id, true).whenComplete((r, e) -> {
r.ifPresent(v -> {
eventPublisher.publishEvent(new SessionExpiredEvent(v));
});
});
}
}
use of io.micronaut.session.event.SessionExpiredEvent in project micronaut-redis by micronaut-projects.
the class RedisSessionStore method message.
@Override
public void message(String pattern, String channel, String message) {
if (message.startsWith(expiryPrefix)) {
boolean expired = pattern.endsWith(":expired");
if (pattern.endsWith(":del") || expired) {
String id = message.substring(expiryPrefix.length());
redisSortedSetAsyncCommands.zrem(activeSessionsSet, id.getBytes(charset)).whenComplete((aVoid, throwable) -> {
if (throwable != null) {
if (LOG.isErrorEnabled()) {
LOG.error("Error removing session [" + id + "] from active sessions: " + throwable.getMessage(), throwable);
}
}
});
findSessionInternal(id, true).whenComplete((optional, throwable) -> {
if (throwable == null && optional.isPresent()) {
RedisSession session = optional.get();
eventPublisher.publishEvent(expired ? new SessionExpiredEvent(session) : new SessionDeletedEvent(session));
}
});
}
}
}
Aggregations