如何向 Redis 集群发布/订阅消息

问题描述

我的项目使用 Redis(Jedis 客户端)作为缓存管理器。这是我用来操作 redis 集群连接的 bean

@Bean(destroyMethod = "close")
    @ConditionalOnProperty(value = "spring.cache.type",havingValue = "redis")
    public JedisCluster jedisCluster(@Value("${spring.redis.host}") String host,@Value("${spring.redis.port}") int port,@Value("${spring.redis.password}") String password) {
        Set<HostAndPort> jedisClusterNode = new HashSet<>();
        jedisClusterNode.add(new HostAndPort(host,port));
        JedisPoolConfig defaultConfig = new JedisPoolConfig()
        return new JedisCluster(jedisClusterNode,DEFAULT_TIMEOUT,DEFAULT_REDIRECTIONS,kcService.getKey(password),"lhs_redis",defaultConfig);
    }

现在我想使用 Redis 的发布/订阅功能,基于这个链接 https://medium.com/@bhanuchaddha/using-redis-pub-sub-with-spring-boot-ea0d7a8c27af 看起来他们可以为独立的 redis 做。

那么有人知道如何为 Redis 集群设置 Pub/Sub 吗?

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)