Skip to content

Easy set up for Sentinel's ReadMode in Spring #7001

@andreasarf

Description

@andreasarf

Is your feature request related to a problem? Please describe.

I integrated Redisson to my Spring Boot projects via redisson-spring-boot-starter. It is really convenient because it can pick spring.data.redis config without having to set up multiple, redundant Redis config.

<dependency>
    <groupId>org.redisson</groupId>
    <artifactId>redisson-spring-boot-starter</artifactId>
    <version>3.52.0</version>
</dependency>

Now, I have been testing Redis Sentinel and just put spring.data.redis.sentinel to activate both Spring Redis and Redisson.

spring:
  data:
    redis:
      repositories:
        enabled: false
      sentinel:
        master: mymaster
        nodes:
          - localhost:26379
          - localhost:26380
          - localhost:26381

However, the problem occurs when I am trying to change Redisson's ReadMode into Master (because the default is Slave). I need to put extra, redundant config. I cannot just change the ReadMode into Master; I need to also put other properties, like masterName and sentinelAddresses

spring:
  data:
    redis:
      repositories:
        enabled: false
      sentinel:
        master: mymaster
        nodes:
          - localhost:26379
          - localhost:26380
          - localhost:26381
    redis:
      redisson:
        config: |
          sentinelServersConfig:
            masterName: "mymaster"
            sentinelAddresses:
              - "redis://127.0.0.1:26379"
              - "redis://127.0.0.1:26380"
              - "redis://127.0.0.1:26381"
            readMode: "MASTER"
            subscriptionMode: "MASTER"

Describe the solution you'd like

I would like to have simple, standalone Spring config to change the sentinel's ReadMode.

Describe alternatives you've considered

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions