为什么ActiveMQ 5.14.x无法启动嵌入camel-jms组件2.18.3

时间:2017-04-21 22:04:39

标签: apache-camel jms activemq

以下是用于演示问题的简单弹簧启动项目(版本1.5.2):

https://github.com/lanwen/camel-jms-activemq-test

Apache Camel 版本 2.18.3

在分支master上,由于activemq-camel=5.14.4camel-jms=2.16.3(可以从中传递),所有工作都正常。

Spring启动应用程序通常使用log:

启动
2017-04-22 00:53:19.647  INFO 97217 --- [           main] o.a.camel.spring.SpringCamelContext      : Apache Camel 2.18.3 (CamelContext: camel-1) is starting
2017-04-22 00:53:19.662  INFO 97173 --- [           main] o.apache.activemq.broker.BrokerService   : Apache ActiveMQ 5.14.4 (localhost, ID:lanwen-osx3.local-62145-1492811599544-0:1) is starting
2017-04-22 00:53:19.665  INFO 97173 --- [           main] o.apache.activemq.broker.BrokerService   : Apache ActiveMQ 5.14.4 (localhost, ID:lanwen-osx3.local-62145-1492811599544-0:1) started
2017-04-22 00:53:19.665  INFO 97173 --- [           main] o.apache.activemq.broker.BrokerService   : For help or more information please see: http://activemq.apache.org
2017-04-22 00:53:19.682  INFO 97173 --- [           main] o.a.activemq.broker.TransportConnector   : Connector vm://localhost started
2017-04-22 00:53:19.702  INFO 97173 --- [           main] o.a.camel.spring.SpringCamelContext      : Route: route1 started and consuming from: activemq://queue:to-write?asyncConsumer=true
2017-04-22 00:53:19.703  INFO 97173 --- [           main] o.a.camel.spring.SpringCamelContext      : Total 1 routes, of which 1 are started.
2017-04-22 00:53:19.704  INFO 97173 --- [           main] o.a.camel.spring.SpringCamelContext      : Apache Camel 2.18.3 (CamelContext: camel-1) started in 0.466 seconds
2017-04-22 00:53:19.709  INFO 97173 --- [           main] ru.yandex.test.writer.MyTestApplication  : Started MyTestApplication in 2.437 seconds (JVM running for 2.911)

但是当你从camel-jms=2.18.3开始(作为驼峰的主要版本,在分支not_working上)

这个日志出了问题:

2017-04-22 00:56:38.070  INFO 97195 --- [           main] o.a.camel.spring.SpringCamelContext      : Apache Camel 2.18.3 (CamelContext: camel-1) is starting
...
2017-04-22 00:56:43.590  WARN 97195 --- [ActiveMQ Task-1] o.a.a.t.failover.FailoverTransport       : Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.

但如果我们使用activemq-camel5.13.4更改为camel-jms=2.18.3,它又可以正常工作......

为什么ActiveMQ 5.14.x 不适用于camel-jms 2.18.x

1 个答案:

答案 0 :(得分:2)

如果您查看最新Camel ActiveMQ 1.15.5https://mvnrepository.com/artifact/org.apache.activemq/activemq-camel/5.14.5)的依赖关系列表,您会发现它已经camel-jms作为依赖关系,但版本是1.16.3。因此,您无需在POM中单独添加camel-jms 1.18.x依赖项,因为它将覆盖ActiveMQ已使用的1.16.x版本,这是兼容的版本。

基本上,问题在于您尝试使用较新的,不兼容的camel-jms版本。当您单独添加1.18.x camel-jms依赖项时,ActiveMQ组件将使用此版本,该版本与其1.16.x版本不兼容,因此出现错误。

如果您需要使用ActiveMQ,那么您可能必须查看camel-jms 1.16.x是否适合您。