2015-07-03 145 views
9

我遇到了同樣的問題,我嘗試覆蓋application.yaml中的hystrix屬性。當我運行應用程序&檢查屬性localhost:端口/應用程序上下文/ hystrix.stream,我得到所有的默認值,而不是。在Spring-Boot應用程序中使用application.yaml配置hystrix命令屬性

這裏是我的application.yaml紅椎配置

hystrix: 
    command.StoreSubmission.execution.isolation.thread.timeoutInMilliseconds: 30000 
    command.StoreSubmission.circuitBreaker.requestVolumeThreshold: 4 
    command.StoreSubmission.circuitBreaker.sleepWindowInMilliseconds: 60000 
    command.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000 
    collapser.StoreSubmission.maxRequestsInBatch: 1 
    collapser.StoreSubmission.requestCache.enabled: FALSE 
    threadpool.StoreSubmission.coreSize: 30 
    threadpool.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000 

這是我看到的時候我打的網址 - 本地主機:端口/應用程序上下文中的瀏覽器/ hystrix.stream [這是相同的流用於錐儀表板]的url -

data: {"type":"HystrixCommand","name":"storeSubmission","group":"StoreSubmission","currentTime":1435941064801,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1} 

data: {"type":"HystrixThreadPool","name":"StoreSubmission","currentTime":1435941064801,"currentActiveCount":0,"currentCompletedTaskCount":35,"currentCorePoolSize":30,"currentLargestPoolSize":30,"currentMaximumPoolSize":30,"currentPoolSize":30,"currentQueueSize":0,"currentTaskCount":35,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":180000,"reportingHosts":1} 

問題是與錐命令&崩塌性質,其中作爲線程池屬性設置是否正確。我有以下我@Configuration類註釋 -

@EnableAutoConfiguration(exclude=MongoAutoConfiguration.class) 
@EnableHystrix 
@EnableHystrixDashboard 

曾有人試圖在thier春啓動應用程序使用application.yaml配置椎命令屬性,可以幫助嗎?

+0

我在看這個,並注意來自HystrixCommand數據的名字是小寫,你的配置是大寫。 – spencergibb

+0

我將你的值粘貼到我的'application.yml'中,並且這些值已經通過。 – spencergibb

+0

@spencergibb:1.通過HystrixCommand數據傳入的名稱是由HystrixCommand包裝的方法名稱。 2.在配置其groupKey值時,實際上應該是commandKey值。 3.當你說這些值出現時,在哪裏? – Amrut

回答

16

主要問題是,我使用groupKey值而不是commandKey值來定義屬性。這些configurtion性能的wiki頁面 - https://github.com/Netflix/Hystrix/wiki/Configuration#intro說 -

hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds 

替換您command鍵設置的值的屬性的HystrixCommandKey部分。

hystrix.threadpool.HystrixThreadPoolKey.coreSize 

將屬性的HystrixThreadPoolKey部分替換爲您爲threadPoolKey設置的值。

這是我如何定義這兩個command鍵& threadPoolKey在由HystrixCommand包裹方法 -

@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission") 
public String storeSubmission(ReturnType returnType, InputStream is, String id) { 
} 

實際上,你可以同時定義commnad內@HystixCommand標註的方法&線程池的屬性。

@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission", commandProperties = { 
     @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000"), 
     @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "4"), 
     @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "60000"), 
     @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") }, threadPoolProperties = { 
     @HystrixProperty(name = "coreSize", value = "30"), 
     @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") }) 
public String storeSubmission(ReturnType returnType, InputStream is, String id) { 
} 

我猜來定義這些屬性的最佳方法是外化application.yaml,這樣你可以控制它更好&改變他們對不同的環境。

+0

你知道我該如何驗證這些屬性是否被用來配置HystrixCommand?有沒有記錄他們?是否可以啓用Hystrix的DEBUG級別日誌記錄? – pijushcse

相關問題