question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fill variables in redisson.yml with Spring Boot values.

See original GitHub issue

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

We are using redisson-spring-boot-starter. We were hoping that we could configure Redisson with a redisson.yml, but also configure more dynamic properties from our application.yml.

# application.yml
spring:
  redis:
    host: ${REDIS_HOSTNAME}
    redisson: 
      file: classpath:redisson.yaml

When we run in a different environment we can overwrite the Redis hostname by setting an environment variable. With Spring Boot profiles (for example “local”), we could have an application-local.yml that contains the following:

# application-local.yml
spring:
  redis:
    host: localhost

Or set the placeholder itself:

# application-local.yml
REDIS_HOSTNAME: localhost

That way we would be able to have different configurations for our local run configuration compared to what we use in our production systems. Detailed properties for Redisson (described in redisson.yml) are the same for all environment, while things like the host, port or ssl properties can change depending on the environment where the application is running.

Describe the solution you’d like

If the merging of application.yml(or application-local.yml) with redisson.yml is not possible, can we then maybe have some feature where we fill variables with Spring Boot values. That way the redisson.yml would be able to look like:

# redisson.yml
singleServerConfig:
  idleConnectionTimeout: 10000
  connectTimeout: 10000
  timeout: 3000
  retryAttempts: 3
  retryInterval: 1500
  subscriptionsPerConnection: 5
  address: "redis://${REDIS_HOSTNAME}:6379"
  subscriptionConnectionMinimumIdleSize: 1
  subscriptionConnectionPoolSize: 50
  connectionMinimumIdleSize: 10
  connectionPoolSize: 64
  dnsMonitoringInterval: 5000

In such a way, we would be able to create an application-local.yml that looks like this:

# application-local.yml
REDIS_HOSTNAME: localhost

With Spring Boot values I mean the values described by externalized configuration here. That way there are many ways to inject variables into the configuration of Redisson.

Describe alternatives you’ve considered

We currently are using the following as an application.yml:

# application.yml
spring:
  redis:
    redisson:
      config: |
        singleServerConfig:
          idleConnectionTimeout: 10000
          connectTimeout: 10000
          timeout: 3000
          retryAttempts: 3
          retryInterval: 1500
          subscriptionsPerConnection: 5
          address: "redis://${ELASTICACHE_URL}:6379"
          subscriptionConnectionMinimumIdleSize: 1
          subscriptionConnectionPoolSize: 50
          connectionMinimumIdleSize: 10
          connectionPoolSize: 64
          dnsMonitoringInterval: 5000

This works for us but puts a lot of detail for a specific dependency in the application.yml. These fields are never changed. The values are prone to mistakes.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mrnikocommented, May 27, 2022

@Blockost

I’m ready to consider any contribution.

0reactions
Blockostcommented, May 14, 2022

Any news on this @mrniko ? It’s been quite some time now since this feature request has been submitted but it does not seem to be implemented yet right ? I’m very interested in this !

Read more comments on GitHub >

github_iconTop Results From Across the Web

redisson.yaml environment variable - spring boot
I am using Redisson with Spring-boot and I need to pass in an environment variable to redisson.yaml. address: "redis://${REDIS_HOST}:6379".
Read more >
21. Externalized Configuration - Spring
You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration. Property values can be injected ...
Read more >
[Solved]-redisson.yaml environment variable-Springboot
How to use environment variable in custom yaml file in spring boot application? ... Spring Boot: How do you specify an environment variable...
Read more >
Implementing a Cache with Spring Boot - Reflectoring
Spring Boot will set up the configuration for embedded topology if hazelcast.xml or hazelcast.yaml is found on the classpath. In these files, we ......
Read more >
Working with application properties in Spring Boot - Dev Genius
We set environmental variables but we also set a fallback value if the environmental variables are not set. So it will not give...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found