2015-07-03 19 views
9

Ich habe dasselbe Problem, wo ich versuche, die Hystrix-Eigenschaften in application.yaml zu überschreiben. Wenn ich die App & ausführen, überprüfen Sie die Eigenschaften mit localhost: port/app-context/hystrix.stream, ich bekomme stattdessen alle Standardwerte.Konfigurieren von Hystrix-Befehlseigenschaften mit Application.yaml in Spring-Boot-Anwendung

hier ist die hystrix config in meinem 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 

Hier ist, was ich sehe, wenn ich die URL getroffen - localhost: port/app-Kontext/hystrix.stream in Browser [dies ist der gleiche Strom url für hystrix Armaturenbrett verwendet] -

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} 

Das Problem ist mit hystrix Befehl & Collapser Eigenschaften, wo als thread~~POS=TRUNC Eigenschaften richtig eingestellt sind. Ich habe in meiner @configuration Klasse folgende Anmerkungen bekommt -

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

Hat jemand versucht hystrix Befehl Eigenschaften mit Hilfe application.yaml in thier Frühlings-Boot-Anwendung konfigurieren, kann helfen, bitte?

+0

Ich schaue mir das an und beachte, dass der Name, der aus den HystrixCommand-Daten kommt, klein geschrieben ist und Ihre Konfiguration in Großbuchstaben geschrieben ist. – spencergibb

+0

Ich habe Ihre Werte in meine 'application.yml' eingefügt und diese Werte kamen durch. – spencergibb

+0

@spencergibb: 1. Der in HystrixCommand-Daten durchkommende Name ist der Methodenname, der von HystrixCommand umschlossen wurde. 2. In der Konfiguration sollte der groupKey-Wert actully this commandKey-Wert sein. 3. Wenn Sie sagen, diese Werte kommen, wo? – Amrut

Antwort

16

Das Hauptproblem war, dass ich groupKey-Wert anstelle von commandKey-Wert verwendete, um die Eigenschaften zu definieren. Die Wiki-Seite für diese configurtion Eigenschaften - https://github.com/Netflix/Hystrix/wiki/Configuration#intro sagt -

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

Ersetzen Sie den HystrixCommandKey Teil der Eigenschaft mit dem Wert, den Sie für commandKey eingestellt.

hystrix.threadpool.HystrixThreadPoolKey.coreSize 

Ersetzen Sie den HystrixThreadPoolKey Teil der Eigenschaft mit dem Wert, den Sie für threadPoolKey eingestellt.

Hier ist, wie ich beide commandKey & threadPoolKey über die von HystrixCommand gewickelten Methode definieren -

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

Sie können sowohl & Thread Eigenschaften auf der Methode innerhalb @HystixCommand Anmerkung tatsächlich definieren commnad.

@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) { 
} 

Ich denke, der beste Weg, diese Eigenschaften ist in externalisierte application.yaml zu definieren, dass die Art und Weise Sie es besser kontrollieren können & sie für verschiedene Umgebungen verändern.

+0

Wissen Sie, wie ich überprüfen kann, ob diese Eigenschaften zur Konfiguration von HystrixCommand verwendet werden? Gibt es sie trotzdem? Ist es möglich, die DEBUG-Level-Protokollierung für Hystrix zu aktivieren? – pijushcse