-
Notifications
You must be signed in to change notification settings - Fork 41.1k
@ConfigurationProperties should have an option to have properties read each time from Environment #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sounds like a wider scope than just That is leaving aside the question of whether this is a good idea or not. Is it a good idea? In a world of stateless micro-services isn't it better to just change the config and restart the app? Or are we mainly talking about development time? What's the benefit exactly? |
I am not sure if the original author is watching this or not. I agree, this might not be a great idea. Dynamically reloading properties can be a tricky problem, often just updating the I also can't see this being a very common use-case. Perhaps we can add some hooks to allow a roll-your-own solution if 'getting on each invocation' is really needed? |
Hey, I was not watching the issue from github, sorry about that. I'm the author of the request. I do not believe this has anything to do with beans other than As to whether or not reloadable configuration is a good idea in a world of micro cloud services, I'd just point out that this new cloud world isn't quite perfect yet. For us, rolling out new clusters into AWS (with sizes ranging from dozens to 100+ per app cluster) can take 45minutes just to get started and perhaps hours for caches to become warm. Because of that we often find it necessary to use feature flags based on properties to enable/disable functionality across our entire cloud infrastructure. This is something Archaius does rather nicely, and its just a shame at the moment I can't leverage Any kind of hook to allow me to customize the creation of |
Hi, We're very interested in this discussion, and the recent announcement about dynamic Spring props. We've built https://github.com/Capgemini/archaius-spring-adapter which sounds like it overlaps heavily with what @twicksell has been working on. We'd be interested in being involved in work in this area as it'd help us greatly on our current project. |
@andrewharmellaw our archaius bridge is here: https://github.com/spring-cloud/spring-cloud-netflix/tree/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/archaius. It would be good to get feedback, or pull requests if you like, via that project. |
Cheers @dsyer We'll take a look and see if we can contribute. We're big users of Spring (Boot especially), Camel, and various Netflix bits and pieces too. Anything which helps glue them together which is OSS is of interest to us. |
I was wondering if someone could point me (and other readers) in the direction of the "recent announcement about dynamic Spring props" as mentioned by andrewharmellaw above. I was interested to hear what the latest thinking is and I cant seem to find anything recent. |
Try here: http://projects.spring.io/spring-cloud/spring-cloud.html#_environment_changes (and some other bits of that section). |
Hmm, that seems to be documentation rather than an announcement as such. Can I assume in that case that the dynamic properties apply only to the Cloud and Boot products and there are no announced changes to the original Spring framework? |
Yes, it's a Cloud feature right now (but with really minimal dependencies, as long as you are using Spring Boot). |
@dsyer Hi, I am having this issue with Spring Cloud: I added a MapPropertySource to the env, I am changing the values from the ConcurentMap from another thread, but I can't see those values reflecting in env.getProperty or in @ConfigurationProperties beans. Pls advise! |
If you really changed the environment, you would see it in You have to rebind to get |
We've discussed the possibility of supporting a property that's a
Our feeling, as it was above, is that an event-based approach would be better. The event would provide a complete new instance of a configuration properties class with the changed value or values. This addresses both of the problems described above while also working with immutable configuration properties that are currently in plan for 2.2. The question remains if this is a good idea. We'd also be interested in hearing some of the use cases that a change in this area would enable. As things stand, there hasn't been particularly broad interest in this functionality. Given the reasonably large amount of complexity that it would introduce, it's difficult to justify implementing it at this time. |
Hi @philwebb @dsyer @wilkinsona, I think the original feature this issue requests have been implemented in my project: https://github.com/Code2Life/spring-boot-dynamic-config Adding With Spring Boot native features leveraged, and with the file watcher and hot-reload mechanism implemented by only 400+ lines of code, This lib is widely used in 20+ core applications for more than half a year in the company I'm working for. Hope this feature becomes a built-in feature of Spring Boot. @philwebb @dsyer @wilkinsona Would you like to take a look at the source codes and put some suggestions? Thanks ! |
Great job. As of a suggestion I would remove the Lombok dependency and only
depend on spring codebase.
One question: this dynamic configuration only affects the given project?
What about share configuration between project? That what spring-config is
intended to do, while your project is intented to make the configurations
dynamic to the project code base. How about security?
Do you want to incorporate your codebase to spring's codebase? Of course,
if they consider it interesting.
Regards,
Flavio Oliva
…On Sat, 22 Jan 2022, 13:01 Joey Yang, ***@***.***> wrote:
Already implemented in my project:
https://github.com/Code2Life/spring-boot-dynamic-config
Adding @DynamicConfig on @ConfigurationProperties
<https://github.com/ConfigurationProperties> simply works.
This lib is widely used in the company I work for. Hope this feature
becomes a built-in feature of Spring Boot. @philwebb
<https://github.com/philwebb> @dsyer <https://github.com/dsyer>
—
Reply to this email directly, view it on GitHub
<#259 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL55TDUF5U2KYPXIOADRWLUXKTBFANCNFSM4ALPH44A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@denon82 Thanks !
|
Thanks very much for sharing the project @Code2Life. It looks like an interesting alternative to |
Thanks for reviewing @philwebb , |
FYI |
@RefreshScope may not be secure enough as it will first destroy the current bean and then create a new bean. What if the environment properties encounter an exception when creating a new bean? This online running application will be a disaster. Is it possible to adjust the order and first try creating a temporary bean? If it can be initialized normally, then replace the original bean. This will be a significant optimization for runtime configuration updates. |
In addition,if it is possible to move @RefreshScope from spring-cloud to spring boot? it should not be bundled to spring cloud project. I am a core builder in the Nacos community (https://nacos.io/en/) which is widely used by chinese developer community and I am responsible for config center. |
There are no plans to move |
Originally raised on the SPR issue tracker:
https://jira.springsource.org/browse/SPR-11289
@ConfigurationProperties
objects should have some mechanism for allowing some or all properties to be read from a propertySource on each get invocation. It seems like instead of injected a concrete implementation into the AppContext we should inject a proxy for the Config object which can reference the Environment abstraction.The usecase for this would be when we have implemented a custom PropertySource which is aware of property changes.
The text was updated successfully, but these errors were encountered: