I am using lettuce through the spring boot API org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory
.
My bean is configured as
@Bean
public LettuceConnectionFactory lettuceSentinelConnectionFactory() {
RedisSentinelConfiguration sentinelConfig = new RedisSentinelConfiguration(mastername, new HashSet<>(sentinelnodes));
return new LettuceConnectionFactory(sentinelConfig);
}
This works fine, except for reconnecting after topology changes, resulting in exceptions.
io.lettuce.core.RedisCommandExecutionException: READONLY You can't write against a read only slave.
Some bugreports seem to confirm this behaviour .
With great interest I read that lettuce implements a dynamic topology discoverer for sentinels SentinelTopologyProvider, which should fix the issue elegantly.
However I am unable to make the LettuceConnectionFactory use this dynamic SentinelTopologyProvider, and googling did not return anything neither.
Can anyone give a hint or some sample code on how to write this code?