resilience4j重试改型

3z6pesqy  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(224)

有没有一种方法可以像circuitbreacker那样添加重试配置?

val circuitBreakerConfig = CircuitBreakerConfig.custom()
        .slidingWindowType(CircuitBreakerConfig.SlidingWindowType.COUNT_BASED)
        .failureRateThreshold(10.0F)
        .build()

    val circuitBreaker = CircuitBreaker.of("name", circuitBreakerConfig)

    val retrofit = Retrofit.Builder()
        .baseUrl(baseUrl)
        .addCallAdapterFactory(
            CircuitBreakerCallAdapter.of(circuitBreaker) {
                it.code() == 500
            }
        ).addConverterFactory(GsonConverterFactory.create())
        .client(httpClient)
        .build()

我想使用的重试配置如下:

val retryConfig = RetryConfig.custom<Any>()
        .maxAttempts(3)
        .waitDuration(Duration.ofSeconds(120))
        .retryExceptions(RuntimeException::class.java)
        .build()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题