阅读背景:

Spring Cloud Config Server (Spring Boot application)上刷新的键的空列表[]

来源:互联网 

In my Spring Cloud config server pom.xml I have

在我的Spring Cloud配置服务器pom中。xml我有

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-cloud.version>Finchley.M8</spring-cloud.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-monitor</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-bus</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

In bootstrap.properties I have specified with spring.cloud.config.server.git.uri the repository to fetch configuration properties from (as yml files). I have set up a Github webhook and have ngrok forwarding POST requests to port 8888 that the config server is listening on. When I commit a change to a yml configuration file, everything seems to go as expected:

在引导。我使用spring.cloud.config.server.git指定的属性。uri存储库以从(作为yml文件)获取配置属性。我设置了一个Github webhook,并让ngrok将POST请求转发到配置服务器正在监听的端口8888。当我对yml配置文件进行更改时,一切似乎都按照预期进行:

  1. In ngrok console window there is a POST request to /monitor and response with 200.
  2. 在ngrok控制台窗口中有一个POST请求/监视和响应200。
  3. The delivery is marked successful on Github's webhook management page.
  4. 交付在Github的webhook管理页面上被标记为成功。
  5. The following log entries are created in config server's console window.

    在config server的控制台窗口中创建以下日志条目。

    2018-03-14 13:55:03.023  INFO 17004 --- [nio-8888-exec-3] o.s.c.c.monitor.PropertyPathEndpoint     : Refresh for: develop_localhost
    2018-03-14 13:55:04.451  INFO 17004 --- [nio-8888-exec-3] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
    2018-03-14 13:55:04.483  INFO 17004 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@d3f5ec1: startup date [Wed Mar 14 13:55:04 EET 2018]; root of context hierarchy
    2018-03-14 13:55:04.521  INFO 17004 --- [nio-8888-exec-3] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$5a4e4f18] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    2018-03-14 13:55:06.027  INFO 17004 --- [nio-8888-exec-3] o.s.cloud.commons.util.InetUtils         : Cannot determine local hostname
    2018-03-14 13:55:06.041  INFO 17004 --- [nio-8888-exec-3] o.s.boot.SpringApplication               : No active profile set, falling back to default profiles: default
    2018-03-14 13:55:06.043  INFO 17004 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@429eafc3: startup date [Wed Mar 14 13:55:06 EET 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@d3f5ec1
    2018-03-14 13:55:06.053  INFO 17004 --- [nio-8888-exec-3] o.s.boot.SpringApplication               : Started application in 3.024 seconds (JVM running for 97.323)
    2018-03-14 13:55:06.054  INFO 17004 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@429eafc3: startup date [Wed Mar 14 13:55:06 EET 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@d3f5ec1
    2018-03-14 13:55:06.055  INFO 17004 --- [nio-8888-exec-3] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@d3f5ec1: startup date [Wed Mar 14 13:55:04 EET 2018]; root of context hierarchy
    2018-03-14 13:55:06.128  INFO 17004 --- [nio-8888-exec-3] o.s.cloud.bus.event.RefreshListener      : Received remote refresh request. Keys refreshed []
    

Why is the list of keys refreshed empty? When I check the local property source yml file, the change committed on Github and POSTed to the monitor endpoint is not reflected there either. I am running RabbitMQ on another server in my local network, and I can see on its web management console the connection from the config server and the channel created for it. Yet there are no messages on the overview tab.

为什么刷新的键列表是空的?当我检查本地属性源yml文件时,Github上提交给监视端点的更改也没有反映在那里。我正在本地网络中的另一个服务器上运行RabbitMQ,我可以在它的web管理控制台上看到来自配置服务器和为它创建的通道的连接。但是在overview选项卡上没有任何消息。

This used to work with Spring Boot 1.5.4.RELEASE and Spring Cloud Dalston.SR5 on the occasions when the embedded Tomcat/Jetty managed to start. The main reason to try version upgrades was that the servlet container actually started only like in 10% percent of the launches. Now with Spring Boot 2.0.0.RELEASE and Spring Cloud Finchley.M8, Tomcat always starts but the configuration changes do not seem to propagate to the config server and definitely not to RabbitMQ.

这用于使用Spring Boot 1.5.4。发布和Spring Cloud Dalston。当嵌入式Tomcat/Jetty成功启动时的SR5。尝试版本升级的主要原因是servlet容器实际上只有10%的启动。现在使用Spring Boot 2.0。释放和Spring Cloud Finchley。M8, Tomcat总是启动,但是配置更改似乎不会传播到配置服务器,而且肯定不会传播到RabbitMQ。

Any ideas?

什么好主意吗?

1 个解决方案

#1


0  

Now that I have updated spring-boot-starter-parent to 2.0.2.RELEASE in the config server pom.xml, config client gets its configuration from it. But as before, no push notification is propagated to RabbitMQ. Both the config server and client have their respective connections, channels and queues with RabbitMQ.

现在我已经将spring-boot-starter-parent更新为2.0.2。在配置服务器pom中释放。xml,配置客户端从它获取配置。但与以前一样,没有将push通知传播到RabbitMQ。配置服务器和客户机都有各自的连接、通道和与RabbitMQ的队列。

Now if I change spring-cloud.version to Finchley.BUILD-SNAPSHOT or Finchley.RC2 (and keep Spring Boot 2.0.2.RELEASE or change it to 2.0.1.RELEASE, no difference), I can see a queued message from the config server on the RabbitMQ web management console when it receives a push notification. Fine. The downside of the combination is that when config client tries to fetch its settings from the server, the server logs the exception below

现在如果我改变云朵。芬奇利的版本。BUILD-SNAPSHOT或芬奇利。保持Spring Boot 2.0.2。发布或更改为2.0.1。释放,没有区别),当RabbitMQ web管理控制台收到推送通知时,我可以看到来自配置服务器的队列消息。很好。这种组合的缺点是,当配置客户端试图从服务器获取其设置时,服务器会记录下的异常

2018-06-04 16:16:12.352 ERROR 10428 --- [nio-8888-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Cannot load environment] with root cause

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(Unknown Source) ~[na:1.8.0_144]
    at org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.lookupHttpClientBuilder(HttpClientConfigurableHttpConnectionFactory.java:69) ~[spring-cloud-config-server-2.0.0.BUILD-SNAPSHOT.jar!/:2.0.0.BUILD-SNAPSHOT]

and because the client does not get its configuration, it fails to boot.

由于客户端没有获得配置,它无法引导。

What would be the working combination of Spring Boot and Cloud versions to have both full RabbitMQ integration (with messages propagated to RabbitMQ) and successful config server and client interaction? Like I mentioned earlier, this used to work with Spring Boot 1.5.4.RELEASE and Spring Cloud Dalston.SR5, but downgrading to them is not an option.

Spring Boot和Cloud版本的工作组合是什么呢?它们将具有完整的RabbitMQ集成(与传递到RabbitMQ的消息一起)和成功的配置服务器和客户端交互?就像我前面提到的,这个习惯使用Spring Boot 1.5.4。发布和Spring Cloud Dalston。SR5,但是降级他们不是一个选项。


分享到: