我尝试在我的 spring 云网关中配置 Resilience4j,但没有成功。我找到的所有内容都是针对 Hystrix 或纯 Java 的。
我已将网关配置为在我的服务上传输请求,没关系。
但是不可能在上面配置resilience4j。我有一个很好的 R4J 响应式神器。
Spring Cloud API和网关中Resilience4j的配置不同?
查看我的配置文件。
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: helloworld_service
uri: "https://localhost:8080"
predicates:
- Path=/helloworld/**
filters:
- RewritePath=/helloworld/(?<segment>.*), /$\{segment}
- name: CircuitBreaker
args:
name: helloworld
httpclient:
ssl:
useInsecureTrustManager: true
# RESILIENCE4J PROPERTIES
resilience4j:
circuitbreaker:
configs:
default:
#registerHealthIndicator: true
ringBufferSizeInClosedState: 10
ringBufferSizeInHalfOpenState: 3
automaticTransitionFromOpenToHalfOpenEnabled: true
waitDurationInOpenStateMillis: 2000
failureRateThreshold: 50
eventConsumerBufferSize: 10
instances:
helloworld:
baseConfig: default
ringBufferSizeInClosedState: 5
我的依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-reactor-resilience4j</artifactId>
</dependency>
并产生错误:
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
Caused by: java.lang.IllegalArgumentException: Unable to find GatewayFilterFactory with name CircuitBreaker
非常感谢您的帮助。