Removes hystrix and ribbon references
This commit is contained in:
@@ -565,112 +565,6 @@ This removes duplicate values of `Access-Control-Allow-Credentials` and `Access-
|
||||
The `DedupeResponseHeader` filter also accepts an optional `strategy` parameter.
|
||||
The accepted values are `RETAIN_FIRST` (default), `RETAIN_LAST`, and `RETAIN_UNIQUE`.
|
||||
|
||||
[[hystrix]]
|
||||
=== The Hystrix `GatewayFilter` Factory
|
||||
|
||||
NOTE: https://cloud.spring.io/spring-cloud-netflix/multi/multi__modules_in_maintenance_mode.html[Netflix has put Hystrix in maintenance mode]. We suggest you use the <<spring-cloud-circuitbreaker-filter-factory, Spring Cloud CircuitBreaker
|
||||
Gateway Filter>> with Resilience4J, as support for Hystrix will be removed in a future release.
|
||||
|
||||
|
||||
https://github.com/Netflix/Hystrix[Hystrix] is a library from Netflix that implements the https://martinfowler.com/bliki/CircuitBreaker.html[circuit breaker pattern].
|
||||
The Hystrix `GatewayFilter` lets you introduce circuit breakers to your gateway routes, protecting your services from cascading failures and letting you provide fallback responses in the event of downstream failures.
|
||||
|
||||
To enable Hystrix `GatewayFilter` instances in your project, add a dependency on `spring-cloud-starter-netflix-hystrix` from https://cloud.spring.io/spring-cloud-netflix/[Spring Cloud Netflix].
|
||||
|
||||
The Hystrix `GatewayFilter` factory requires a single `name` parameter, which is the name of the `HystrixCommand`.
|
||||
The following example configures a Hystrix `GatewayFilter`:
|
||||
|
||||
.application.yml
|
||||
====
|
||||
[source,yaml]
|
||||
----
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: hystrix_route
|
||||
uri: https://example.org
|
||||
filters:
|
||||
- Hystrix=myCommandName
|
||||
----
|
||||
====
|
||||
|
||||
This wraps the remaining filters in a `HystrixCommand` with a command name of `myCommandName`.
|
||||
|
||||
The Hystrix filter can also accept an optional `fallbackUri` parameter. Currently, only `forward:` schemed URIs are supported. If the fallback is called, the request is forwarded to the controller matched by the URI.
|
||||
The following example configures such a fallback:
|
||||
|
||||
.application.yml
|
||||
====
|
||||
[source,yaml]
|
||||
----
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: hystrix_route
|
||||
uri: lb://backing-service:8088
|
||||
predicates:
|
||||
- Path=/consumingserviceendpoint
|
||||
filters:
|
||||
- name: Hystrix
|
||||
args:
|
||||
name: fallbackcmd
|
||||
fallbackUri: forward:/incaseoffailureusethis
|
||||
- RewritePath=/consumingserviceendpoint, /backingserviceendpoint
|
||||
----
|
||||
====
|
||||
|
||||
This will forward to the `/incaseoffailureusethis` URI when the Hystrix fallback is called. Note that this example also demonstrates (optional) Spring Cloud Netflix Ribbon load-balancing (defined the `lb` prefix on the destination URI).
|
||||
|
||||
The primary scenario is to use the `fallbackUri` to an internal controller or handler within the gateway app.
|
||||
However, you can also reroute the request to a controller or handler in an external application, as follows:
|
||||
|
||||
.application.yml
|
||||
====
|
||||
[source,yaml]
|
||||
----
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: ingredients
|
||||
uri: lb://ingredients
|
||||
predicates:
|
||||
- Path=//ingredients/**
|
||||
filters:
|
||||
- name: Hystrix
|
||||
args:
|
||||
name: fetchIngredients
|
||||
fallbackUri: forward:/fallback
|
||||
- id: ingredients-fallback
|
||||
uri: http://localhost:9994
|
||||
predicates:
|
||||
- Path=/fallback
|
||||
----
|
||||
====
|
||||
|
||||
In this example, there is no `fallback` endpoint or handler in the gateway application.
|
||||
However, there is one in another application, registered under `http://localhost:9994`.
|
||||
|
||||
In case of the request being forwarded to the fallback, the Hystrix Gateway filter also provides the `Throwable` that has caused it.
|
||||
It is added to the `ServerWebExchange` as the `ServerWebExchangeUtils.HYSTRIX_EXECUTION_EXCEPTION_ATTR` attribute, which you can use when handling the fallback within the gateway application.
|
||||
|
||||
For the external controller/handler scenario, you can add headers with exception details.
|
||||
You can find more information on doing so in the <<fallback-headers, FallbackHeaders GatewayFilter Factory section>>.
|
||||
|
||||
You can configured Hystrix settings (such as timeouts) with global defaults or on a route-by-route basis by using application properties, as explained on the https://github.com/Netflix/Hystrix/wiki/Configuration[Hystrix wiki].
|
||||
|
||||
To set a five-second timeout for the example route shown earlier, you could use the following configuration:
|
||||
|
||||
.application.yml
|
||||
====
|
||||
[source,yaml]
|
||||
----
|
||||
hystrix.command.fallbackcmd.execution.isolation.thread.timeoutInMilliseconds: 5000
|
||||
----
|
||||
====
|
||||
|
||||
[[spring-cloud-circuitbreaker-filter-factory]]
|
||||
=== Spring Cloud CircuitBreaker GatewayFilter Factory
|
||||
|
||||
|
||||
@@ -135,44 +135,6 @@ spring:
|
||||
predicates:
|
||||
- Host=**.hostmulti1.org,**.hostmulti2.org
|
||||
|
||||
# =====================================
|
||||
- id: hystrix_failure_test
|
||||
uri: ${test.uri}
|
||||
predicates:
|
||||
- Host=**.hystrixfailure.org
|
||||
filters:
|
||||
- Hystrix=failcmd
|
||||
|
||||
# =====================================
|
||||
- id: hystrix_fallback_test
|
||||
uri: ${test.uri}
|
||||
predicates:
|
||||
- Host=**.hystrixfallback.org
|
||||
filters:
|
||||
- name: Hystrix
|
||||
args:
|
||||
name: fallbackcmd
|
||||
fallbackUri: forward:/fallbackcontroller
|
||||
|
||||
# =====================================
|
||||
- id: hystrix_exception_fallback_test
|
||||
uri: ${test.uri}
|
||||
predicates:
|
||||
- Host=**.hystrixexceptionfallback.org
|
||||
filters:
|
||||
- name: Hystrix
|
||||
args:
|
||||
name: fallbackcmd
|
||||
fallbackUri: forward:/exceptionFallback
|
||||
|
||||
# =====================================
|
||||
- id: hystrix_success_test
|
||||
uri: ${test.uri}
|
||||
predicates:
|
||||
- Host=**.hystrixsuccess.org
|
||||
filters:
|
||||
- Hystrix=successcmd
|
||||
|
||||
# =====================================
|
||||
- id: sccb_success_test
|
||||
uri: ${test.uri}
|
||||
|
||||
Reference in New Issue
Block a user