简体   繁体   English

由于使用spring cloud config,退出app时spring cloud consul注销失败

[英]spring cloud consul deregister failed when app exit because of use spring cloud config

i use spring cloud consul as register service, spring cloud config + git as config server. 我使用spring cloud consul作为注册服务,使用spring cloud config + git作为配置服务器。 an micro service app uses consul discovery configserver, then get value by propery key, also app need register service to consul for other consumers call. 一个微服务应用程序使用领事发现配置服务器,然后通过适当的密钥获取价值,另外,该应用程序还需要注册服务以领事其他消费者的电话。

dependency pom.xml: 依赖pom.xml:

    <parent>
       <groupId>org.springframework.cloud</groupId>
       <artifactId>spring-cloud-starter-parent</artifactId>
       <version>Brixton.SR4</version>
       <relativePath/>
    </parent>

    <dependencyManagement>
      <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-consul-dependencies</artifactId>
            <version>1.0.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>


    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-consul-discovery</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-actuator</artifactId>
    </dependency>

bootstarp.yml: bootstarp.yml:

cloud:
  config:
    enabled: true
    label: master
    name: demo
    discovery:
      enabled: true
      serviceId: CONFIG-SERVER
  consul:
    host: localhost
    port: 8500
    enabled: true
    discovery:
      enabled: true
      healthCheckPath: /health
      healthCheckInterval: 10s
      tags: dev

after app start success, can get value from configserver by key, also register service to consul success, but shutdown app(control+C), ConsulLifecycle deregister not be executed. 应用程序启动成功后,可以通过键从configserver获取值,也可以注册服务以成功完成领事,但是关闭应用程序(control + C),ConsulLifecycle注销不会执行。 log as follow: 记录如下:

2016-08-05 13:22:59.675  INFO 86816 --- [       Thread-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@c00fff0: startup date [Fri Aug 05 13:22:43 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@6989da5e
2016-08-05 13:22:59.678  INFO 86816 --- [       Thread-3] o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 0
2016-08-05 13:22:59.684  INFO 86816 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown
2016-08-05 13:22:59.685  INFO 86816 --- [       Thread-3] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans

so i delete dependency as follow, restart app and shutdown, service deregister success. 所以我按照以下方式删除依赖项,重新启动应用程序并关闭,服务注销成功。 but cannot get config property. 但无法获取配置属性。

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

2016-08-05 13:24:03.671 INFO  86820 ationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@52066604: startup date [Fri Aug 05 13:23:51 CST 2016]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3315d2d7
2016-08-05 13:24:03.674 INFO  86820 o.s.c.support.DefaultLifecycleProcessor  - Stopping beans in phase 0
2016-08-05 13:24:03.675 INFO  86820 o.s.c.consul.discovery.ConsulLifecycle   - Deregistering service with consul: demo-server-ed3e50ef60d3f5b1295f4866c46386d1
2016-08-05 13:24:03.777 INFO  86820 o.s.b.a.e.jmx.EndpointMBeanExporter      - Unregistering JMX-exposed beans on shutdown
2016-08-05 13:24:03.785 INFO  86820 o.s.b.a.e.jmx.EndpointMBeanExporter      - Unregistering JMX-exposed beans
2016-08-05 13:24:03.786 INFO  86820 o.s.j.e.a.AnnotationMBeanExporter        - Unregistering JMX-exposed beans on shutdown
2016-08-05 13:24:03.787 INFO  86820 o.s.j.e.a.AnnotationMBeanExporter        - Unregistering JMX-exposed beans

i don't know why, anything is conflict? 我不知道为什么,有什么冲突吗? look forwarding to any answer,thks @spencergibb 期待转发任何答案,@ spencergibb

我遇到了同样的问题,并在github上的spring-cloud-consul上打开了一个问题: https : //github.com/spring-cloud/spring-cloud-consul/issues/213

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM