spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
813 stars 541 forks source link

spring.config.import configuration option doesn't support Spring Retry #703

Closed sergey-morenets closed 3 years ago

sergey-morenets commented 3 years ago

Spring Cloud Consul Config always supported Spring Retry and there's a special consulRetryInterceptor bean in RetryConfiguration class (part of ConsulAutoConfiguration class).

Spring Boot 2.4 introduced new property - spring.config.import which we can use to specify Consul Config client settings:

spring:
  config:
    import: "consul:localhost:8500;app"

But it seems new approach doesn't support Spring Retry by two reasons:

1) consulRetryInterceptor bean loaded after spring.config.import configuration had been processed 2) There's no @Retryable methods in this new approach. ConsulPropertySourceLocator (which contains @Retryable methods) is not used

The first issue can be resolved by creating custom high-order EnvironmentPostProcessor. But the second issue seems unsolvable for now.

Please advice on how to use Spring Retry and spring.config.import together.

spencergibb commented 3 years ago

yes, this was left out do to timing. It was done in spring cloud config so it is possible.

sergey-morenets commented 3 years ago

Thank you, @spencergibb So the only way now to use Spring Retry in Spring Cloud Consul Config is to use legacy configuration approach with bootstrap.yml?

spencergibb commented 3 years ago

for now, using bootstrap will get you retry support.

sergey-morenets commented 3 years ago

for now, using bootstrap will get you retry support.

Great. Can you please update documentation that Spring Retry is not supported with spring.config.import option now? I was under impression it is supported and spent a lot of time on the investigation.

https://docs.spring.io/spring-cloud-consul/docs/current/reference/html/index.html#spring-cloud-consul-retry

spencergibb commented 3 years ago

I can't update the docs since they are part of the release, but I will add something to the known issues section of the release notes

spencergibb commented 3 years ago

Note added here https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2020.0-Release-Notes#known-issues

sergey-morenets commented 3 years ago

Thank you, @spencergibb Unfortunately I can't use "legacy" way because of another issue that I found: https://github.com/spring-cloud/spring-cloud-commons/issues/893

sergey-morenets commented 3 years ago

@spencergibb Thank you for the fix. Do you have estimation for 3.0.2 release date?

spencergibb commented 3 years ago

https://github.com/spring-cloud/spring-cloud-release/milestones

hannah23280 commented 3 years ago

https://github.com/spring-cloud/spring-cloud-release/milestones

Hi, can i say that after the fix, this is resolved. I am currently 2020.0.3, but yet the retry still not working.

spencergibb commented 3 years ago

@hanct I'm not sure I understand. This issue was to support retry with spring.config.import with consul. Either it works or it doesn't. If you'd like us to spend some time investigating, please take the time to open a new issue and provide a complete, minimal, verifiable sample (something that we can unzip attached to the new issue or git clone, build, and deploy) that reproduces the problem.