2016-03-03 56 views
0

我配置了spring cloud config以從git存儲庫讀取屬性。對於當前實現,如果配置發生更改,如果發佈到/ refresh on我的客戶我能夠看到更新的屬性。現在,我想使用spring-cloud-bus-monitor來檢測我的git repo中的更改並自動刷新客戶端端點中的屬性。即使在依賴關係中添加spring-cloud-config-monitor之後,/ monitor端點也未啓用,因此即使配置服務器中的配置屬性發生更改 - 也不會刷新任何內容。無法爲推送通知啓用/監控彈簧雲總線端點

我有一個本地運行的RabbitMQ服務器。 欣賞如何讓啓用推送通知到所有客戶端在公交

http://localhost:8888/monitor

{ 
"timestamp": 1457025362412 
"status": 405 
"error": "Method Not Allowed" 
"exception": "org.springframework.web.HttpRequestMethodNotSupportedException" 
"message": "Request method 'POST' not supported" 
"path": "/monitor" 
} 

o.s.cloud.bus.event.RefreshListener  : Received remote refresh request. Keys refreshed [] 

服務器POM依賴關係/監視器任何指針:

<dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-config-monitor</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.cloud</groupId> 
     <artifactId>spring-cloud-starter-bus-amqp</artifactId> 
    </dependency> 

application.properties:

spring.cloud.config.server.git.uri=file:\\\C:\\Users\\spring-cloud-config 
server.port=8888 
spring.cloud.config.server.monitor.github=false 

pom依賴於clie nt:

 <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-config-client</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-config</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-actuator</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-autoconfigure</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-config-monitor</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.cloud</groupId> 
      <artifactId>spring-cloud-starter-bus-amqp</artifactId> 
     </dependency> 

回答

1

你不會說你正在使用的是哪個版本,它只在Brixton(最新版本是M5)中可用。刪除<scope>test</scope>

它應該是:

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

spring-cloud-config-monitor在客戶端不是必需的。

監視器是用於git託管服務webhooks。如果您使用的是文件系統,則必須使用native配置服務器配置文件。有關更多信息,請參見here

+0

謝謝!那就是訣竅。我使用Brixton構建,並使用git repo而不是文件系統。我還沒有使用webhook遠程推送配置更改,只要有一個主分支推入GIT倉庫,但我可以通過發佈手動將配置更改推送到客戶端。 [POST] http:// localhost:8888/monitor?path = demo –

+0

雖然我在這裏有一個問題 - 如果我使用通配符向所有客戶端廣播更改,性能問題是否會是性能問題? 例如:[POST] http:// localhost:8888/monitor?path = * 我問這個問題的原因是 - 我的所有配置屬性文件將在相同的回購協議中,並且當我使用webhook時--github將當有配置更改時,直接使用我的應用程序url推送更改,並且有效負載URL不會有更改哪個文件的上下文(即 - 不知道應用程序名稱)。有什麼想法嗎? –

+0

來自github的帖子中的信息告訴哪些文件發生了變化,並且'/ monitor'端點使用它來推斷髮送消息的應用程序。 – spencergibb

相關問題