1

我们最近从 ActiveMQ 4.0 迁移到 ActiveMQ 5.6,并注意到代理的响应时间减慢了大约 50-60 秒。我们使用默认的 ActiveMQ 5.6 设置并且没有配置任何参数。客户端使用 Java Impl 存根,应用服务器是 Jboss 5.1.0。我们在 ActiveMQ 中打开了 TRACE 日志记录以检查速度变慢的原因,但无法找到任何重要的东西。队列看起来因为某种原因正在等待,我们可以在日志中看到很多重复的以下行:

2012-06-11 02:04:38,523 | DEBUG | queue://dav/validator expiring messages .. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:38,524 | DEBUG | dav/validator toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 0, dequeueCount: 0 | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:38,524 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@e0420b:dav/validator,batchResetNeeded=false,storeHasMessages=false,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:38,524 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@e0420b:dav/validator,batchResetNeeded=false,storeHasMessages=false,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:38,524 | DEBUG | queue://dav/validator expiring messages done. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | DEBUG | queue://dav/logger expiring messages .. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | DEBUG | dav/logger toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 1, dequeueCount: 1 | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@1c64ed8:dav/logger,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@1c64ed8:dav/logger,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | DEBUG | queue://dav/logger expiring messages done. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | DEBUG | queue://dav/synchronizer expiring messages .. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | DEBUG | dav/synchronizer toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 1, dequeueCount: 1 | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,824 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@1549ceb:dav/synchronizer,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@1549ceb:dav/synchronizer,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | DEBUG | queue://dav/synchronizer expiring messages done. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | DEBUG | queue://dav/executor expiring messages .. | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | DEBUG | dav/executor toPageIn: 0, Inflight: 0, pagedInMessages.size 0, enqueueCount: 1, dequeueCount: 1 | org.apache.activemq.broker.region.Queue | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@9b777a:dav/executor,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler
2012-06-11 02:04:39,825 | TRACE | org.apache.activemq.broker.region.cursors.QueueStorePrefetch@9b777a:dav/executor,batchResetNeeded=false,storeHasMessages=true,size=0,cacheEnabled=true - fillBatch | org.apache.activemq.broker.region.cursors.AbstractStoreCursor | ActiveMQ Broker[localhost] Scheduler

我们可以从调度程序中看到上面的行,并怀疑它可能引入了等待,因此尝试使用标志 useScheduleSupport=false。我们还尝试了 persistent=false 标志,但它对时间没有影响。

这是我的 ActiveMQ.xml 文件:

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!-- START SNIPPET: example -->
<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>

    <!--
        The <broker> element is used to configure the ActiveMQ broker.
    -->
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" 
        useShutdownHook="false" useJmx="true" persistent="false">

        <!--
            For better performances use VM cursor and small memory limit.
            For more information, see:

            http://activemq.apache.org/message-cursors.html

            Also, if your producer is "hanging", it's probably due to producer flow control.
            For more information, see:
            http://activemq.apache.org/producer-flow-control.html
        -->
  <!--
        <destinationPolicy>
      <policyMap><policyEntries>

          <policyEntry topic="FOO.>">
            <dispatchPolicy>
              <strictOrderDispatchPolicy />
            </dispatchPolicy>
            <subscriptionRecoveryPolicy>
              <lastImageSubscriptionRecoveryPolicy />
            </subscriptionRecoveryPolicy>
          </policyEntry>

      </policyEntries></policyMap>
    </destinationPolicy>
  -->

<destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" producerFlowControl="false" memoryLimit="1mb">
                  <pendingSubscriberPolicy>
                    <vmCursor />
                  </pendingSubscriberPolicy>
                </policyEntry>
                <policyEntry queue=">" producerFlowControl="false" memoryLimit="1mb">
                  <!-- Use VM cursor for better latency
                       For more information, see:

                       http://activemq.apache.org/message-cursors.html

                  <pendingQueuePolicy>
                    <vmQueueCursor/>
                  </pendingQueuePolicy>
                  -->
                </policyEntry>
              </policyEntries>
            </policyMap>
        </destinationPolicy>
        <!--
            The managementContext is used to configure how ActiveMQ is exposed in
            JMX. By default, ActiveMQ uses the MBean server that is started by
            the JVM. For more information, see:

            http://activemq.apache.org/jmx.html
        -->
        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>

        <!--
            Configure message persistence for the broker. The default persistence
            mechanism is the KahaDB store (identified by the kahaDB tag).
            For more information, see:

            http://activemq.apache.org/persistence.html
        -->
        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb"/>
        </persistenceAdapter>


          <!--
            The systemUsage controls the maximum amount of space the broker will
            use before slowing down producers. For more information, see:
            http://activemq.apache.org/producer-flow-control.html
            If using ActiveMQ embedded - the following limits could safely be used:

        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="20 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="1 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="100 mb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

          <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="64 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>-->

        <!--
            The transport connectors expose ActiveMQ over a given protocol to
            clients and other brokers. For more information, see:

            http://activemq.apache.org/configuring-transports.html
        -->
        <transportConnectors>
            <transportConnector name="default" uri="tcp://localhost:61616?jms.useAsyncSend=true&amp;jms.prefetchPolicy.all=10&amp;wireFormat.maxInactivityDuration=0" discoveryUri="multicast://default"/>
        </transportConnectors>

请帮助了解导致响应额外延迟的根本原因。这个额外的响应时间导致我们未能达到我们的生产标准响应时间限制。此外,客户端等待数据超时,因为它们被配置为在达到时间限制后自动关闭连接。

4

0 回答 0