Trả lời

3

Hãy thử với:

myService.ribbon.ServerListRefreshInterval=10000 

nơi myService là tên của microservice điểm đến của bạn.

CẬP NHẬT:

Sau khi một số mã nguồn đào tôi phát hiện ra rằng LoadBalancerBuilder cuộc gọi:

@Deprecated 
public ZoneAwareLoadBalancer(IClientConfig clientConfig, IRule rule, 
     IPing ping, ServerList<T> serverList, ServerListFilter<T> filter) { 
    super(clientConfig, rule, ping, serverList, filter); 
} 

mà siêu là:

@Deprecated 
public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping, 
     ServerList<T> serverList, ServerListFilter<T> filter) { 
    this(
      clientConfig, 
      rule, 
      ping, 
      serverList, 
      filter, 
      new PollingServerListUpdater() 
    ); 
} 

Thông báo các PollingServerListUpdater constructors:

private static int LISTOFSERVERS_CACHE_REPEAT_INTERVAL = 30 * 1000; // msecs; 

public PollingServerListUpdater() { 
    this(LISTOFSERVERS_CACHE_UPDATE_DELAY, LISTOFSERVERS_CACHE_REPEAT_INTERVAL); 
} 

public PollingServerListUpdater(IClientConfig clientConfig) { 
    this(LISTOFSERVERS_CACHE_UPDATE_DELAY, getRefreshIntervalMs(clientConfig)); 
} 

Điều thứ hai sẽ cho phép chúng tôi ghi đè khoảng thời gian làm mới mặc định. Tuy nhiên nó là cái đầu tiên được gọi, vì vậy nó bỏ qua de property.

UPDATE 2:

Có một vấn đề mở về vấn đề này: https://github.com/spring-cloud/spring-cloud-netflix/issues/1304

+0

dịch vụ của bạn có được đăng ký chính xác như 'Dịch vụ tính toán' trong máy chủ Eureka của bạn không? Tâm trí các chữ cái vốn. – codependent

+0

Chắc chắn, hãy kiểm tra kỹ lưỡng rằng không có lỗi đánh máy, sẽ đính kèm một số ảnh chụp màn hình để bạn tham khảo sau –

+0

Cảm ơn câu trả lời có giá trị của bạn, hy vọng lỗi có thể được khắc phục ASAP –

2

@codependent

Sau khi đặt bên dưới cấu hình trong application.yml, nó trông cấu hình didnt có hiệu lực.

Compute-Service: 
    ribbon: 
    ServerListRefreshInterval: 1000 

tôi quan sát thấy rằng danh sách các trường hợp đã được cập nhật ở bên Ribbon (thông qua tham số eureka.client.registry nạp-khoảng-giây), tuy nhiên Ribbon vẫn chỉ ra một trường hợp chết:

[tbeatExecutor-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_RIBBON-CONSUMER/192.168.1.101:Ribbon-Consumer:3333 - Heartbeat status: 200 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : Got delta update with apps hashcode UP_2_ 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : Added instance 192.168.1.101:Ribbon-Consumer:3333 to the existing apps in region null 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : Deleted instance 192.168.1.101:Compute-Service:2222 to the existing apps 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : Added instance 192.168.1.101:Compute-Service:1111 to the existing apps in region null 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : The total number of instances fetched by the delta processor : 3 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : The total number of all instances in the client now is 2 
[freshExecutor-0] com.netflix.discovery.DiscoveryClient : Completed cache refresh task for discovery. All Apps hash code is Local region apps hashcode: UP_2_, is fetching remote regions? false 
[nio-3333-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://Compute-Service/add": Connection refused; nested exception is java.net.ConnectException: Connection refused] with root cause 

192.168.1.101:Compute-Service:1111 là cá thể dịch vụ phù hợp, trong khi 192.168.1.101:Compute-Service:2222 là trường hợp chết, rõ ràng Ribbon vẫn trỏ đến cá thể chết, có nghĩa là bộ nhớ đệm của Máy chủ Ribbon không được làm mới.

Các vấn đề liên quan