我有一个Spring Boot Zuul作为外部网关和Eureka作为服务发现的场景,所有这些都在Kubernetes中运行。Zuul重试配置不适用于Eureka
事情是,我想保证我的服务的可用性,所以当我的服务实例出现故障时,我希望Zuul通过Eureka重新尝试调用其他实例之一。
我试着按照这样做Ryan Baxter's post。 另外,我试图按照here的提示进行操作。
问题是,无论我做什么,看起来像Zuul不会重试打电话。当我删除我的一个实例时,它会一直向我返回此实例的超时,直到Eureka地址得到同步。
我application.yaml看起来是这样的:
spring:
cloud:
loadbalancer:
retry:
enabled: true
zuul:
stripPrefix: true
ignoredServices: '*'
routes:
my-service:
path: /my-service/**
serviceId: my-service-api
retryable: true
my-service:
ribbon:
maxAutoRetries: 3
MaxAutoRetriesNextServer: 3
OkToRetryOnAllOperations: true
ReadTimeout: 5000
ConnectTimeout: 3000
我的服务是使用卡姆登SR7(我也试过SR6):
"org.springframework.cloud:spring-cloud-dependencies:Camden.SR7"
而且还弹簧重试:
org.springframework.retry:spring-retry:1.1.5.RELEASE
我的应用程序类看起来像这样:
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
@EnableRetry
public class MyZuulApplication
编辑:
制作打通邮差,它带来
{
"timestamp": 1497959364819,
"status": 500,
"error": "Internal Server Error",
"exception": "com.netflix.zuul.exception.ZuulException",
"message": "TIMEOUT"
}.
以一看Zuul日志,它印{"level":"WARN","logger_name":"org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter","appName":...,"message":"Error during filtering","stack_trace":"com.netflix.zuul.exception.ZuulException: Forwarding error [... Stack Trace ...] Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: my-service-api timed-out and no fallback available [... Stack Trace ...] Caused by: java.util.concurrent.TimeoutException: null
另一个有趣的日志,我发现:
{"level":"INFO" [...] current list of Servers=[ip_address1:port, ip_address2:port, ip_address3:port],Load balancer stats=Zone stats: {defaultzone=[Zone:[ ... ]; Instance count:3; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:ip_address1:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ]
, [Server:ip_address2:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ]
, [Server:ip_address3:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ]
你得到了什么确切的例外? –
我编辑原始文章的一些更多的信息 –