Spring Cloud RefreshScope 刷新后 Hook

标签 spring spring-boot spring-cloud spring-cloud-config

是否有 @RequestScope 刷新后 Hook 的概念?

用例: 我们需要推送配置更改。目前,这是手动的,并作为应用程序重新启动的一部分触发。但是,如果我们可以触发/bus/refresh,一旦环境刷新,就不会销毁 bean(在本例中为 @Service),而是在新环境值更新后触发一些配置更改?这样的事情可能吗?

最佳答案

我使用的解决方案是让我的@Service实现ApplicationListener并重写onApplicationEvent(RefreshRemoteApplicationEvent event)。这已经在 RefreshListener 中执行,但我的实现能够检查更改的键并根据客户端为特定键更改设置的规则使用react。

关于Spring Cloud RefreshScope 刷新后 Hook ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36633185/

相关文章:

java - RabbitMQ - 没有找到停止 Spring 服务器的队列

postgresql - Spring Data R2dbc中处理表间关系的最佳实践

java - Spring Boot 使用 Gradle 找不到 spring-boot-starter-dao-jpa 包?

spring-cloud - 如何在Spring Cloud Gateway中为每个路由设置超时?

java - 如何在 application.yml Spring Cloud Gateway 中指定自定义过滤器

java - 在 centOS Linux Box 中运行的 Spring Java Mail 程序抛出异常

java - Cassandra 实体必须具有 @Table、@Persistent 或 @PrimaryKeyClass 注解

spring - 如何在 Spring Cloud AWS SQS 中以编程方式设置消息处理程序?

Java WSDL 修改或隐藏 Web View 上的某些属性