首页 文章

Spring spring配置服务器客户端可以监听新的更新事件吗?

提问于
浏览
1

Spring spring配置服务器客户端可以监听新的更新事件吗?例如:git仓库中的新提交 - >服务器发送事件 - >客户端通知和自定义函数调用! Thank you!

1 回答

  • 2

    由于git不需要使用你的git服务器的webhooks . 见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://<configserverurl>/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/

相关问题