问题
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