Spring 触发 hazelcast 会话事件的会话
Spring Session with hazelcast session events firing
我正在使用 Spring Session with Hazelcast 和 Spring Websockets。因为我不需要集群化,所以我将 hazelcast 与 MapSessionRepository
一起使用。但它不会在会话过期或会话删除时触发事件。我想要的是听 SessionExpiredEvent
然后立即通过 websocket 断开用户连接。所以我有两个问题:
MapSessionRepository
没有触发所需的事件(SessionExpiredEvent
等)
我不知道如何使用过期的 http 会话发送 websocket 通知。我需要像 simpMessageTemplate.convertAndSendToUser()
这样的东西。
但是我怎样才能得到用户呢?
所以我能看到的唯一一种变体是为 SessionRepository<ExpiringSession>
编写自己的实现并触发事件。我希望你明白我的问题。提前致谢。
Spring Session Hazelcast 支持确实提供 session 事件的发布。该功能本身是使用 SessionEntryListener
实现的,因此请确保您使用 @EnableHazelcastHttpSession
annotation 来配置 Hazelcast 集成所需的所有组件。
您可能还对即将推出的 Spring Session 1.3(目前在 1.3.0.M2
)将提供 first-class Hazelcast support with new HazelcastSessionRepository
(除其他外,替换 SessionEntryListener
).
我正在使用 Spring Session with Hazelcast 和 Spring Websockets。因为我不需要集群化,所以我将 hazelcast 与 MapSessionRepository
一起使用。但它不会在会话过期或会话删除时触发事件。我想要的是听 SessionExpiredEvent
然后立即通过 websocket 断开用户连接。所以我有两个问题:
MapSessionRepository
没有触发所需的事件(SessionExpiredEvent
等)我不知道如何使用过期的 http 会话发送 websocket 通知。我需要像
simpMessageTemplate.convertAndSendToUser()
这样的东西。 但是我怎样才能得到用户呢?
所以我能看到的唯一一种变体是为 SessionRepository<ExpiringSession>
编写自己的实现并触发事件。我希望你明白我的问题。提前致谢。
Spring Session Hazelcast 支持确实提供 session 事件的发布。该功能本身是使用 SessionEntryListener
实现的,因此请确保您使用 @EnableHazelcastHttpSession
annotation 来配置 Hazelcast 集成所需的所有组件。
您可能还对即将推出的 Spring Session 1.3(目前在 1.3.0.M2
)将提供 first-class Hazelcast support with new HazelcastSessionRepository
(除其他外,替换 SessionEntryListener
).