I am using Spring Session with Hazelcast and Spring Websockets. As I don't need clustarization I use hazelcast with MapSessionRepository
. But it doesn't fire event on session expiring or session deleting. What I want is to listen to SessionExpiredEvent
and then disconnect user via websocket immediately. So I have two problems:
MapSessionRepository
does not firing needed events (SessionExpiredEvent
and etc.)
I don't realize how to send websocket notification using expired http session. I need something like simpMessageTemplate.convertAndSendToUser()
.
But how I can get the user?
So the only one variant I can see is to write own implementation for SessionRepository<ExpiringSession>
with events firing. I hope you understood my question. Thanks in advance.
Spring Session Hazelcast support does provide publishing of session events. The functionality itself is implemented using SessionEntryListener
so make sure you use @EnableHazelcastHttpSession
annotation which configures all the necessary components for Hazelcast integration.
It might also be of your interest that the upcoming Spring Session 1.3 (currently at 1.3.0.M2
) will provide first-class Hazelcast support with new HazelcastSessionRepository
(which will, among other things, replace SessionEntryListener
).