无法在 Spring Boot 应用程序中使用 Apache Camel Circit Breaker

问题描述 投票:0回答:1

我正在尝试在我的 Spring Boot 应用程序中实现 Apache Camel 的 CircuitBreaker,如下所示。在此之前,我也尝试过几种方法,但由于库不兼容和Camel上下文问题(作为Spring Boot自动配置上下文,一些配置冲突),我都无法工作。

我还添加了必要的存储库(我使用 Java 17):

implementation("org.apache.camel:camel-resilience4j:3.21.0")

@Component
class ImportJiraWorklogsRoute(
    errorProperties: ErrorProperties,
    counters: Map<String, Counter>
) : ErrorRouteBuilder(errorProperties, counters) {

    override fun configure() {
        
        from("direct:employees")
            // .routeId(ROUTE_GET_UPDATED_WORKLOGS)
            .circuitBreaker()
                .resilience4jConfiguration()
                    .timeoutEnabled(true)
                    .timeoutDuration(500)
            .end()

            .process(EmployeeProcessor)
            .process { counters.getValue(EMPLOYEE).increment() }
            .onFallback()
                .transform().constant("Fallback response: Service Unavailable")
            .log("Route completed successfully.")
    }
}

那么,这是一个通用类路径问题还是与 Apache Camel 有关?我尝试重建应用程序并刷新 Gardle 依赖项,但仍然不起作用(如果我从此方法中删除与断路器相关的行,它就可以工作)。

java spring-boot kotlin exception apache-camel
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.