Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于Pull Message Task的 Reconnection问题疑惑 #111

Open
eddieran opened this issue Feb 6, 2025 · 0 comments
Open

关于Pull Message Task的 Reconnection问题疑惑 #111

eddieran opened this issue Feb 6, 2025 · 0 comments

Comments

@eddieran
Copy link

eddieran commented Feb 6, 2025

关于 RedisMessagePullTask 的初始化实现当中
会默认开启重连检测
https://github.com/xiaolyuh/layering-cache/blob/master/layering-cache-core/src/main/java/com/github/xiaolyuh/listener/RedisMessagePullTask.java#L44C9-L44C25

// 4. 重连检测
reconnectionTask(initialDelay, delay);

但是在重连检测里面,我看似乎每一次都会每隔几秒就建立一个新的连接?

@Override
    public void subscribe(RedisMessageListener messageListener, String... channels) {
        try {
            StatefulRedisPubSubConnection<String, String> connection = this.clusterClientPubSub.connectPubSub();
            logger.info("layering-cache和redis创建订阅关系,订阅频道【{}】", Arrays.toString(channels));
            connection.sync().subscribe(channels);
            connection.addListener(messageListener);
        } catch (SerializationException e) {
            throw e;
        } catch (Exception e) {
            throw new RedisClientException(e.getMessage(), e);
        }
    }

在pub/sub 的订阅初始化,这里我看 connection会持有对应的messageListener的bean,看起来连接也不会释放?
是否有连接一直堆积越建立越多的情况呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant