Skip to content
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

修复 Nacos 集群模式下获取到旧配置问题 | Fixed: server pulling old config in Nacos cluster mode #3600

Merged
merged 4 commits into from
Jan 29, 2024

Conversation

ruansheng8
Copy link
Collaborator

@ruansheng8 ruansheng8 commented Jan 22, 2024

Describe what this PR does / why we need it

image

改造逻辑:

  1. 用户在 Nacos 更新配置,服务接受到更新后的配置内容,将收到的配置内容缓存到内存中
  2. 向 Spring 容器发送一个 RefreshEvent 刷新下上下文,RefreshEvent 监听器收到事件后开始触发上下文刷新逻辑
  3. 根据 dataId + group 判断是否存在本地内存快照,如果存在本地快照则直接使用(快照取出后会直接被移除,避免占用内存),如果快照不存在则调用 Nacos Api 获取远程配置

其他说明

由于 Spring 在处理 RefreshEvent 的时候,并没有将 Event 原始数据传入后续的业务逻辑,所以这里单独声明了一个 Nacos 快照配置管理工具类管理 Nacos 临时配置
image

@chickenlj
Copy link
Collaborator

fixes #3322

Copy link
Collaborator

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@ruansheng8 ruansheng8 changed the title 修复 Nacos 集群模式下获取到旧配置问题 修复 Nacos 集群模式下获取到旧配置问题 | Fixed: server pulling old config in Nacos cluster mode Jan 22, 2024
@ruansheng8 ruansheng8 self-assigned this Jan 22, 2024
@ruansheng8 ruansheng8 added kind/bug Mark as bug area/nacos spring cloud alibaba nacos labels Jan 22, 2024
@steverao steverao merged commit c5d2f98 into alibaba:2.2.x Jan 29, 2024
2 checks passed
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this pull request Jan 29, 2024
* Fix nacos config update in Nacos cluster

* add capacity limit for nacos config snapshots

* add capacity limit for nacos config snapshots

* optimized the nacos config snapshot
steverao pushed a commit that referenced this pull request Jan 29, 2024
* Fix nacos config update in Nacos cluster

* add capacity limit for nacos config snapshots

* add capacity limit for nacos config snapshots

* optimized the nacos config snapshot
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this pull request Mar 7, 2024
* Fix nacos config update in Nacos cluster

* add capacity limit for nacos config snapshots

* add capacity limit for nacos config snapshots

* optimized the nacos config snapshot
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this pull request Mar 8, 2024
* Fix nacos config update in Nacos cluster

* add capacity limit for nacos config snapshots

* add capacity limit for nacos config snapshots

* optimized the nacos config snapshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/nacos spring cloud alibaba nacos kind/bug Mark as bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants