Я использовал конфигурацию встроенного сервера activeMQ (конфигурация очень похожа на примеры, иллюстрирующие концепцию встроенного сервера / слушателя activeMQ).
Как часть приложения, у меня есть поток мониторинга, который контролирует каталог. Вместо того, чтобы завершать процесс, чтобы завершить работу сервера activeMQ, я ввел проверку файла «STOP», и, если файл существует, сервер выключится.
Завершение работы, которое я пытаюсь выполнить, вызывая функцию остановки в брокере.
(broker.stop ()) Кажется, это отключает службу. Однако при выходе из System.exit возникают ошибки исключения:
Я заметил, что еще один пост, в котором упоминалось похожее поведение, имел ответ, который указывал столько же, сколько и "Это нормальное" поведение. Еще один пост указал, что я должен отключить shutdownhook (через конфигурацию Spring брокера, установив useShutdownHook = "false"). Это также не устранило проблему.
Любая помощь по этому вопросу приветствуется.
Спасибо
Вот трассировка стека исключений:
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 - Спасибо за комментарий)