Refresh of Zuul configuration when using Spring Config Service

a 夏天 提交于 2019-12-19 10:49:27

问题


We have a Zuul proxy (wraped with Spring Cloud/Boot) deployed that fetches configuration from the Spring Config Server. Every time I do changes in the routes I restart Zuul application and I wonder if there is a better approach that can be taken (like refresh of Zuul config information)? :)

Thank you,


回答1:


You can issue a refresh command via rest:

curl -X POST http://<host>:<port>/refresh

I wrote a simple bash script that commits all my changes to the config file in the Git repository and then issue curl request to all my services.

If you wanted to be fancy you could write a script that first queries your Eureka server to get the list of all services and then refresh them all :)




回答2:


Zuul Routes could be dynamically refreshed when configuring them in a Git backend for instance, fronted by Spring Cloud Config server and Spring Cloud Bus.

I have covered this scenario in a recent blog post Routing requests and dynamically refreshing routes using Spring Cloud Zuul Server




回答3:


For #1, Spring cloud config introduced the @RefreshScope annotation which will expose the /refresh endpoint (over HTTP or JMX)

For #2, after '/refresh', spring cloud config will take the latest git commit, For the config changes, essentially there are two ways, 1) pull the changes 2) push the changes, spring cloud bus approach is based on the rabbitmq to push the config changes.

Check out this article

And this also



来源:https://stackoverflow.com/questions/37479044/refresh-of-zuul-configuration-when-using-spring-config-service

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