2012-02-03 42 views
3

我有一個簡單的Spring配置,用於包含ActiveMQ嵌入式代理,JMS生產者和JMS監聽器的單元測試。測試已成功通過,但在關閉所有內容時,我會看到一些例外情況。就像這樣:正確關閉ActiveMQ嵌入式代理

[ 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 

我的配置:

<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> 

我推測,經紀人正在關閉,然後連接工廠失去連接。但depends-on沒有幫助。 感謝您的幫助。

回答

2

據我所知,除非出現這些例外情況,否則無法關閉嵌入式AMQ。 AMQ代碼將該EOF視爲相對無害的事件,但它記錄了該異常。您可以嘗試在Apache ActiveMQ項目中打開JIRA。