我使用netflix Cloud 微服务架构做了很多新事 .
我的网络中运行了三个微服务:
- Zuul / Ribbon Service:localhost:8765
Application.yml: =============== eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/
-
尤里卡服务:localhost:8761
-
RentCarService:localhost:8888
现在,我的要求是: localhost:8765/RentCarService/getAllAvailableCars
此请求应自动路由到正确的微服务(RentCarService with Port 8888),如 localhost:8888/getAllAvailableCars
我看过很多教程,其中大部分都是以编程方式转发请求,就像在本教程中一样:
Microservice discovery with spring boot and eureka
Or here by a method called getServiceURL
我必须自己编写转发代码还是 this possible automatically by Ribbon ?
Beste关心的是lars
2 回答
到目前为止我得到了它的工作 . 我的主要问题是不同微生物的不同版本 . 请关心这个!
另一个想法:我认为自动路由(没有任何路由定义)是不可能的 . 我必须在路由定义中至少写出微服务的名称 . 在这种情况下,地址解析由Eureka服务器完成 .
如果我错了,请纠正我 .
到目前为止还没有自动路由这样的东西至少我们需要在你的yml文件中声明Zuul来处理路由 .
在你的application.yml中添加这些行
对于忽略任何路由,请使用ignoredServices属性
有关详细信息,请参阅此this链接 .
这将忽略您的服务的所有自动路由 .
希望这可以帮助你 .
谢谢 .