【问题标题】:Can spring cloud config server client listening new updates events ?spring 云配置服务器客户端可以监听新的更新事件吗?
【发布时间】:2017-09-28 20:07:38
【问题描述】:

spring cloud config server 客户端可以监听新的更新事件吗?例如:git 存储库中的新提交 -> 服务器发送事件 -> 客户端通知和调用自定义函数! 谢谢!

【问题讨论】:

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


    【解决方案1】:

    由于 git 没有事件,您需要使用 git 服务器的 webhook。见http://cloud.spring.io/spring-cloud-static/Camden.SR6/#_push_notifications_and_spring_cloud_bus

    在配置服务器上添加

    <parent>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-starter-parent</artifactId>
      <version>Camden.SR6</version>
      <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-monitor</artifactId>
      </dependency>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bus-amdp</artifactId>
        <!-- -amqp (rabbitmq) or -kafka -->
      </dependency>
    <!-- ... -->
    </dependencies>
    

    然后你需要添加一个 webhook 到你的配置服务器 http://&lt;configserverurl&gt;/monitor

    在配置客户端添加

    <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>
      <!-- -amqp (rabbitmq) or -kafka -->
    </dependency>
    

    更多细节在这里https://spencergibb.netlify.com/blog/2015/09/24/spring-cloud-config-push-notifications/

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-25
    • 1970-01-01
    • 1970-01-01
    • 2017-08-09
    • 2018-06-28
    • 1970-01-01
    • 2015-11-01
    相关资源
    最近更新 更多