My project state:
- Java 17
- Spring Boot 3.2.0
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<exclusions>
<exclusion>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-hystrix</artifactId>
</exclusion>
</exclusions>
</dependency>
Client:
@FeignClient(
name = "serviceB",
url = "url"
configuration = [ServiceBClientFeignConfig::class]
)
interface PredictionBannerClient {
@Timed("prediction-banner", histogram = true, percentiles = [0.5, 0.8, 0.85, 0.90, 0.95, 0.99])
@CircuitBreaker(name = "serviceB-banner")
@PostMapping("/endpoint")
fun callApi(
@RequestBody request: ProtoRequest,
): List<ProtoResponse>
}
class ServiceBClientFeignConfig(
@Value("\${readTimeout}")
val readTimeout: Long,
@Value("\${connectTimeout}")
val connectTimeout: Long
) {
@Bean
fun feignOptions(): Request.Options {
return Request.Options(Duration.ofMillis(readTimeout), Duration.ofMillis(connectTimeout), true)
}
}
In Service A calling service B with FeignClient and circuitbreaker config like below:
resilience4j:
circuitbreaker:
metrics:
enabled: true
legacy:
enabled: true
configs:
default:
sliding-window-type: count_based
sliding-window-size: 60
automatic-transition-from-open-to-half-open-enabled: true
disable-config:
minimum-number-of-calls: 1000_000_000
sliding-window-type: time_based
sliding-window-size: 60
instances:
serviceB-video:
base-config: default
minimumNumberOfCalls: 100
failureRateThreshold: 35
waitDurationInOpenState: 60s
slowCallDurationThreshold: 250ms
slowCallRateThreshold: 35
permittedNumberOfCallsInHalfOpenState: 100
eventConsumerBufferSize: 10
serviceB-banner:
base-config: default
minimumNumberOfCalls: 1000
failureRateThreshold: 35
waitDurationInOpenState: 60s
slowCallDurationThreshold: 140ms
slowCallRateThreshold: 35
permittedNumberOfCallsInHalfOpenState: 100
eventConsumerBufferSize: 10
In my system everything is fine, when deploy it on kuber at first circuitBreaker opened and I get callNotPermitted exception and after a while getting below error:
ERROR| o.a.c.c.C.[.[.[.[dispatcherServlet] | Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed: java.lang.StackOverflowError] with root cause
java.lang.StackOverflowError: null
at java.base/java.time.Clock.currentInstant(Clock.java:498)
at java.base/java.time.Clock$SystemClock.instant(Clock.java:614)
at io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine$OpenState.tryAcquirePermission(CircuitBreakerStateMachine.java:733)
at io.github.resilience4j.circuitbreaker.internal.CircuitBreakerStateMachine$OpenState.tryAcquirePermission(CircuitBreakerStateMachine.java:737)
At first my Java version is 21, after reading doc, change Java version to 17.