Adding spring cloud circuitbreaker hystrix implementation
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
=== Configuring Hystrix Circuit Breakers
|
||||
|
||||
==== Default Configuration
|
||||
|
||||
To provide a default configuration for all of your circuit breakers create a `Customize` bean that is passed a
|
||||
`HystrixCircuitBreakerFactory` or `ReactiveHystrixCircuitBreakerFactory`.
|
||||
The `configureDefault` method can be used to provide a default configuration.
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<HystrixCircuitBreakerFactory> defaultConfig() {
|
||||
return factory -> factory.configureDefault(id -> HystrixCommand.Setter
|
||||
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(id))
|
||||
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
|
||||
.withExecutionTimeoutInMilliseconds(4000)));
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
===== Reactive Example
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<ReactiveHystrixCircuitBreakerFactory> defaultConfig() {
|
||||
return factory -> factory.configureDefault(id -> HystrixObservableCommand.Setter
|
||||
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(id))
|
||||
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
|
||||
.withExecutionTimeoutInMilliseconds(4000)));
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
==== Specific Circuit Breaker Configuration
|
||||
|
||||
Similarly to providing a default configuration, you can create a `Customize` bean this is passed a
|
||||
`HystrixCircuitBreakerFactory`
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<HystrixCircuitBreakerFactory> customizer() {
|
||||
return factory -> factory.configure(builder -> builder.commandProperties(
|
||||
HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(2000)), "foo", "bar");
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
===== Reactive Example
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<ReactiveHystrixCircuitBreakerFactory> customizer() {
|
||||
return factory -> factory.configure(builder -> builder.commandProperties(
|
||||
HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(2000)), "foo", "bar");
|
||||
}
|
||||
----
|
||||
====
|
||||
@@ -554,6 +554,10 @@ when running a Eureka server you must include these dependencies in your POM or
|
||||
</dependency>
|
||||
----
|
||||
|
||||
== Circuit Breaker: Spring Cloud Circuit Breaker With Hystrix
|
||||
|
||||
include::spring-cloud-circuitbreaker-hystrix.adoc[]
|
||||
|
||||
== Circuit Breaker: Hystrix Clients
|
||||
|
||||
Netflix has created a library called https://github.com/Netflix/Hystrix[Hystrix] that implements the https://martinfowler.com/bliki/CircuitBreaker.html[circuit breaker pattern].
|
||||
|
||||
Reference in New Issue
Block a user