-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
关于配置变更的一些疑问 #5045
Comments
🤖 感谢您分享您在使用Apollo配置中心时遇到的问题和疑惑。您对@value修饰的属性值在@ApolloConfigChangeListener回调中获取到老值的困惑很有意义,这可能会影响到代码的简洁性和可维护性。 您提出的建议也很有建设性,包括提高@value修饰的值变更优先级和在官方文档中标注这个问题。这些都是对框架改进和文档完善的有益建议。 我鼓励您将这些问题和建议提交到Apollo的GitHub仓库,这样可以让更多的人参与讨论和评审,也有机会被框架的维护者们采纳。非常感谢您的贡献和反馈! This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
…attribute setting. issue: apolloconfig/apollo#5045
初始的设计考虑是 listener 之间不存在依赖关系,所以是异步执行。在你的场景,两个 listener 之间存在依赖关系(用户 listener 依赖了 AutoUpdateConfigChangeListener,这个场景确实要考虑下是否要支持以及该怎么支持。 |
感谢大佬的回复和解答,很期待后续的设计和变化 |
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 7 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted". Thank you for your contributions. |
springboot项目中,在apollo配置中心修改配置后,可以使用两种方式获得更改后的key
1、使用@value("${configKey}"),每次使用方法获取属性就可以获得新的值
2、@ApolloConfigChangeListener,在回调方法ConfigChangeEvent中可以获取新的值
基于代码的简洁性,我在代码中监听了某个key,在回调中使用了@value修饰的属性值,而不是用ConfigChange.getNewValue,在apollo中修改值后获取到了老的值,我对此有点困惑
翻看client源码中,看到触发变更AbstractConfig.fireConfigChange(final ConfigChangeEvent changeEvent) 使用线程池来更新,AutoUpdateConfigChangeListener来更新spring中@value修饰的值,这就解释了我为什么在@ApolloConfigChangeListener回调中使用@value修饰的属性值获得了配置变化的老值。
我有两点疑问:
1、是否可以将@value修饰的值变更优先级提高,用户自定义回调方法优先级降低,毕竟我们依赖框架是希望框架给解决一些黑盒问题,遇到问题还要去拆盒子。确实挺崩溃的。
2、如果1设计上上有别的考虑,是否可以在官方文档标注一下这个问题。
感谢大佬们
The text was updated successfully, but these errors were encountered: