spring cloud auto refresh config server property

廉价感情. 提交于 2019-12-24 00:13:20

问题


I have configured spring cloud config which picks up property from Github. If I post to /refresh, I am also able to get the updated value in my application.

Now I want to get properties updated automatically. That means I don't want to hit refresh API to get the changes reflected in my application from Github property file to my application.

Do I need to implement Rabbitmq and cloud bus for it or there is any other simple way to do it? Also there document says that we need to add a dependency on the spring-cloud-config-monitor library for push notification. http://projects.spring.io/spring-cloud/spring-cloud.html#_push_notifications_and_spring_cloud_bus But I did not find any such dependency in maven to be added. Not sure if my understanding is wrong. Please help.


回答1:


You would need a Config server with Spring Cloud Bus and RabbitMQ (or Kafka or Redis) support.

RabbitMQ with the following exchange:

name: springCloudBus

type: topic

durable: true

autoDelete: false

internal: false

The config server would send data to the topic once it receives push events from Git (Github, Bitbucket, GitLab) via a webhook to http://<config-server>/monitor

And a client application with Config and RabbitMQ libraries, subscribed to the previous exchange to receive messages of the properties that need to be refreshed.

More could be found in my blog at: http://tech.asimio.net/2017/02/02/Refreshable-Configuration-using-Spring-Cloud-Config-Server-Spring-Cloud-Bus-RabbitMQ-and-Git.html with a brief explanation of the configuration, logs and full source code for the Config server and client app.




回答2:


They are not generally available yet. You need to add http://repo.spring.io/milestone/ as a maven repository and use a milestone release.



来源:https://stackoverflow.com/questions/33564275/spring-cloud-auto-refresh-config-server-property

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!