skip to Main Content

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.

enter image description here

2

Answers


  1. If you are using spring boot try configuring connection in application.yaml or application.properties. See below example:

    spring:
      redis:
        host: 127.0.0.1
        port: 6379
        timeout: 200
        lettuce:
          pool:
            max-active: 16
            max-idle: 16
            min-idle: 8
            time-between-eviction-runs: 9000
    

    This is one way to configure Redis over lettuce, the above given values are indicative, use the configuration values as per your need.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search