如何解决包含/排除骆驼弹性中的异常4J
在骆驼路线(spring-boot应用程序)中使用resilience4J库实现断路器模式时,如何在分析中包括/排除异常。
我们正在使用以下官方库,但是它没有公开任何API来排除普通Java库之类的例外。
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-resilience4j-starter</artifactId>
<version>${camel.version}</version>
</dependency>
,但是官方文档说有API可以处理以下情况: https://resilience4j.readme.io/docs/circuitbreaker
// Create a custom configuration for a CircuitBreaker
CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom()
.failureRateThreshold(50)
.slowCallRateThreshold(50)
.waitDurationInOpenState(Duration.ofMillis(1000))
.slowCallDurationThreshold(Duration.ofSeconds(2))
.permittedNumberOfCallsInHalfOpenState(3)
.minimumNumberOfCalls(10)
.slidingWindowType(SlidingWindowType.TIME_BASED)
.slidingWindowSize(5)
.recordException(e -> INTERNAL_SERVER_ERROR
.equals(getResponse().getStatus()))
.recordExceptions(IOException.class,TimeoutException.class)
.ignoreExceptions(BusinessException.class,OtherBusinessException.class)
.build();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。