我已将我的 zuul 代理配置为与我的微服务的多个实例一起使用。我唯一做的就是将ribbon.listOfServers 关键字添加到我的配置中。
它适用于循环策略。
但是,当我关闭其中一个微服务实例功能区时,仍然会向该实例发送请求并将错误返回给客户端。
如何在 ZuulProxy 中启用 healthCheck 功能?
我的zuul配置如下图:
shared.microservice.customer.service1.url=ip1:port1/shared/microservice/customer/
shared.microservice.customer.service2.url=ip2:port2/shared/microservice/customer/
ribbon.eureka.enabled = false
zuul.routes.customer-micro-service.path: /shared/microservice/customer/**
zuul.routes.customer-micro-service.serviceId: customers
customers.ribbon.listOfServers = ip1:port1/shared/microservice/customer/,ip2:port2/shared/microservice/customer/
我的 Main Spring 类具有以下注释:
@EnableZuulProxy
@SpringBootApplication
@ComponentScan(basePackages = { "com.my.gateway"})
public class ZuulProxyApplication
我得到以下异常:
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:143) ~[spring-cloud-netflix-core-1.0.1.RELEASE.jar!/:1.0.1.RELEASE]
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:107) ~[spring-cloud-netflix-core-1.0.1.RELEASE.jar!/:1.0.1.RELEASE]
at com.netflix.zuul.ZuulFilter.runFilter(ZuulFilter.java:112) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.FilterProcessor.processZuulFilter(FilterProcessor.java:197) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.FilterProcessor.runFilters(FilterProcessor.java:161) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.FilterProcessor.route(FilterProcessor.java:120) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.ZuulRunner.route(ZuulRunner.java:84) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.http.ZuulServlet.route(ZuulServlet.java:111) [zuul-core-1.0.28.jar!/:?]
at com.netflix.zuul.http.ZuulServlet.service(ZuulServlet.java:77) [zuul-core-1.0.28.jar!/:?]
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: customersRibbonCommand failed and no fallback available.
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:782) ~[hystrix-core-1.4.4.jar!/:1.4.4]
at com.netflix.hystrix.AbstractCommand$16.call(AbstractCommand.java:769) ~[hystrix-core-1.4.4.jar!/:1.4.4]
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$1.onError(OperatorOnErrorResumeNextViaFunction.java:77) ~[rxjava-1.0.7.jar!/:1.0.7]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.7.jar!/:1.0.7]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.7.jar!/:1.0.7]
at rx.internal.operators.OperatorDoOnEach$1.onError(OperatorDoOnEach.java:70) ~[rxjava-1.0.7.jar!/:1.0.7]