skip to Main Content

I am trying to switch my http session to redis in my spring boot application.
When the first request comes to backend it’s being filtered by authentication filter.
One duty of this filter is to populate user session bean with data. The session is succesfully saved to the redis instance at this step, but the delta of changes ( which should include the session bean) is not invoked. I want to point out that with storing session on tomcat the session beans work correctly.

So why session bean populated on OnePerRequest filter is not updated as the delta of session ?

2

Answers


  1. Have you tried the below configuration?

    @Configuration
    @EnableRedisHttpSession(saveMode = SaveMode.ALWAYS)
    public class RedisSessionConfig {
    }
    
    Login or Signup to reply.
  2. Try changing the flush mode to IMMEDIATE, by default it’s ON_SAVE which means you explicitly have to save the session or in a managed environment, it happens before the response is serialized (I think).

    In src/main/resources/application.properties you could do:

    spring.session.redis.flush-mode=immediate
    

    Or using @EnableRedisHttpSession do:

    @EnableRedisHttpSession(redisFlushMode = RedisFlushMode.IMMEDIATE)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search