Search code examples
springsessionspring-session

Capture Spring Session Destroy Event without registering the HttpSessionEventPublisher Listener


I wanted to perform some clean-up activity during Spring Session destroy (logout and timeout) and tried following the solution provided at this thread

but what made me curious is that, my application is a Spring Boot application and I didn't have to register the HttpSessionEventPublisher Listener , i just implemented the ApplicationListener interface and used the onApplicationEvent() method to capture the SessionDestroyEvent.

My question is, How did my code work without registering this listener ?


Solution

  • here is the answer from the Spring Session documentation itself

    http://docs.spring.io/spring-session/docs/current/reference/html5/#api-redisoperationssessionrepository-sessiondestroyedevent

    If you are using @EnableRedisHttpSession the SessionMessageListener and enabling the necessary Redis Keyspace events is done automatically. <<