Spring-cloud-config: Config Client Retry Not Working

Created on 8 Nov 2017  路  10Comments  路  Source: spring-cloud/spring-cloud-config

Hi,

Description

I have been trying to dockerize my Spring boot Application that contains a Config Server and a Config Client. I've been following the steps mentioned in the Document but the Retry behavior is not working as expected.

Property Configuration

spring:
  cloud:
     config:
       fail-fast: true
       retry:
         max-attempts: 10000
         max-interval: 1000

Details

This is the content that is present in both bootstrap.yml and application.yml under the config client service that uses the config-server running on port 8888.

I have a set of Bean that is creating a TransportClient bean for Elasticsearch that causes the error `Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'elasticsearch.host' in value "${elasticsearch.host}"``

What I noticed is, that the spring.cloud.config.retry.* properties have no effect and I don't see any retry attempts being done from the Config Client. I also tried the spring.config.retry.* properties with same results.

Gradle Configuration

compile("org.springframework.boot:spring-boot-starter-web:1.5.7.RELEASE")
compile("org.springframework.cloud:spring-cloud-starter-config:1.3.3.RELEASE")
// Retry Methods
compile("org.springframework.retry:spring-retry:1.2.1.RELEASE")
compile("org.springframework.boot:spring-boot-starter-aop:1.3.3.RELEASE")

Can you please help me understand what I am missing in this case and why the retry is not working ?

waiting for feedback

Most helpful comment

might a little bit late. but also this might help someone looking around like me.

you need to get the following understandings first

  • failFast the SpringBoot application, so that the default config won't work in any case
  • initial-interval & maxAttempts ... etc won't work unless you fix some dependencies in your maven/gradle file
    in my case, gradle alongside with yml ... the following were a must:
    1) compile('org.springframework.cloud:spring-cloud-starter-config')
    2) compile("org.springframework.boot:spring-boot-starter-actuator")
    3) compile("org.springframework.retry:spring-retry")
    4) compile("org.springframework.boot:spring-boot-starter-aop")

so eventually you will have a bootstrap.yml file that looks like this

server:
port: 9000
spring:
application:
name: command-api
cloud:
config:
uri: http://config:8888
failFast: true
retry:
initialInterval: 2000
maxAttempts: 30

I hope this help out somebody

All 10 comments

First thing I noticed is that you are not using the BOM.

dependencyManagement {
  imports {
    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.M2'
  }
}

dependencies {
    compile 'org.springframework.cloud:spring-cloud-starter-config'
}

It is unclear to me what the elastic search property has to do with the retry not working. Could you please provide the complete logs?

@ryanjbaxter

Elasticsearch property has nothing to do with the Retry not working. The error I am observing with respect to elasticsearch is because of Retry not working.

The Scenario is as follows.

I have a set of Properties in application.yml and application-local.yml in the git repo that is configured under Config Server.

I have a client Service that relies on the Config Server to create @Bean for Elasticsearch client under the @EnableAutoconfiguration class. For some reason, i've been noticing failure on the availability of the Config Server endpoints (Root cause still unknown).

Due to this unavailability of Config server, when I am trying to deploy the Client application, it fails to initialize the @Bean and fails.

The Retry method I added based on the document is not working. There is literally no logs generated other than the one that corresponds to the Annotation Processing while it's trying to resolve a SPEL variable syntax through @Value annotation.

Will give a try to the mavenBom and see if that fixes my problem.

@ryanjbaxter

I tried including the mavenBom details in my build.gradle file. But the issue still exists. Haven't been able to put some time and run the Spring Boot app in debug mode to figure out exactly what's going wrong while Autowiring and Bean Processing. Any suggestion is appreciated.

I also ran into this problem. My scenario was as follows:

  1. I had a spring boot application which was using the cloud config server.
  2. I was using Eureka discovery service to register the config server.
  3. I configured the retry information as you have done in the dependent spring boot application so that it would keep retrying to find the configuration server if it had not yet started.
    It was not retrying.
    I fixed it by changing the spring-cloud-dependencies version to org.springframework.cloud:spring-cloud-dependencies:Camden.SR3"

Could one of you provide me with your Maven/Gradle dependencies? Even better would be a sample app that reproduces the problem.

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

I am experiencing this problem with my spring-boot app.
Spring boot 1.5.7
Spring cloud config client 1.3.3
Spring core 4.3.11

Intentionally shut down a localhost spring config server such that I get a Connection refused https://localhost:8888/a/b/c

Bootstrap.yml
Tried with and without failFast true/false, and this setting takes effect.
Clearly only 1 attempt is made, with and without other settings like maxAttempts

spring:
  cloud:
    config:
      retry:
        initial-interval: 1000
        maxInterval: 3000
        maxAttempts: 30
        multiplier: 1.1
      uri: https://localhost:8888

Could you provide a sample app?

might a little bit late. but also this might help someone looking around like me.

you need to get the following understandings first

  • failFast the SpringBoot application, so that the default config won't work in any case
  • initial-interval & maxAttempts ... etc won't work unless you fix some dependencies in your maven/gradle file
    in my case, gradle alongside with yml ... the following were a must:
    1) compile('org.springframework.cloud:spring-cloud-starter-config')
    2) compile("org.springframework.boot:spring-boot-starter-actuator")
    3) compile("org.springframework.retry:spring-retry")
    4) compile("org.springframework.boot:spring-boot-starter-aop")

so eventually you will have a bootstrap.yml file that looks like this

server:
port: 9000
spring:
application:
name: command-api
cloud:
config:
uri: http://config:8888
failFast: true
retry:
initialInterval: 2000
maxAttempts: 30

I hope this help out somebody

Thanks, was just about having all mentioned dependencies.

Was this page helpful?
0 / 5 - 0 ratings