简体   繁体   English

正确关闭ActiveMQ嵌入式代理

[英]Correct shutdown of ActiveMQ embedded broker

I have a simple Spring config for unit tests that includes ActiveMQ embedded broker, JMS producer and JMS listener. 我有一个简单的Spring配置用于单元测试,包括ActiveMQ嵌入式代理,JMS生成器和JMS监听器。 Tests are passed successfully, but when shutting everything down I see some exceptions. 测试成功通过,但当关闭所有内容时,我看到一些例外。 Like this: 像这样:

[ WARN] [ActiveMQ Connection Executor: tcp://localhost/127.0.0.1:61616 03:16:23] (SingleConnectionFactory.java:onException:301) Encountered a JMSException - resetting the underlying JMS Connection
javax.jms.JMSException: java.io.EOFException

My configuration: 我的配置:

<beans>
  <amq:queue id="defaultDestination" physicalName="example.A"/>
  <bean id="jmsProducerTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="defaultDestination" ref="defaultDestination"/>
  </bean>

  <bean id="jmsMessageSender" class="package.JMSMessageSender"/>

  <amq:broker id="broker" useJmx="false" persistent="false" destroyApplicationContextOnStop="true" >
    <amq:transportConnectors>
      <amq:transportConnector uri="tcp://localhost:61616"/>
    </amq:transportConnectors>
  </amq:broker>

  <bean id="messageListener" class="package.MessageReceiver"/>

  <bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" depends-on="broker">
    <property name="targetConnectionFactory">
      <amq:connectionFactory brokerURL="tcp://localhost:61616"/>
    </property>
  </bean>

  <jms:listener-container connection-factory="connectionFactory" container-type="default">
    <jms:listener destination="example.A" ref="messageListener"/>
  </jms:listener-container>
</beans>

I supposed that broker is closing and then connection factory loses connection. 我认为经纪人正在关闭,然后连接工厂失去连接。 But depends-on has not helped. depends-on并没有帮助。 Thanks for your help. 谢谢你的帮助。

Ad far as I can tell, there is no way to shut down the embedded AMQ without these exceptions. 据我所知,没有这些例外,没有办法关闭嵌入式AMQ。 The AMQ code treats that EOF as a relatively harmless event, but it does log that exception. AMQ代码将EOF视为相对无害的事件,但它会记录该异常。 You could try opening a JIRA at the Apache ActiveMQ project. 您可以尝试在Apache ActiveMQ项目中打开JIRA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM