java - 如何向 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_TIMEOUT,
DEFAULT_REDIRECTIONS, kcService.getKey(password), "lhs_redis", defaultConfig);
}
现在我想使用 Redis 的 pub/sub 功能,基于此链接https://medium.com/@bhanuchaddha/using-redis-pub-sub-with-spring-boot-ea0d7a8c27af看起来他们可以为独立的 redis 做.
那么有人知道如何为 Redis 集群设置 Pub/Sub 吗?
谢谢
解决方案
推荐阅读
- oracle - PL/SQL 触发器未按预期评估 IF 条件
- javascript - 如何使用 word-wrap: break-word 计算行数?
- python-3.x - 绑定到输入框并更改输入
- python - 循环中跳过错误 - JSONDecodeError:预期值:第 1 行第 1 列(字符 0)
- javascript - 无法在 JavaScript 中将对象转换为字符串
- python - Python PIL 裁剪图像并将裁剪保存为新图像/副本
- python - lxml 内存分配失败
- azure - 在 V-Net 和不同域之间映射驱动器
- xamarin.ios - 让底纸正确加载
- ssl - 代理上的 SSL 证书与源服务器上的 SSL 证书