lettuce
lettuce copied to clipboard
Couldn't find a way to get a pubsub connection with a sentinel-based topology
Hi,
If I create a connection like in this example from the wiki:
RedisClient redisClient = RedisClient.create();
StatefulRedisMasterSlaveConnection<String, String> connection = MasterSlave.connect(redisClient, new Utf8StringCodec(),
RedisURI.create("redis-sentinel://localhost:26379,localhost:26380/0#mymaster"));
connection.setReadFrom(ReadFrom.MASTER_PREFERRED);
How can I create a pubsub connection ? Doing it straight from the redisClient fails (no URI).
Master/Slave connections have a strong focus on slaves and read routing. Use regular Pub/Sub connections with a Sentinel URL:
RedisURI redisUri = RedisURI.create("redis-sentinel://localhost:26379,localhost:26380/0#mymaster");
RedisClient client = RedisClient.create(redisUri);
RedisPubSubConnection<String, String> connection = client.connectPubSub();
See also the wiki for further details.