1

У меня есть некоторые приложения, которые получают его конфигурацию с сервера Spring Cloud Config (Brixton.RELEASE) и хотели бы включить автоматическое обновление его свойства. Я следил за Spring Cloud Config documentation для настройки как серверных, так и клиентских приложений, но при внесении изменений в локальные файлы git ничего не происходит.Spring Cloud Config + Spring Cloud Bus + RabbitMQ - не автообновляющие клиенты с локальным репозиторием Git

конфигурация по умолчанию также обнаруживает изменения файловой системы в локальном мерзавце хранилища (webhook не используются в этом случае, но как только вы Редактирует файл конфиги освежать будет транслироваться).

Может кто-нибудь указать, что может быть неправильным или где отлаживать код Spring Cloud, чтобы проверить его?

Spring облако сервера Config:

server: 
    port: 8888 

info: 
    description: Spring Cloud Config Server 

spring: 
    application: 
    name: config-server 
    cloud: 
    config: 
     server: 
     git: 
      uri: file:///C:/Users/myuser/git/config-dev/ 

Spring облако серверов pom.xml

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

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

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

    <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
    </dependency> 

Spring Cloud Config Запуск журналы:

o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusInput 
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput] 
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel springCloudBusOutput 
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput] 
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel errorChannel 
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel] 
o.s.i.monitor.IntegrationMBeanExporter : Registering MessageChannel nullChannel 
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel] 
o.s.i.monitor.IntegrationMBeanExporter : Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal] 
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648 
o.s.c.s.binding.BindableProxyFactory  : Binding outputs for :interface org.springframework.cloud.bus.SpringCloudBusClient 
o.s.c.s.binding.BindableProxyFactory  : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusOutput 
s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]707ca986: startup date [Fri May 13 10:03:10 CEST 2016]; root of context hierarchy 
trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$73faa1d3] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
o.s.cloud.commons.util.InetUtils   : Cannot determine local hostname 
e.m.a.config.ConfigServerApplication  : No active profile set, falling back to default profiles: default 
s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]1ca610a0: startup date [Fri May 13 10:03:11 CEST 2016]; parent: org.springframework.boot[email protected]294a6b8e 
o.s.c.support.GenericApplicationContext : Refreshing [email protected]48e26a: startup date [Fri May 13 10:03:11 CEST 2016]; root of context hierarchy 
e.m.a.config.ConfigServerApplication  : Started ConfigServerApplication in 2.907 seconds (JVM running for 12.366) 
o.s.a.r.c.CachingConnectionFactory  : Created new connection: [email protected] [delegate=amqp://[email protected]:5672/] 
o.s.i.endpoint.EventDrivenConsumer  : Adding {message-handler:outbound.springCloudBus} as a subscriber to the 'springCloudBusOutput' channel 
o.s.integration.channel.DirectChannel : Channel 'config-server:8888.springCloudBusOutput' has 1 subscriber(s). 
o.s.i.endpoint.EventDrivenConsumer  : started outbound.springCloudBus 
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648 
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0 
o.s.i.endpoint.EventDrivenConsumer  : Adding {logging-channel-adapter:_org.springframework.integration.errorLogger} as a subscriber to the 'errorChannel' channel 
o.s.i.channel.PublishSubscribeChannel : Channel 'config-server:8888.errorChannel' has 1 subscriber(s). 
o.s.i.endpoint.EventDrivenConsumer  : started _org.springframework.integration.errorLogger 
o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147482647 
o.s.c.s.binding.BindableProxyFactory  : Binding inputs for :interface org.springframework.cloud.bus.SpringCloudBusClient 
o.s.c.s.binding.BindableProxyFactory  : Binding :interface org.springframework.cloud.bus.SpringCloudBusClient:springCloudBusInput 
o.s.c.s.b.r.RabbitMessageChannelBinder : declaring queue for inbound: springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg, bound to: springCloudBus 
o.s.integration.channel.DirectChannel : Channel 'springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg.bridge' has 1 subscriber(s). 
o.s.i.a.i.AmqpInboundChannelAdapter  : started inbound.springCloudBus.anonymous.t4cuHSE6RfKRYvPvrgfbUg 

Client App pom.xml:

<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>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.1.0.Final</version> 
    </dependency> 

    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-validator</artifactId> 
    </dependency> 

Client App конфигурации:

spring: 
    application: 
    name: app 
    cloud: 
    config: 
     uri: http://localhost:8888 

Client App Startup войти:

o.s.b.a.e.m.EndpointHandlerMapping INFO - Mapped "{[/bus/refresh],methods=[POST]}" onto public void org.springframework.cloud.bus.endpoint.RefreshBusEndpoint.refresh(java.lang.String) 
... 
o.s.i.m.IntegrationMBeanExporter INFO - Registering beans for JMX exposure on startup 
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel springCloudBusInput 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusInput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusInput] 
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel springCloudBusOutput 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=springCloudBusOutput': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=springCloudBusOutput] 
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel nullChannel 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=nullChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=nullChannel] 
o.s.i.m.IntegrationMBeanExporter INFO - Registering MessageChannel errorChannel 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageChannel,name=errorChannel': registering with JMX server as MBean [org.springframework.integration:type=MessageChannel,name=errorChannel] 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=org.springframework.cloud.bus.BusAutoConfiguration.acceptRemote.serviceActivator,bean=endpoint] 
o.s.i.m.IntegrationMBeanExporter INFO - Located managed bean 'org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal': registering with JMX server as MBean [org.springframework.integration:type=MessageHandler,name=errorLogger,bean=internal] 
o.s.b.a.e.j.EndpointMBeanExporter INFO - Registering beans for JMX exposure on startup 
+0

Вы совершили изменения? –

+0

Да, я также пробовал коммитировать, хотя это и не обязательно, документ указывает, что он проверяет файловую систему ... – codependent

+0

Только с собственным профилем, а не с git. – spencergibb

ответ

2

Попробуйте пройти эту документацию spring-cloud-config-push-notifications и не установите для установки ngrock. Кроме того, если вам просто нужно обновить git commit, вам даже не нужен проект облачной шины, достаточно просто настроить конфигурацию. Надеюсь это поможет.

+0

Благодарим вас за предложение использовать ngrok, он помог мне протестировать реальную репо GitHub вместо файловой системы. – codependent

0

Вы должны иметь парование зависимы в pom.xml компиляции («org.springframework.cloud:spring-cloud-stream-binder-rabbit») - Gradle если вы обливали вы RabbitMQ в другой системе, вам нужно указать хост-файл в application.properties

spring.rabbitmq.host: {{имя хоста}}

2

Вам потребуется сервер Config с Spring Cloud Bus и RabbitMQ (или Кафки или Redis) поддержки.

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

RabbitMQ со следующим обменом:

имя: springCloudBus

Тип: тема

прочный: истинный

Автоудаление: ложные

внутренний: ложные

сервер Config будет передавать данные на эту тему, как только он получает толчок события от любого из Github, Bitbucket или GitLab, через webhook к http://<config-server>/monitor

И клиентское приложение с библиотеками Config и RabbitMQ:

... 
<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> 
... 

Подписано на предыдущий обмен, чтобы получать сообщения с pr которые необходимо обновить.

Подробнее можно найти в моем блоге: http://tech.asimio.net/2017/02/02/Refreshable-Configuration-using-Spring-Cloud-Config-Server-Spring-Cloud-Bus-RabbitMQ-and-Git.html с кратким объяснением конфигурации, журналов и полного исходного кода для сервера конфигурации и клиентского приложения.

+0

Похоже, я могу использовать тот же (pub/sub механизм) для обновления JMX управления beans/конфигурациями. Или есть лучший способ централизовать управление JMX в кластерной среде? – alltej

Смежные вопросы