在ServiceMix-shutdown的情况下,ActiveMQ的订单依赖性



看来,如果使用ActiveMQ-Combosumer,则根据不关闭组件是正确的顺序。据我所知,在关闭依赖路线之前,JMSSessionPool已关闭。这会导致JMSESCEPTION,并且每个客户端路由将在被迫关闭之前陷入超时。另外,AMQ-broker在其依赖路线之前删除了IST。

<?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&amp;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

有人知道如何解决这个问题吗?

更新路由的捆绑包的起始级别。容器将以相反的顺序关闭捆绑包。看来您的捆绑包在与经纪人捆绑包的相同级别(或较低)。

也..如果您使用的是部署/目录,则可以更新设置:

etc/org.apache.felix.fileinstall-deploy.cfg:

felix.fileinstall.start.level = xx

参考:http://felix.apache.org/documentation/subprojects/apache-felix-file-install.html

对于那些可能在karaf/felix中遇到此问题的人,我们通过编写一个KARAF控制台脚本来解决问题,该脚本在发出'Shutshown'命令之前先停止我们的骆驼上下文。

上下文停止命令将在该上下文返回之前优雅地停止所有路由。

上下文停止大约需要15秒(大约300个路线),然后关闭在大约5秒内完成(我们有350多个捆绑包)。

所以脚本看起来像这样:

camel:context-stop context1
camel:context-stop context2
camel:context-stop context3
camel:context-stop context4
shutdown -f

(已更改上下文名称以保护无辜)

最新更新