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.

RedissonReactiveSubscription is not initialized properly and as a result - no messages are handled

See original GitHub issue

Expected behavior In case of using through org.springframework.data.redis.core.ReactiveStringRedisTemplate, I expect to handle messages from the channel I subscribed to via reactiveRedisTemplate.listenTo(channel)

Actual behavior The subscription via reactiveRedisTemplate.listenTo(channel) is happening and redis-cli PUBLISH channel hello returns (integer) 1, but NO messages are handled.

Spent some time debugging, I noticed that anonymous subclass of BaseRedisPubSubListener is created in RedissonReactiveSubscription.receive() with overridden onMessage(CharSequence channel, Object msg) method which as I understand should handle all the messages from redis channel (by the way, perhaps you could explain why BaseRedisPubSubListener overrides onMessage with empty implementation? ).

In fact the listener handles all messages and swallows it somewhere, debugging the message hits onMessage breakpoint, but nothing happened then. By the way, in some unexplainable cases (I really don’t know how to explain it) somewhere in the code the SubscribeListener is initialized and message that is handled by that listener is handled downstream (happens only in debug mode with some combination of breakpoints placed:)). But event in that base, a single message first handled by BaseRedisPubSubListener empty implementation of onMessage and only then by SubscribeListener which translates the message downstream. I tried a lot of times but didn’t understand what is really needed to achieve this.

Steps to reproduce or test case

  1. Initialize ReactiveStringRedisTemplate with regular spring config (example attached).
  2. Call reactiveRedisTemplate.listenTo(channel) and subscribe to it.

Redis version 5.0.5

Redisson version org.redisson:redisson-spring-data-22:3.12.4

Redisson configuration

@Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer()
                .setDnsMonitoringInterval(-1)
                .setTimeout(commandTimeoutMillis)
                .setAddress("redis://" + host + ":" + port);
        return Redisson.create(config);
    }
@Bean
public ReactiveRedisConnectionFactory redisConnectionFactory(RedissonClient redissonClient) {
    return new RedissonConnectionFactory(redissonClient);
}
 @Bean
ReactiveStringRedisTemplate reactiveRedisTemplate(ReactiveRedisConnectionFactory redisConnectionFactory) {
    return new ReactiveStringRedisTemplate(redisConnectionFactory);
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:30 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
mrnikocommented, Apr 23, 2020

use Config.setCodec method

1reaction
mrnikocommented, Apr 13, 2020

Fixed! Could you try it with attached version?

redisson-spring-data-22-3.12.5-SNAPSHOT.jar.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overview of Redisson: The Redis Java Client - DZone
Redis is an open-source, in-memory data structure store that can be used as a NoSQL key-value database, as well as a cache and...
Read more >
Spring Redis Error Handle - Stack Overflow
I had the very same problem. I'm developing some data services against a database, using Redis as the cache store by way of...
Read more >
7.-Distributed-collections.md · 大黑鱼/redisson.wiki - Gitee.com
Redis based distributed List object for Java implements java.util.List interface. It keeps elements in insertion order. It has Async, Reactive and RxJava2 ...
Read more >
A Guide to Redis with Redisson - Baeldung
A quick and practical guide to using Redisson for accessing Redis from a ... password: null subscriptionsPerConnection: 5 clientName: null ...
Read more >
Spring Data Redis
Note that the template requires all keys to be non-null. However, values can be null as long as the underlying serializer accepts them....
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