问题spring-cloud-config和spring-cloud-bus

时间:2016-05-31 10:17:18

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

我有三个应用程序,一个是spring-cloud-config服务器点,另一个是spring-cloud-config客户端点。我在彼此配置spring-cloud-bus以使我的客户端点自动刷新更改但在我的应用程序运行中,我得到了一个例外

    c.netflix.discovery.TimedSupervisorTask  : task supervisor rejected the task

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@17834c50 rejected from java.util.concurrent.ThreadPoolExecutor@1944b0d0[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) ~[na:1.8.0_92]
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823) [na:1.8.0_92]
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369) [na:1.8.0_92]
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[na:1.8.0_92]
    at com.netflix.discovery.TimedSupervisorTask.run(TimedSupervisorTask.java:62) ~[eureka-client-1.4.6.jar:1.4.6]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_92]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_92]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_92]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_92]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_92]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_92]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92]

这是我的spring-cloud-server config

#git config
spring.cloud.config.server.git.uri = ###
spring.cloud.config.server.git.username=###
spring.cloud.config.server.git.password=###
spring.cloud.config.server.git.search-paths = puhui-cloud-config-client

#spring.active.profile
spring.profiles.active=dev

#spring-cloud-bus-amqp config
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.virtual-host=/

这是我的spring-cloud-config服务器pom

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

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

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
        </dependency>

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

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

    </dependencies>

这是我的spring-cloud-config客户端配置

#spring-cloud-config
spring.cloud.config.discovery.serviceId = PUHUI-CLOUD-CONFIG-SERVER
spring.cloud.config.name = @project.artifactId@
spring.cloud.config.profile = @profiles.active@
spring.cloud.config.label= master

spring.rabbitmq.host = localhost
spring.rabbitmq.port = 5672

这是我的spring-cloud-config客户端点pom

<dependencies>
        <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.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
        </dependency>
</dependencies>

此异常不会影响操作的应用程序,但我想知道应用程序抛出异常的原因

4 个答案:

答案 0 :(得分:2)

尝试为发现服务器中的客户端启用注册和获取注册表

eureka.client.registerWithEureka=true

eureka.client.fetchRegistry=true

答案 1 :(得分:0)

我认为错误日志与Eureka有关。你在运行Eureka服务器吗?您已在pom文件中添加了Eureka依赖项,但我在您的属性文件中未看到任何与Eureka相关的配置。尝试没有这些依赖项或构建一个Eureka服务器并与它们一起运行。或者至少在配置文件中添加以下属性。

eureka.client.enabled=false

答案 2 :(得分:0)

这是Eureka本身的问题,请尝试升级您使用的Eureka版本。您可以检查此https://github.com/spring-cloud/spring-cloud-netflix/issues/2228

答案 3 :(得分:0)

如果您将 application.yml 文件用于项目配置,则可以在发现服务器中为客户端启用注册和获取注册表:

eureka:
  client:
    fetch-registry: true
    register-with-eureka: true