2017-01-13 6 views
0

Ich habe den Frühling Aspekt für hystrixcommand konfiguriert und es funktioniert gut (Open und Close-Schaltung)hystrix Kreis offen Ereignis

Während meiner Tests, was ich beobachtet, dass, wenn die Schaltung offen ist, wird der normale Fluss noch aufgerufen und bei dem Ereignis FAILURE wird der Fall zurückgerufen.

Was ich aus der Dokumentation zu verstehen ist, dass, wenn die Schaltung geöffnet ist, wird der normale Fluss nur einmal in fünf Sekunden (Standard) überprüft werden. Ich habe versucht, manuell den Wert auf 20 Sekunden, aber immer noch nicht funktioniert

@HystrixCommand(commandProperties = { 
      @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "20000") 
     }, 
      fallbackMethod = "fallbackCall") 

Wo stelle ich diese Konfiguration? Ich möchte nicht, dass der Fehlerdienst jedes Mal aufgerufen wird, und gehe dann zum Fallback.

Antwort

1

Der Test war ich falsche Konfiguration zu tun hatte. Um SHORT_CIRCUIT zu erreichen, sollte circuitBreaker.requestVolumeThreshold erfüllt sein.

Der Wert war Standard-20 und die Anzahl der Ausfälle im Rollfenster wurde nicht mehr als 20 in meinem Fall. Es ist also nie ein Kurzschluss passiert. Im Folgenden finden Sie die Dokumentation ich von einem anderen Stapel über Fluss Antwort bekam

within a timespan of duration metrics.rollingStats.timeInMilliseconds, the percentage of actions resulting in a handled exception exceeds errorThresholdPercentage, provided also that the number of actions through the circuit in the timespan is at least requestVolumeThreshold 

Ich habe circuitBreaker.requestVolumeThreshold 1 und es funktioniert wie erwartet.