有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java数据库。数据和ActiveMQ 5.6

我正在寻找与KahaDB相关的以下问题的答案

我有一个使用ActiveMQ的应用程序,该应用程序接收到大约500000到100万条消息,这些消息被写入ActiveMQ队列,消费者会将其接收

我观察到db。数据文件大小从几KB到近600或700 MB不等

我注意到当db。数据文件大小增加,消息被卡住,迫使我关闭应用程序,重新启动应用程序,让新的消费者连接到代理以排出所有消息

  1. 理想情况下,db的大小应该是多少。数据如果一个应用程序同时产生和消费,不管消息的数量如何,我认为db的大小是一样的。数据应该很小

  2. 为什么有时文件大小会增长,是什么触发了db的文件大小。数据增长

我有ActiveMQ 5.6,我每个月至少会看到2到3次这个问题。在运行平稳的代理中,我观察到db的文件大小。数据以KB为单位,而不是500 MB或700 MB

下面是示例activemq。xml文件:

<?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) 个答案

  1. # 1 楼答案

    通常,kahadb目录包含尚未使用的消息段。如果段中有任何消息尚未被使用,它将保留整个段。因此,如果您在任何队列中没有任何内容,那么kaha目录中通常不会有太多内容

    如果启用了jetty控制台,则可以使用它查看哪些队列中包含消息

    如果有时有些队列消耗缓慢,您可能希望将段大小从默认值(如33兆)调整为更小的值,以避免填满磁盘/达到配置文件中的存储限制)