在不注册 HttpSessionEventPublisher 侦听器的情况下捕获 Spring 会话销毁事件

Capture Spring Session Destroy Event without registering the HttpSessionEventPublisher Listener

我想在 Spring 会话销毁(注销和超时)期间执行一些清理 activity 并尝试按照 线程

提供的解决方案

但让我感到好奇的是,我的应用程序是一个 Spring 启动应用程序,我不必注册 HttpSessionEventPublisher Listener ,我只是实现了 ApplicationListener 接口并使用 onApplicationEvent() 方法来捕获 SessionDestroyEvent。

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

这是 Spring 会话文档本身的答案

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. <<