在Zuul中使用Hystrix Stream和Eureka First来查找Config服务器

时间:2016-01-18 09:31:03

标签: spring spring-boot spring-cloud netflix-eureka netflix-zuul

我使用Spring Cloud Brixton.M4和spring boot 1.3.1

我有

的zuul服务器
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-hystrix-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
    </dependency>

我首先使用Eureka找到Config-Server,所以bootstrap看起来像

spring:
 profiles: dev 
 cloud:
   config:
     fail-fast: true
     discovery:
       enabled: true
       serviceId: config-server

zuul是 UP 状态的两次首次登录,然后是 STARTING

2016-01-18 14:47:27.209  INFO 2808 --- [           main] c.w.i.edgeserver.EdgeServerApplication   : Started EdgeServerApplication in 21.651 seconds (JVM running for 22.232)
2016-01-18 14:47:56.231  INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - Re-registering apps/EDGE-SERVER
2016-01-18 14:47:56.270  INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003: registering service...
2016-01-18 14:47:56.281  INFO 2808 --- [ool-20-thread-1] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - registration status: 204
2016-01-18 14:48:06.230  INFO 2808 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003: registering service...
2016-01-18 14:48:06.238  INFO 2808 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_EDGE-SERVER/192.168.17.178:edge-server:8003 - registration status: 204

如果我通过设置

删除对config-server的依赖
spring:
 profiles: dev 
 cloud:
   config:
     fail-fast: false
     discovery:
       enabled: false
       serviceId: config-server
一切都运行良好。

1 个答案:

答案 0 :(得分:1)

我认为这是正常的(引导阶段必须注册以获取配置服务器位置,然后取消注册以让主应用程序再次注册)。在应用程序完全启动后,您可能会发现它已恢复为UP。