改造背景:
微服务配置中心承载着配置托管角色,出问题排查需要查看本地缓存配置,确认生效配置,此时发现apollo配置中心缓存下来不保证有序,配置非常多情况下排查比较麻烦
解决:
按照本文如下三步对apollo配置中心改造,即可实现apollo配置中心发布推送到客户端配置按照portal端显示顺序一致,方便在应用机器配置查阅。
1、apollo-clien修改
修改点一:
方法:
com.ctrip.framework.apollo.internals.LocalFileConfigRepository#onRepositoryChange(String namespace, Properties newProperties)
首先自己实现或参照 http://ju.outofmemory.cn/entry/119219 添加重写的有序Properties到client项目中。
原值
Properties newFileProperties = new Properties();
修改为
Properties newFileProperties = new LinkedProperties();
修改点二:
方法:
com.ctrip.framework.apollo.internals.RemoteConfigRepositor