3

I wrote my own SessionExpireListener that will be invoked when session is deleted. All my sessions are stored in redis. So i am using @EnableRedisSession(maxInactiveIntervalInSeconds = 10) annotation. When i run my server sessionCreated(HttpSessionEvent event) is invoked. After 10 seconds session is deleted from the redis but sessionDestroyed event is not invoked.

@Component
public class SessionExpireListener implements HttpSessionListener {

    private static final Logger LOG = LoggerFactory.getLogger(SessionExpireListener.class);

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        LOG.info("Session has been destroyed...");
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        // TODO Auto-generated method stub
        LOG.info("Session has been created...");
    }
}

No LOG has been displayed in console. sessionDestroyed method is never called.

Slava Semushin
  • 14,904
  • 7
  • 53
  • 69
K. Marko
  • 121
  • 3
  • Check out this [question](https://stackoverflow.com/questions/38510187/not-able-to-capture-sessiondestroyed-event-in-spring-redis-session-spring-boot) for some hints in comments. No answer though. – Strelok May 16 '17 at 10:24
  • Also how are you testing the destruction of the session? Are you just deleting in Redis and expecting the event to fire in Spring immediately? – Strelok May 16 '17 at 10:28
  • When session expire i have to invoke sessionDestroyed method and then I can use my redisService to delete session from it. – K. Marko May 16 '17 at 15:44

0 Answers0