Spring Cloud Zuul/Eureka动态路线 [英] Spring Cloud Zuul/Eureka dynamic route

查看:79
本文介绍了Spring Cloud Zuul/Eureka动态路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用spring cloud eureka和spring cloud zuul代理,我想知道当在eureka服务器中注册新服务时是否有任何方法可以添加动态zuul路由,或者添加路由的唯一方法是编辑应用程序. yml文件并重新启动spring zuul应用程序

I am using spring cloud eureka and spring cloud zuul proxy and i was wondering if there is any way to add dymanic zuul routes when a new service is register in eureka server or the only way to add a route is edit the application.yml file and restart the spring zuul application

zuul:
  ignoredPatterns: /**/admin/**
  routes:
    users: /myusers/**

推荐答案

如果您的Zuul服务器也是EurekaClient(使用@EnableDiscoveryClient批注),它将发现所有服务并自动创建路由.

If your Zuul server is also EurekaClient (use @EnableDiscoveryClient annotation) it will discover all the services and automatically will create routes.

例如Zuul服务器是zuul.mydomain.com 尤里卡(Eureka)有2个已注册的服务:订单和帐户

Ex. Zuul server is zuul.mydomain.com Eureka has 2 services registered with it : orders and accounts

然后Zuul将自动具有两条路线 Zuul.mydomain.com/orders和Zuul.mydomain.com/accounts

Then Zuul will automatically have two routes Zuul.mydomain.com/orders and Zuul.mydomain.com/accounts

这将转发到特定服务.如果服务在多台计算机上运行,​​它将自动为您平衡负载.

And this will forward to particular service. It will also automatically load balance calls for you if services run on multiple machines.

这篇关于Spring Cloud Zuul/Eureka动态路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆