无法使用内置的 BrokerService.stop 调用关闭嵌入式 ActiveMQ 服务 [英] Unable to shutdown embedded activeMQ service using the built in BrokerService.stop call

查看:29
本文介绍了无法使用内置的 BrokerService.stop 调用关闭嵌入式 ActiveMQ 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用嵌入式 ActiveMQ 服务器配置(配置与说明嵌入式 ActiveMQ 服务器/侦听器概念的示例非常相似).作为应用程序的一部分,我有一个监视目录的监视线程.我不必终止进程来关闭 activeMQ 服务器,而是引入了对STOP"文件的检查,如果该文件存在,则服务器将关闭.我试图通过调用代理上的停止函数来完成关闭:

I have been using an embedded activeMQ server configuration (configuration is very similar to the examples that illustrate the concept of an embedded activeMQ server/listener). As part of the application, I have a monitoring thread that monitors a directory. Instead of having to kill the process to shutdown the activeMQ server, I introduced a check for a "STOP" file and if the file exists, the server would shutdown. The shutdown I am trying to accomplish by calling the stop function on the broker:

(broker.stop())

这似乎关闭了服务.但是,在 System.exit 时,会引发异常错误:

This seems to shutdown the service. However, Upon a System.exit, Exception errors are raised:

我观察到另一篇提到类似行为的帖子的回复表明这是正常的"行为.另一篇文章表明我应该禁用shutdownhook(通过设置useShutdownHook="false" 的代理的Spring 配置).这也没有解决问题.

I observed that one other post that mentioned similar behaviour had a response that indicated as much as "This is normal" behavior. One other post indicated that I should disable the shutdownhook (via Spring config of the broker by setting the useShutdownHook="false"). This has not fixed the problem either.

感谢有关此问题的任何帮助.

Any help regarding this issue is appreciated.

谢谢

这是异常堆栈跟踪:

17:10:20.056 [Thread-9] DEBUG org.apache.activemq.AdvisoryConsumer - Failed to send remove command: javax.jms.JMSException: Peer (vm://localhost#3) disposed.
javax.jms.JMSException: Peer (vm://localhost#3) disposed.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1267) [activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1259) [activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:615) [activemq-core-5.5.1.jar:5.5.1]
    at org.springframework.jms.connection.SingleConnectionFactory.closeConnection(SingleConnectionFactory.java:426) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.resetConnection(SingleConnectionFactory.java:321) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.destroy(SingleConnectionFactory.java:312) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:958) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://localhost#3) disposed.
    at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:89) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1265) [activemq-core-5.5.1.jar:5.5.1]
    ... 13 common frames omitted
17:10:20.069 [Thread-9] DEBUG o.s.j.c.SingleConnectionFactory - Could not close shared JMS Connection
javax.jms.JMSException: Peer (vm://localhost#3) disposed.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doSyncSendPacket(ActiveMQConnection.java:1342) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:660) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.springframework.jms.connection.SingleConnectionFactory.closeConnection(SingleConnectionFactory.java:426) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.resetConnection(SingleConnectionFactory.java:321) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.destroy(SingleConnectionFactory.java:312) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:958) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://localhost#3) disposed.
    at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:89) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:91) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doSyncSendPacket(ActiveMQConnection.java:1329) ~[activemq-core-5.5.1.jar:5.5.1]
    ... 11 common frames omitted
17:10:20.069 [Thread-9] DEBUG o.s.b.f.s.DisposableBeanAdapter - Invoking destroy() on bean with name 'jmsProducerConnectionFactory'
17:10:20.069 [Thread-9] DEBUG o.s.j.c.SingleConnectionFactory - Closing shared JMS Connection: ActiveMQConnection {id=ID:u0102180-MacA.local-57101-1331074458547-2:1,clientId=ID:u0102180-MacA.local-57101-1331074458547-3:1,started=false}
17:10:20.070 [Thread-9] DEBUG org.apache.activemq.AdvisoryConsumer - Failed to send remove command: javax.jms.JMSException: Peer (vm://localhost#1) disposed.
javax.jms.JMSException: Peer (vm://localhost#1) disposed.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1267) [activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.asyncSendPacket(ActiveMQConnection.java:1259) [activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.AdvisoryConsumer.dispose(AdvisoryConsumer.java:56) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:615) [activemq-core-5.5.1.jar:5.5.1]
    at org.springframework.jms.connection.SingleConnectionFactory.closeConnection(SingleConnectionFactory.java:426) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.resetConnection(SingleConnectionFactory.java:321) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.destroy(SingleConnectionFactory.java:312) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:958) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://localhost#1) disposed.
    at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:89) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.oneway(ResponseCorrelator.java:60) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doAsyncSendPacket(ActiveMQConnection.java:1265) [activemq-core-5.5.1.jar:5.5.1]
    ... 13 common frames omitted
17:10:20.071 [Thread-9] DEBUG o.s.j.c.SingleConnectionFactory - Could not close shared JMS Connection
javax.jms.JMSException: Peer (vm://localhost#1) disposed.
    at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:62) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doSyncSendPacket(ActiveMQConnection.java:1342) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.close(ActiveMQConnection.java:660) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.springframework.jms.connection.SingleConnectionFactory.closeConnection(SingleConnectionFactory.java:426) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.resetConnection(SingleConnectionFactory.java:321) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.jms.connection.SingleConnectionFactory.destroy(SingleConnectionFactory.java:312) [spring-jms-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:211) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:498) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:474) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:442) [spring-beans-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1066) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1040) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:958) [spring-context-3.1.0.RELEASE.jar:3.1.0.RELEASE]
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Peer (vm://localhost#1) disposed.
    at org.apache.activemq.transport.vm.VMTransport.oneway(VMTransport.java:89) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:40) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:91) ~[activemq-core-5.5.1.jar:5.5.1]
    at org.apache.activemq.ActiveMQConnection.doSyncSendPacket(ActiveMQConnection.java:1329) ~[activemq-core-5.5.1.jar:5.5.1]
    ... 11 common frames omitted

(@TimBish - 感谢您的评论)

(@TimBish - Thanks for the comment)

推荐答案

ActiveMQ 注册自己的 shutdown hook 并在进程终止时自动停止.因此,在您调用 stop() 之前它已经停止并且出现异常.

ActiveMQ registers its own shutdown hook and stops automatically when the process is terminating. Thus it is already stopped before you've called stop() and the exception appears.

如果您通过 Spring 手动停止它,那么您应该通过设置属性 useShutdownHook="false"

If you are stopping it manually via Spring then you should disable the shutdown hook by setting the property useShutdownHook="false"

<broker brokerName="broker" useShutdownHook="false">

这篇关于无法使用内置的 BrokerService.stop 调用关闭嵌入式 ActiveMQ 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆