我在python中使用端口8004的应用程序,它有端点。我需要将它集成到微服务平台,该平台具有Eureka发现服务器端口8001,Spring Boot管理端口8002,网关端口80.网关使用Zuul代理,并将请求转发到所需服务。
我有两个选择:
我决定有边车。 Sidecar端口8003,python-app端口8004. @EnableSidecar
注释+ @EnableDiscoveryClient
- 和魔术。然后我需要添加网关配置来转发对python-service的请求。我需要配置sidecar Zuul Proxy,因此它会将请求转发给python应用程序。
网关端口80 - >边车端口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。现在一切正常,并且在Spring Boot Admin中可以看到python-app。
我的两个问题:
@EnableSidecar
有@EnableCircuitBreaker
?如果有一个sidecar实例和python-service的多个实例,这是有道理的。我有1:1 - 一个边车和一个python-app。如果python app不可用,sidecar应该返回错误。我不需要断路器?或者我呢?@EnableSidecar
会影响Spring Boot客户端,因此它不会显示在Spring Boot Admin UI上。我认为有一个错误或如何在Spring Boot Admin web-ui中监控sidecar。Spring Boot版本是2.0.7,Spring Cloud版本是2.0.0
sidecar不应将请求代理到非jvm服务中。它使用java eureka客户端代表非jvm服务进行注册。然后,非jvm服务可以使用sidecar中的嵌入式zuul来向其他服务发出请求。它不需要了解eureka,hystrix(断路器)或功能区(客户端负载均衡器),但这是可选的。
好吧,我通过将Spring Cloud升级到2.1.1-RELEASE解决了这个问题。然后我有另一个问题。
Field restTemplate in org.springframework.cloud.netflix.sidecar.LocalApplicationHealthIndicator required a single bean, but 3 were found
为了解决这个问题,我添加了配置
@Configuration
public class RestTemplateConfig {
@Primary
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
从逻辑上看,sidecar应该将请求转发给应用程序。使用Hystrix,它不会等待及时响应,而是更快地失败。在sidecar中有断路器模式和功能的其他原因是什么?