Adds support for retry in profile specific properties.
in application-<profile>.{properties|yaml}
spring.config.import=configserver:http://configserver.example.com?fail-fast=true&max-attempts=10&max-interval=1500&multiplier=1.2&initial-interval=1100"
This required that the RetryTemplate be created as late as possible and it is no longer put in the bootstrap context. A RetryTemplateFactory was created so the LoaderInterceptor and the ConfigServerInstanceProvider can create a RetryTemplate. ConfigServerConfigDataLocationResolver creates RetryProperties from the url parameters if they are provided.
ConfigServerConfigDataLoader now creates a ConfigClientFailFastException and registers it in the application context rather and returns an empty ConfigData rather than throwing and exception. Then in ConfigClientAutoConfiguration an ApplicationStartedEvent is listened for and if the fail fast exception is there, throws it halting execution. This all allows logging in ConfigData to show.
Fixes gh-1797
This commit is contained in:
@@ -1565,9 +1565,21 @@ Then you need to add `spring-retry` and `spring-boot-starter-aop` to your classp
|
||||
The default behavior is to retry six times with an initial backoff interval of 1000ms and an exponential multiplier of 1.1 for subsequent backoffs.
|
||||
You can configure these properties (and others) by setting the `spring.cloud.config.retry.*` configuration properties.
|
||||
|
||||
TIP: To take full control of the retry behavior, add a `@Bean` of type `RetryOperationsInterceptor` with an ID of `configServerRetryInterceptor`.
|
||||
TIP: To take full control of the retry behavior and are using legacy bootstrap, add a `@Bean` of type `RetryOperationsInterceptor` with an ID of `configServerRetryInterceptor`.
|
||||
Spring Retry has a `RetryInterceptorBuilder` that supports creating one.
|
||||
|
||||
=== Config Client Retry with spring.config.import
|
||||
|
||||
Retry works with the Spring Boot `spring.config.import` statement and the normal properties work. However, if the import statement is in a profile, such as `application-prod.properties`, then you need a different way to configure retry. Configuration needs to be placed as url parameters on the import statement.
|
||||
|
||||
.application-prod.properties
|
||||
[source,properties]
|
||||
----
|
||||
spring.config.import=configserver:http://configserver.example.com?fail-fast=true&max-attempts=10&max-interval=1500&multiplier=1.2&initial-interval=1100"
|
||||
----
|
||||
|
||||
This sets `spring.cloud.config.fail-fast=true` (notice the missing prefix above) and all the available `spring.cloud.config.retry.*` configuration properties.
|
||||
|
||||
=== Locating Remote Configuration Resources
|
||||
|
||||
The Config Service serves property sources from `/{application}/{profile}/{label}`, where the default bindings in the client app are as follows:
|
||||
|
||||
Reference in New Issue
Block a user