5

मैंने यूरेका में पंजीकृत एक आरईएसटी सेवा को कॉल करने के लिए एक साधारण स्प्रिंग क्लाउड रिबन एप्लिकेशन लिखा था।स्प्रिंग क्लाउड रिबन में ribbon.serverListRefreshInterval डिफ़ॉल्ट मान को ओवरराइड कैसे करें?

लेकिन ribbon.serverListRefreshInterval मूल्य को ओवरराइड कैसे करें? डिफ़ॉल्ट मान 30 सेकंड है, मैं समय अंतराल को कम करना चाहता हूं।

अग्रिम धन्यवाद।

उत्तर

3

साथ प्रयास करें:

myService.ribbon.ServerListRefreshInterval=10000 

जहां myService अपने गंतव्य microservice का नाम है।

अद्यतन:

कुछ स्रोत कोड खुदाई मुझे पता चला उसके बाद LoadBalancerBuilder कॉल:

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

जिसका सुपर है:

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

सूचना PollingServerListUpdater कंस्ट्रक्टर्स:

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)); 
} 

दूसरा वाला हमें डिफ़ॉल्ट रीफ्रेश अंतराल को ओवरराइड करने की अनुमति देगा। हालांकि यह पहला ऐसा है जिसे बुलाया जाता है, इसलिए यह संपत्ति को अनदेखा करता है।

अद्यतन 2:

इस बारे में एक खुला मुद्दा है: https://github.com/spring-cloud/spring-cloud-netflix/issues/1304

+0

आपकी सेवा आपके यूरेका सर्वर में 'कंप्यूट-सेवा' के रूप में बिल्कुल पंजीकृत है? पूंजी अक्षरों को ध्यान में रखें। – codependent

+0

निश्चित रूप से, दो बार जांच की गई है कि कोई टाइपो त्रुटि नहीं है, बाद में आपके संदर्भ के लिए कुछ स्क्रीन शॉट्स संलग्न करेगा –

+0

आपके मूल्यवान उत्तर के लिए धन्यवाद, उम्मीद है कि बग ASAP को ठीक किया जा सकता है –

2

@codependent

application.yml में विन्यास नीचे डाल के बाद, यह विन्यास देखा फ्लॉप प्रभावी होते हैं।

Compute-Service: 
    ribbon: 
    ServerListRefreshInterval: 1000 

मैंने देखा कि उदाहरणों सूची (eureka.client.registry-फ़ेच अंतराल सेकंड पैरामीटर के माध्यम से) रिबन पक्ष में अद्यतन किया गया है, फिर भी रिबन अभी भी एक मृत उदाहरण का कहना है:

[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 

1 9 2.168.1.101: कॉम्प्यूट- सेवा 1111 सही सेवा उदाहरण था, जबकि 1 9 2.168.1.101: कॉम्प्यूट- सेवा 2222 मृत घटना थी, जाहिर है रिबन ने अभी भी मृत उदाहरण की ओर इशारा किया था, जिसका अर्थ है रिबन सर्वरलिस्ट कैश को ताज़ा नहीं किया गया था।

संबंधित मुद्दे