question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Spring Session Redis prevents you from creating your own bean named redisMessageListenerContainer

See original GitHub issue

Via this Stack Overflow question, Spring Session Redis creates a bean named redisMessageListenerContainer that prevents a user from creating their own bean with that name. A bean will either get overridden or, if overriding is disabled as it is by default in Spring Boot 2.1, a startup failure will occur.

The quickest solution would be to name Spring Session’s bean more specifically. redisMessageListenerContainer is a very generic name for a piece of Spring Session’s infrastructure. I think it would also be interesting to consider solutions beyond that and take a look at whether it needs to be a RedisMessageListenerContainer bean at all. If the listener container is intended to be used solely by Spring Session, it would seem to make sense for it to not be exposed as a RedisMessageListenerContainer bean. If it’s intended to be a general purpose component, then it would seem to make sense for Spring Session to be able to reuse an existing listener container rather than always creating its own.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vpaviccommented, Nov 9, 2018

Another point is that I don’t believe (correct me if I’m wrong) that exposing this as a Bean with a unique name is going to impact many users since they are not unlikely to autowire RedisMessageListenerContainer by type. This differs from RedisTemplate, for example, since users are likely to autowire it by type.

I agree, this is a valid point. Prefixing the bean name springSession should address this without us having to add too much complexity.

0reactions
rwinchcommented, Nov 9, 2018

Thanks for the clarifications.

I’d prefer to stick with Spring Data’s contract which is exposing it as a Bean. Wrapping it seems to read into the implementation a bit too much. For example, if RedisMessageListenerContainer adds more lifecycle methods we would need to make sure we support those too. Another point is that I don’t believe (correct me if I’m wrong) that exposing this as a Bean with a unique name is going to impact many users since they are not unlikely to autowire RedisMessageListenerContainer by type. This differs from RedisTemplate, for example, since users are likely to autowire it by type.

In short, unless we have sufficient reason to do otherwise I’d prefer to stick with exposing it as a Bean using a more unique bean name.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why isn't RedisMessageListenerContainer starting up?
I'm using Spring Data Redis 2.2.8.RELEASE along with embedded redis server (it.ozimov.embedded-redis version 0.7.2). Does anyone have any ...
Read more >
Documentation - Spring Session
The @EnableRedisHttpSession annotation creates a Spring Bean with the name of springSessionRepositoryFilter that implements Filter . The filter ...
Read more >
Production Considerations for Spring Session Redis ... - Medium
Spring Session Redis uses the Spring Data Redis framework to talk to Redis. This means that the same considerations and best practices are ......
Read more >
Handling Spring Session with Redis
Above configuration is performing some heavy lifting for us: The @EnableRedisHttpSession annotation creates a Spring Bean with the name of ...
Read more >
Spring Session 2.0中文参考文档-oopsguy.com
1, The @EnableJdbcHttpSession annotation creates a Spring Bean with the name of springSessionRepositoryFilter that implements Filter.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found