4
votes

I am looking for answers for the following questions related to KahaDB.

I have an app that uses ActiveMQ and the app receives about 500,000 to 1 million messages which are written to an ActiveMQ queue with consumers picking them up.

I observed that the db.data file size varies anywhere between a few KB to almost 600 or 700 MB.

I noticed that when the db.data file size grows, messages get stuck, forcing me to shutdown my app, restart the app to have new consumers connecting to the broker to drain all messages.

  1. Ideally what should be the size of db.data? If an app produces and consumes at the same time, irrespective of the number of messages, I think the size of db.data should be small.

  2. Why sometimes the file size grows and what triggers the file size of db.data to grow?

I have ActiveMQ 5.6 and I see this issue at least 2 or 3 times a month. In the brokers that are running smooth, I observed that the file size of db.data is in KB and not 500 MB or 700 MB.

Here is the sample activemq.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core" 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-2.0.xsd   http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
   <!-- Allows us to use system properties as variables in this configuration file -->
   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
         <value>file:${activemq.conf}/credentials.properties</value>
      </property>
   </bean>
   <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="/foo/activemq_5.6/data">
      <destinationPolicy>
         <policyMap>
            <policyEntries>
               <policyEntry topic=">" producerFlowControl="true" memoryLimit="1mb">
                  <pendingSubscriberPolicy>
                     <vmCursor />
                  </pendingSubscriberPolicy>
               </policyEntry>
               <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb" useCache="false" />
            </policyEntries>
         </policyMap>
      </destinationPolicy>
      <managementContext>
         <managementContext createConnector="true" />
      </managementContext>
      <persistenceAdapter>
         <kahaDB directory="/foo/activemq_5.6/data/kahadb" />
      </persistenceAdapter>
      <systemUsage>
         <systemUsage>
            <memoryUsage>
               <memoryUsage limit="64 mb" />
            </memoryUsage>
            <storeUsage>
               <storeUsage limit="100 gb" />
            </storeUsage>
            <tempUsage>
               <tempUsage limit="50 gb" />
            </tempUsage>
         </systemUsage>
      </systemUsage>
      <transportConnectors>
         <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" />
      </transportConnectors>
   </broker>
   <import resource="jetty.xml" />
</beans>
1
can you post your broker configuration? - Martin Serrano
just posted and /foo is nothing but another mount with 200 gb of storage - serverfaces

1 Answers

1
votes

Generally the kahadb directory has segments for messages that haven't been consumed yet. If there is any message in the segment that hasn't been consumed yet, it will keep the whole segment. So if you nothing in any queue, you generally won't have much of anything in the kaha directory.

If you have the jetty console enabled, you can use it to see which queues have messages in them.

If you sometimes have some queues that are consumed slowly, you probably want to adjust the segment size from its default (something like 33 meg) to something smaller to avoid filling up your disk/hitting your storage limit from the config file)