2016-05-13 233 views
1

我有一些應用程序從Spring Cloud Config服務器獲取其配置(Brixton.RELEASE),並且希望啓用自動刷新其屬性。我遵循Spring Cloud Config documentation來配置服務器和客戶端應用程序,但是在對本地git文件進行更改時不會發生任何事情。Spring Cloud Config + Spring Cloud Bus + RabbitMQ - 無法使用本地Git存儲庫自動刷新客戶端

默認配置還檢測在本地的Git倉庫 (網絡掛接不是在這種情況下使用,但只要你 編輯配置文件的刷新將播出)文件系統的變化。

有人可以指出什麼可能是錯誤的或在哪裏調試Spring Cloud的代碼來檢查它?

春季雲服務器配置

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/ 

春天的雲服務器的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> 

春雲配置啓動日誌中

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 

客戶端應用的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> 

客戶端應用程序配置

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

客戶端應用啓動日誌

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」) - 搖籃 如果你有大清洗,你在你需要的另一個系統的RabbitMQ指定主機文件中application.properties

spring.rabbitmq.host:{{主機名}}

2

您需要使用Spring雲巴士和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

類型:話題

耐用:真

自動刪除:假

內部:假

的配置服務器將數據發送到一旦收到任何Github上,到位桶或GitLab的推動事件的話題,通過網絡掛接到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管理bean /配置。或者是否有更好的方法來在集羣環境中集中JMX管理? – alltej

相關問題