看来,如果使用ActiveMQ-Consumer,依赖组件不会关闭是正确的顺序。 据我所知,JMSSessionPool在依赖路由关闭之前关闭。 这会导致JMSEsception,并且每个客户端路由在强制关闭之前都会遇到超时。 此外,amq-broker在其依赖路由之前被删除。
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelContext id="ObjectServerConnection" xmlns="http://camel.apache.org/schema/blueprint" >
<route id="test-aqm-shutdown-route">
<from uri="activemq:buffered-route?concurrentConsumers=5&asyncConsumer=5" />
<!--transacted ref="required" /-->
<convertBodyTo type="java.lang.String" />
<to uri="file:/out.txt" />
</route>
</camelContext>
</blueprint>
正如我在logfile中看到的那样: ...
2016-12-08 11:48:53,003 | INFO | FelixShutdown | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Starting to graceful shutdown 1 routes (timeout 300 seconds)
2016-12-08 11:49:02,336 | ERROR | [buffered-route] | faultJmsMessageListenerContainer | 145 - org.apache.servicemix.bundles.spring-jms - 3.2.17.RELEASE_1 | Could not refresh JMS Connection for destination 'buffered-route' - retrying in 5000 ms. Cause: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not create Transport. Reason: java.io.IOException: Broker named 'amq-broker' does not exist.
2016-12-08 11:49:07,339 | INFO | 5 - ShutdownTask | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Route: test-aqm-shutdown-route shutdown complete, was consuming from: Endpoint[activemq://buffered-route?asyncConsumer=5&concurrentConsumers=5]
2016-12-08 11:49:07,340 | INFO | FelixShutdown | DefaultShutdownStrategy | 151 - org.apache.camel.camel-core - 2.16.4 | Graceful shutdown of 1 routes completed in 14 seconds
...
2016-12-08 11:47:09,064 | DEBUG | m://amq-broker#0 | AdvisoryConsumer | 122 - org.apache.activemq.activemq-osgi - 5.12.3 | Failed to send remove command: javax.jms.JMSException: Peer (vm://amq-broker#1) disposed.
javax.jms.JMSException: Peer (vm://amq-broker#1) disposed.
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1314)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1306)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:57)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:655)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.jms.pool.ConnectionPool.close(ConnectionPool.java:168)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.jms.pool.ConnectionPool.onException(ConnectionPool.java:379)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection$5.run(ActiveMQConnection.java:1982)[122:org.apache.activemq.activemq-osgi:5.12.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_102]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_102]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://amq-broker#1) disposed.
at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:91)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60)[122:org.apache.activemq.activemq-osgi:5.12.3]
at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1312)[122:org.apache.activemq.activemq-osgi:5.12.3]
... 9 more
有没有人知道如何解决这个问题?
答案 0 :(得分:0)
更新路线的捆绑包的起始级别。容器将以相反的顺序关闭bundle。您的捆绑包似乎与代理捆绑包处于同一级别(或更低)。
另外..如果您使用的是deploy /目录,则可以更新设置:
等/ org.apache.felix.fileinstall-deploy.cfg:
felix.fileinstall.start.level = XX
参考:http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html
答案 1 :(得分:0)
对于那些可能在Karaf / Felix中遇到此问题的人,我们通过编写一个Karaf控制台脚本解决了这个问题,该脚本在发出'shutdown'命令之前先停止了我们的Camel上下文。
上下文停止命令将在返回之前正常停止该上下文中的所有路由。
上下文停止大约需要15秒钟(大约300条路由),然后关闭将在大约5秒钟内完成(我们有350多个捆绑包)。
所以脚本看起来像这样:
camel:context-stop context1
camel:context-stop context2
camel:context-stop context3
camel:context-stop context4
shutdown -f
(上下文名称已更改,以保护无辜者)