lettuce icon indicating copy to clipboard operation
lettuce copied to clipboard

Couldn't find a way to get a pubsub connection with a sentinel-based topology

Open jflebeau opened this issue 8 years ago • 1 comments

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).

jflebeau avatar Mar 01 '18 15:03 jflebeau

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.

mp911de avatar Mar 01 '18 15:03 mp911de