【发布时间】:2016-03-25 11:20:50
【问题描述】:
我有一个在 tomcat 上运行的 web 应用程序,声明为 activemq 消费者。应用程序工作正常,但现在我想在运行时启动消费者 - 所以我声明了控制总线并向其发送消息。
有一段我的代码:
<channel id="controlChannel"/>
<control-bus input-channel="controlChannel"/>
<gateway service-interface="myApp.ControlGateway" default-request-channel="controlChannel"/>
<channel id="eventQueueChannel"/>
<jms:message-driven-channel-adapter
id="eventQueueJMSIn"
connection-factory="connectionFactory"
destination="eventQueue"
channel="eventQueueChannel"
auto-startup="false"
acknowledge="transacted"
concurrent-consumers="${concurrentConsumers:1}"
max-concurrent-consumers="${maxConcurrentConsumers:10}"/>
然后我通过controlBusGateway.sendCommand("@eventQueueJMSIn.start()");启动这个网关。
问题是消费者无法连接到activemq。而且发布者也有问题。
总之,当一切自动启动时,没有问题。当我将消费者网关更改为auto-startup="false" 时,我无法发送或接收来自activemq 的任何消息。但是当我测试这个错误时,我假设如果在 activemq 中是排队的消息,它会连接到它并且一切正常。
我很惊讶,出版商有问题 - 我没有改变它。而且我不知道为什么它有时会起作用......
编辑:
有一个错误:
“org.apache.activemq.transport.tcp.TcpTransportFactory 无法转换为 org.apache.activemq.transport.TransportFactory” - 将 auto-startup 更改为 false 后出现。
我还看到Thread.currentThread().getContextClassLoader() 在一切正常时返回BundleDelegatingClassLoader,在抛出异常时返回AppClassLoader。
【问题讨论】: