【问题标题】:Spring Config Server does not seem to notify BusSpring Config Server 似乎没有通知 Bus
【发布时间】:2018-10-11 00:58:22
【问题描述】:

我正在使用 Spring 2.0.1.RELEASE 并使用 spring-cloud-bus 设置了所有项目(2 个服务和云配置服务器)

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amqp</artifactId>
    </dependency>

配置服务器也有 spring-cloud-config-monitor

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-monitor</artifactId>
    </dependency>

我在我的 Git 存储库中编辑了一个文件(使用带有 Spring Cloud Config 的本机配置文件的本地文件)。检测到更改,我在 云配置服务器:

17:59:25.201 [task-scheduler-3] INFO  o.s.cloud.bus.event.RefreshListener - Received remote refresh request. Keys refreshed [version.client.min]

但是,其他服务都没有收到有关更新密钥的通知。

另一方面,如果我手动调用任何其他服务的bus-refresh 端点,我会看到所有模块都收到更新后的密钥。配置服务器本身也收到通知,但它说没有更新密钥,这是有道理的,因为它已经检测到更改。

文档没有提到要设置除 RabbitMQ 属性之外的任何特殊属性(似乎配置得很好,因为 bus-refresh 端点按预期工作。)

我看到已经有一些关于此的帖子,其中一个甚至指向一个已标记为已解决的错误 (https://github.com/spring-cloud/spring-cloud-bus/issues/101),但它似乎对我不起作用。

配置服务器启用任何属性以通知总线? 关于如何调试的任何提示?

【问题讨论】:

    标签: spring-cloud-config spring-cloud-bus


    【解决方案1】:

    易于修复(经过大量研究!) 将 org.springframework.cloud 的所有依赖项从 FINCHLEY.M9 更改为 2.0.0.RC1,突然间,一切都开始工作了!

    【讨论】:

      【解决方案2】:

      也许你的 bootstrap.properties 文件没有在项目启动时加载

      所以有几件事是第一手的: 如果您正在使用(在您的 Cloud Config 项目中),

      &lt;spring-cloud.version&gt; 2020.0.0&lt;DependencyManagement&gt;&lt;properties&gt; 中指定

      然后Spring Boot版本低于2.4.1在同一个项目中)默认不会启动云配置服务器依赖关系。

      因此,如果您使用的是上述版本,也许还有以上版本,

      那么对于需要通过云总线更新的项目(例如使用 bootstrap.properties)应该包含 Starter Bootstrap 依赖项(当然还有 cloud-starter-configbus-amqp 依赖项)

      <!--    Spring Cloud Config + Cloud Bus + Bootstrap-->
      
              <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-config</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-bus-amqp</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-starter-bootstrap</artifactId>
              </dependency>
      

      另外检查 Spring 云版本是 2020.0.0-M6 还是 Hoxton.BUILD-SNAPSHOT,具体取决于您使用的 Spring Boot 版本。这是 Spring Cloud 版本与哪些 Spring Boot 版本兼容的截图

      v v v v v v v

      【讨论】:

        猜你喜欢
        • 2021-03-15
        • 2016-06-04
        • 1970-01-01
        • 2016-09-29
        • 2017-11-11
        • 2017-11-13
        • 1970-01-01
        • 2021-08-31
        • 2020-07-11
        相关资源
        最近更新 更多