首页 > 解决方案 > 如果缺少任何依赖项,Apache Camel 会静默失败

问题描述

我正在使用 DSL 来构建异步队列处理器。

路线的代码如下所示:

from("seda://exportListQueue")
                .setProperty("originalRequest", simple("${body}"))
                .setHeader("CamelRedis.Key", Builder.simple("Something"))
                .setHeader("CamelRedis.Value", Builder.simple("Some Json"))
                .to("spring-redis://the_host:the_port?serializer=#stringSerializer")                .setBody(exchangeProperty("originalRequest").convertTo(MyClass::class.java))
                .process(queueProcessor)
                .to("http4:some_url)

(这是 kotlin 顺便说一句,但这真的没关系)

当然,我已经更改了名称,因为我不能公开非通用部分。我的问题是,当我尝试运行应用程序时,Camel 立即停止。日志是这样的:

[INFO ] [2019-04-01 18:57:46,089] [] [] [o.a.c.l.i.Jdk14Logger->log:87] | Detected @ExceptionHandler methods in exceptionHandlerController
[INFO ] [2019-04-01 18:57:46,995] [] [] [o.a.c.l.i.Jdk14Logger->log:87] | Registering beans for JMX exposure on startup
[INFO ] [2019-04-01 18:57:46,998] [] [] [o.a.c.l.i.Jdk14Logger->log:87] | Bean with name 'dataSource' has been autodetected for JMX exposure
[INFO ] [2019-04-01 18:57:47,010] [] [] [o.a.c.l.i.Jdk14Logger->log:87] | Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
[INFO ] [2019-04-01 18:57:47,079] [] [] [o.a.c.s.b.RoutesCollector->loadXmlRoutes:279] | Loading additional Camel XML routes from: classpath:camel/*.xml
[INFO ] [2019-04-01 18:57:47,080] [] [] [o.a.c.s.b.RoutesCollector->loadXmlRests:296] | Loading additional Camel XML rests from: classpath:camel-rest/*.xml
[INFO ] [2019-04-01 18:57:47,084] [] [] [o.a.c.i.DefaultCamelContext->start:3138] | Apache Camel 2.23.1 (CamelContext: RED) is starting
[INFO ] [2019-04-01 18:57:47,085] [] [] [o.a.c.i.DefaultCamelContext->doStartCamel:3312] | MDC logging is enabled on CamelContext: RED
[INFO ] [2019-04-01 18:57:47,085] [] [] [o.a.c.m.ManagedManagementStrategy->doStart:205] | JMX is enabled
[INFO ] [2019-04-01 18:57:47,249] [] [] [o.a.c.i.DefaultCamelContext->doStop:3496] | Apache Camel 2.23.1 (CamelContext: RED) is shutting down
[INFO ] [2019-04-01 18:57:47,256] [] [] [o.a.c.i.DefaultCamelContext->doStop:3596] | Apache Camel 2.23.1 (CamelContext: RED) uptime 0.171 seconds
[INFO ] [2019-04-01 18:57:47,256] [] [] [o.a.c.i.DefaultCamelContext->doStop:3597] | Apache Camel 2.23.1 (CamelContext: RED) is shutdown in 0.007 seconds

使用跟踪级别进行日志记录,我们找到了问题的根源:

[TRACE] [2019-04-01 19:01:06,419] [] [] [o.a.c.u.EventHelper->doNotifyEvent:1091] | Notifier: org.apache.camel.spring.boot.RoutesCollector$2@7dd847a2 is not enabled for the event: Failed to start Camel: RED due to Failed to create route route1 at: >>> To[spring-redis://the_port:the_host?serializer=#stringSerializer] <<< in route: Route(route1)[[From[seda://exporQueue]] -> [SetProperty... because of Failed to resolve endpoint: spring-redis://the_host:the_port?serializer=%23stringSerializer due to: No component found with scheme: spring-redis

最后,它只是一个缺失的依赖项。但我的问题是,骆驼不应该给我一个例外或至少一个警告,告诉我为什么它会以更友好的方式关闭。

我是否遗漏了什么,或者这真的是一种不漂亮的骆驼行为,值得一张票?

- - 编辑 - -

这是与启动相关的依赖项

dependencies {

    // spring web
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-jetty")

    // cache
    compile("org.springframework.boot:spring-boot-starter-cache")

    // spring retry
    compile("org.springframework.retry:spring-retry:1.1.5.RELEASE")

    // monitoring
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-logging")

    // camel
    compile('org.apache.camel:camel-spring-boot-starter:2.23.1')
    compile('org.apache.camel:camel-spring-redis:2.23.1')
    compile('org.apache.camel:camel-http4:2.23.1')

    // eaio uuid
    compile("com.eaio.uuid:uuid:3.2")

    // apache
    compile("org.apache.commons:commons-lang3:3.7")
    compile("commons-codec:commons-codec:1.11")
    compile("org.apache.httpcomponents:httpclient:4.5.3")

}

标签: apache-camelspring-camel

解决方案


推荐阅读