I’m trying to established reactive connection via lettuce,
connection
@Bean
public LettuceConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory();
}
Reactive Redis Template
@Bean
public ReactiveRedisTemplate<String, Object> reactiveRedisTemplate(ReactiveRedisConnectionFactory connectionFactory) {
KryoSerializer<String> kryoSerializer = new KryoSerializer<>();
RedisSerializationContext<String, Object> serializationContext = RedisSerializationContext.<String, Object>newSerializationContext(new StringRedisSerializer())
.hashKey(new StringRedisSerializer())
.hashValue(kryoSerializer)
.build();
return new ReactiveRedisTemplate<>(connectionFactory, serializationContext);
}
After Debug the code,i found reactive connection not established, Anyone have correct configuration of Redis connection via lettuce.
2
Answers
If you are using spring boot try configuring connection in application.yaml or application.properties. See below example:
This is one way to configure Redis over lettuce, the above given values are indicative, use the configuration values as per your need.
seems like I am trapped in same situation like you.I used lettuce to connect with azure redis service and redis template function rightpop with limited waiting time,my yml config for redis is timeout: 600000
if rightpop parameter of limit time is more than 600000ms and the block quene in connection pool ,the connection with redis will not be reconnect again.
finally we change from lettuce to jedis,and error never raise again