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

lan*_*wen 14 activemq-classic jms apache-camel

以下是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启动应用程序正常启动日志:

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)
Run Code Online (Sandbox Code Playgroud)

但是当你开始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.
Run Code Online (Sandbox Code Playgroud)

但是,如果我们换activemq-camel5.13.4camel-jms=2.18.3它工作再次罚款...

为什么ActiveMQ 5.14.x不能与camel-jms 2.18.x一起使用

Kha*_*led 2

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

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

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