2016-07-11 55 views
3

當向ActiveMQ隊列投擲大量負載時,它似乎按照它應該入隊/出隊消息,但存儲保持滿。ActiveMQ沒有釋放隊列的磁盤存儲

這會導致生產者在一段時間後阻塞,當存儲達到100%時,會導致應用程序停止響應請求。

這是我們使用的相關ActiveMQ的Spring配置:

<beans 
    xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://activemq.apache.org/schema/core 
         http://activemq.apache.org/schema/core/activemq-core.xsd 
         http://activemq.apache.org/schema/core 
         http://activemq.apache.org/schema/core/activemq-core.xsd"> 

<!-- ===================================================== 
    Broker Configuration 
    ===================================================== --> 
<broker id="appEmbeddedBroker" 
     xmlns="http://activemq.apache.org/schema/core" 
     brokerName="${msg.embedded.broker.name}" 
     persistent="true" 
     dataDirectory="${msg.embedded.broker.data.directory}" 
     useJmx="true" > 

    <destinationPolicy> 
     <policyMap> 
      <policyEntries> 
       <policyEntry topic=">" > 
        <pendingMessageLimitStrategy> 
         <constantPendingMessageLimitStrategy limit="1000"/> 
        </pendingMessageLimitStrategy> 
       </policyEntry> 
      </policyEntries> 
     </policyMap> 
    </destinationPolicy> 

    <managementContext> 
     <managementContext connectorPort="${msg.embedded.broker.jmx.port}" createConnector="false"/> 
    </managementContext> 

    <persistenceAdapter> 
     <levelDB directory="${msg.embedded.broker.db.directory}" /> 
    </persistenceAdapter> 

    <systemUsage> 
     <systemUsage> 
      <memoryUsage> 
       <memoryUsage percentOfJvmHeap="10"/> 
      </memoryUsage> 
      <storeUsage> 
       <storeUsage limit="${msg.embedded.broker.system.usage.store.usage}"/> <!-- Configured for 200Mb --> 
      </storeUsage> 
      <tempUsage> 
       <tempUsage limit="${msg.embedded.broker.system.usage.temp.usage}"/> <!-- Configured for 40Mb --> 
      </tempUsage> 
     </systemUsage> 
    </systemUsage> 

    <plugins> 
     <!-- Configure authentication; Username, passwords and groups --> 
     <simpleAuthenticationPlugin anonymousAccessAllowed="false"> 
      <users> 
       <authenticationUser username="app" password="${msg.embedded.broker.app.password}" 
            groups="users"/> 
      </users> 
     </simpleAuthenticationPlugin> 
    </plugins> 

    <transportConnectors> 
     <transportConnector name="tcp" uri="tcp://0.0.0.0:${msg.embedded.broker.port}?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> 
    </transportConnectors> 

    <shutdownHooks> 
     <bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" /> 
    </shutdownHooks> 

</broker> 


<!-- ===================================================== 
    Client Connections 
    ===================================================== --> 

<bean id="embeddedAmqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" depends-on="appEmbeddedBroker" > 
    <property name="brokerURL" value="${msg.embedded.broker.url}" /> 
    <property name="userName" value="${msg.embedded.client.app.username}" /> 
    <property name="password" value="${msg.embedded.broker.app.password}" /> 
</bean> 

<bean id="embeddedAmqPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" > 
    <property name="connectionFactory" ref="embeddedAmqConnectionFactory" /> 
    <property name="maxConnections" value="${msg.embedded.client.connection.pool.max}" /> 
</bean> 

當查詢豆:

$>get QueueSize EnqueueCount DequeueCount                     

#mbean = org.apache.activemq:brokerName=app-embedded,destinationName=the.queue.name.local,destinationType=Queue,type=Broker: 

QueueSize = 0; 


EnqueueCount = 17821; 


DequeueCount = 17821; 

和:

#mbean = org.apache.activemq:brokerName=app-embedded,type=Broker: 

StoreLimit = 209715200; 


StorePercentUsage = 100; 


TempLimit = 41943040; 


TempPercentUsage = 0; 

所以,questi on會是:爲什麼如果所有的郵件都出現了,我們仍然看到100%的存儲使用率?

回答

1

可能有很多原因取決於您的代理配置和使用情況。首先要檢查的是DLQ的內容,然後在控制檯上查看其他保留消息的目標。由於事物的方式是通過KahaDB雜誌傳播的記錄有可能是他們創造的鏈條不能斷,直到你清除一些其他的隊列或回滾仍在任何交易飛行等

上有一個guide ActiveMQ網站涵蓋了如何開始調試應該幫助您入門的情況。

此外,請嘗試運行最新的代理髮行版,這些組件中存在嘗試解決這些情況的修復程序。

+0

感謝@ tim-bish爲您解答。我查看了控制檯,其他隊列/主題似乎都沒有保存到消息中,但仍然存儲已滿。這是在另一次運行。此外,DLQ未啓用。我們正在使用內嵌的ActiveMQ代理和倒數第二個版本(5.13.2)。另外需要注意的是,我們不使用KahaDB,而是使用LevelDB。 – ecrisostomo

+0

不要使用LevelDB它有很多問題,沒有上游的志願者來維護它。 –

+0

我們前段時間解決了這個問題,但將此答案標記爲解決問題的答案,因爲它實際上是填充空間的DLQ。我們的配置使得所有(或大部分)消息都可以傳送到DLQ,即使它們已經被成功處理。 – ecrisostomo