Redis OM Spring with two or more connections for the repositories

136 views Asked by At

I am trying to use a redis master-replica in my Spring application using Redis OM Spring. Jedis, the library used to implement all the functionalities for Redis OM, doesn't support write to master and read from replica by configuration (https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis:connectors:connection).

I am trying to configure two different connections with Redis and define two repositories with the same class but configuring each one for each one of the connections. I have defined two classes with the @EnableRedisDocumentRepositories with different JedisConnectionFactory and a RedisTemplate. But, when I run the application, both repositories connect to the same connection. Perhaps it is related with the @Primary annotation defined in the first ConnectionFactory.

I am not finding documentation where there is an example or explanation where I can customize the connection for the repositories.

Is it possible to define to different Redis repositories with different connections in the same Spring application?

thanks in advance

I am trying to connect with two different redis dbs with redis-om-spring using two different connections and I am expecting to connect with both dbs.

0

There are 0 answers