...
Below is an example route showing an Hystrix endpoint that protects against slow operation by falling back to the in-lined fallback route. By default the timeout request is just 1000ms
so the HTTP endpoint has to be fairly quick to succeed.
Code Block | ||
---|---|---|
| ||
from("direct:start") .hystrix() .to("http://fooservice.com/slow") .onFallback() .transform().constant("Fallback message") .end() .to("mock:result"); |
...
Hystrix has many options as listed in the table above. For example to set a higher timeout to 5
seconds, and also let the circuit breaker wait 10
seconds before attempting a request again when the state was tripped to be open.
Code Block | ||
---|---|---|
| ||
from("direct:start") .hystrix() .hystrixConfiguration() .executionTimeoutInMilliseconds(5000).circuitBreakerSleepWindowInMilliseconds(10000) .end() .to("http://fooservice.com/slow") .onFallback() .transform().constant("Fallback message") .end() .to("mock:result"); |
...