spring-cloud-tencent
spring-cloud-tencent copied to clipboard
【需求认领】配置变更支持 Spring 原生的 Event 事件
What is the feature you want to add?
目前动态配置支持监听配置变更事件,自定义配置监听器
但是上述实现是 SCT 自己实现的,并没有对接 Spring 原生的 Event 机制,期望可以通过 Spring 的 Event 机制实现配置变更的监听。 Why do you want to add this feature?
How to implement this feature?
- 新增 Spring 配置变更 Event 类,继承 ApplicationEvent,并把已有的 ConfigChangeEvent 类作为 Source,这样就可以拿到 Event 所有信息
- 在 PolarisConfigChangeEventListener 新增发布 ApplicationEvent
Additional context Add any other context or screenshots about the feature request here.
@lepdou 我来试试。有时间要求吗?预计下周才有时间研究和编写代码
@lepdou 我来试试。有时间要求吗?预计下周才有时间研究和编写代码
时间上先暂定这个月~
@DerekYRC 感谢支持~ 时间上没有要求,不是紧急需求
@lepdou @SkyeBeFreeman 好的,没问题
@lepdou @SkyeBeFreeman 讨论下两个问题:
1、"把已有的ConfigChangeEvent类作为Source"的做法可能不太合理。发布ConfigChangeEvent事件的前提是PolarisConfigKVFileChangeListener注解指定了感兴趣的keys,如果没有指定感兴趣的keys就不发布Spring的配置更新事件,显然不合理。
把更新的配置项(下图中的changes变量)作为事件的source,如何?

2、事件命名为ConfigChangeSpringEvent,如何?
@lepdou @SkyeBeFreeman 讨论下两个问题:
1、"把已有的ConfigChangeEvent类作为Source"的做法可能不太合理。发布ConfigChangeEvent事件的前提是PolarisConfigKVFileChangeListener注解指定了感兴趣的keys,如果没有指定感兴趣的keys就不发布Spring的配置更新事件,显然不合理。
把更新的配置项(下图中的changes变量)作为事件的source,如何?
2、事件命名为ConfigChangeSpringEvent,如何?
1, The configuration change published events, Whether to publish all change events or based on the business specified configuration key, this place for the definition of the function is different , does it need to be discuss ? @lepdou
2, ConfigChangeListener parameters can not be defined as events, can change class name, the version upgrade is recommended to consider backward compatibility (@PolarisConfigKVFileChangeListener) .
@DerekYRC @misselvexu
1、"把已有的ConfigChangeEvent类作为Source"的做法可能不太合理。发布ConfigChangeEvent事件的前提是PolarisConfigKVFileChangeListener注解指定了感兴趣的keys,如果没有指定感兴趣的keys就不发布Spring的配置更新事件,显然不合理。
我觉得 spring 的 event 机制和 PolarisConfigKVFileChangeListener 应该是两个独立的处理逻辑,不应该有”潜在“的关系。所以 spring 的 event 应该是所有变更事件都要发布这个事情,然后在事件处理的地方用户自己去处理感兴趣的key。
把更新的配置项(下图中的changes变量)作为事件的source,如何?
我觉得可以
2、事件命名为ConfigChangeSpringEvent,如何?
可以的
@DerekYRC @misselvexu
1、"把已有的ConfigChangeEvent类作为Source"的做法可能不太合理。发布ConfigChangeEvent事件的前提是PolarisConfigKVFileChangeListener注解指定了感兴趣的keys,如果没有指定感兴趣的keys就不发布Spring的配置更新事件,显然不合理。
我觉得 spring 的 event 机制和 PolarisConfigKVFileChangeListener 应该是两个独立的处理逻辑,不应该有”潜在“的关系。所以 spring 的 event 应该是所有变更事件都要发布这个事情,然后在事件处理的地方用户自己去处理感兴趣的key。
把更新的配置项(下图中的changes变量)作为事件的source,如何?
我觉得可以
2、事件命名为ConfigChangeSpringEvent,如何?
可以的
好的