最近、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&jms.prefetchPolicy.all=10&wireFormat.maxInactivityDuration=0" discoveryUri="multicast://default"/>
</transportConnectors>
応答が大幅に遅れる根本的な原因を理解するのに役立ててください。この余分な応答時間が原因で、製品標準の応答時間の制限に達していません。また、クライアントは制限時間に達すると自動的に接続を閉じるように構成されているため、データの待機中にタイムアウトになります。