-
-
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
Spring3.x集成Apollo后.无法监听到配置的变化 #2501
Comments
先打开客户端的debug日志看看 |
@nobodyiam 大佬. 我看了下源码发现点问题,想跟您确认下. config通过长连接获取配置然后与DefaultConfig.m_configProperties里做比对.比较出有差异的配置,然后再去调用自定义的ConfigChangeListener. 在方法DefaultConfig.updateAndCalcConfigChanges的177行里有一段代码: |
这个是设计的行为,system property的配置优先级最高 |
如果是这样的话,那我们启动的时候就不能向system property赋值了. 这样就等于在system property存了旧值. 会导致在Apollo Protal里修改了配置后无法监听到了. |
system property一般认为是用于单机临时调整的配置,比如-D参数 |
This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in 14 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 14 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. |
已经增加了监听,在项目运行中,发现值还是没有变化. 是不是还需要做其他的配置?
Config apolloConfig = ConfigService.getAppConfig();
apolloConfig.addChangeListener(new ConfigChangeListener() {
@OverRide
public void onChange(ConfigChangeEvent configChangeEvent) {
for (String key : configChangeEvent.changedKeys()) {
ConfigChange change = configChangeEvent.getChange(key);
System.setProperty(String.valueOf(key), String.valueOf(change.getNewValue()));
}
}
});
The text was updated successfully, but these errors were encountered: