i have spring boot project spring session backed redis. trying capture sessiondestroyed event can perform clean up.
the code capture event below per guidance found elsewhere on stack overflow.
@component public class sessionendedlistener implements applicationlistener<sessiondestroyedevent> { private final logger logger = loggerfactory.getlogger(getclass()); @override public void onapplicationevent(sessiondestroyedevent event) { logger.info("destroyed session: {}", event.getsessionid()); }
}
i have set redis session configuration so
@enableredishttpsession(maxinactiveintervalinseconds = 120) public class redissessionconfig { }
i can see logs spring redis cleaning expired sessions every minute shown below
2016-07-21 11:07:00,026 ==== redissessionexpirationpolicy.java ==== thread: pool-4-thread-1 ==== debug > org.springframework.session.data.redis.redissessionexpirationpolicy.cleanexpiredsessions() => [] (line: 107) cleaning sessions expiring @ thu jul 21 11:07:00 edt 2016
but code meant capture sessiondestroyedevent never called. missing here?
please note testing local redis server there no problem in configuring key-space-events egx.
when debugged through code.
this statement
if(!body.startswith("spring:session:sessions:")) { return; }
in class org.springframework.session.data.redis.sessionmessagelistener returns prematurely before getting chance publish event
because variable body has value
\xac\xed\x00\x05t\x00<spring:session:sessions:2392443d-62a9-4f8c-81f0-c0bb446eb16f
i using spring-session 1.0.2.release. there bug fixed?
Comments
Post a Comment