【发布时间】:2019-04-29 11:38:05
【问题描述】:
我在 python 中有一个使用端口 8004 的应用程序,它有端点。我需要将它集成到微服务平台中,该平台有 Eureka 发现服务器端口 8001,Spring Boot Admin 端口 8002,网关端口 80。网关使用 Zuul 代理,它将请求转发到所需的服务。
我有两个选择:
- 更改我的 python-app 的代码,使其可以拥有 Spring Cloud 服务的端点
- 或者使用 Spring Cloud Sidecar - 它实现了这些端点。 https://cloud.spring.io/spring-cloud-netflix/multi/multi__polyglot_support_with_sidecar.html
我决定有边车。 Sidecar 端口 8003,python-app 端口 8004。@EnableSidecar 注释 + @EnableDiscoveryClient - 和魔术。然后我需要添加网关配置以将请求转发到 python-service。而且我需要配置 sidecar Zuul Proxy,所以它将请求转发到 python 应用程序。
网关端口 80 -> sidecar 端口 8003 -> python-app 端口 8004。
很漂亮,而且有效。当我打开 Eureka web-ui 时,所有服务都在那里。当我打开 Spring Boot Admin UI 时,它说 python-service(它的 sidecar)已关闭。
Spring Boot Admin客户端(sidecar端配置),端口为28003,与sidecar不同。
management:
server:
port: 18003
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
我用@EnableZuulProxy 替换了@EnableSidecar。现在一切正常,python-app 在 Spring Boot Admin 中可见。
我的两个问题:
如果sidecar默认不需要断路器,为什么
@EnableSidecar有@EnableCircuitBreaker?如果有一个 sidecar 实例和多个 python-service 实例,这是有意义的。我有 1:1 - 一个边车和一个 python-app。如果 python 应用程序不可用,sidecar 应该返回一个错误。我不需要断路器?还是我?为什么注解
@EnableSidecar会影响Spring Boot客户端,所以在Spring Boot Admin UI上不显示。我认为有一个错误或如何在 Spring Boot Admin web-ui 中启用 sidecar 监控。
Spring Boot 版本是 2.0.7,Spring Cloud 版本是 2.0.0
【问题讨论】:
标签: java spring-boot spring-cloud spring-boot-admin circuit-breaker