2014-02-19 34 views
3

我正在測試ActiveMQ 5.9.0 with Replicated LevelDB五秒鐘等待activemq cms MessageProducer.send與動物園管理員

針對具有本地LevelDB存儲的獨立ActiveMQ運行,每個producer.send(message)調用大約需要1 ms。我用3個動物園管理員和3個activemq經紀人複製安裝,producer.send(message)需要稍微超過5秒才能返回!即使sync="local_mem"<replicatedLevelDB ... >中也會發生這種情況。它總是超過5秒,所以似乎有一些奇怪的等待/超時。

這是否響鈴?

如果我將brokerurl設置爲failover:(<all three brokers>)tcp://brokerX(其中brokerX位於複製的LevelDB設置中),則無關緊要。在brokerX web ui(hawtio)中沒有不明顯的延遲發送消息。如果我更改爲tcp://brokerY,其中經紀人是<persistenceAdapter ...>設置爲<levelDB...>,而不是<replicatedLevelDB...>,否則我們的發送時間爲1毫秒。

更改動物園管理員tickTime等沒有區別。

調試日誌如下。正如你所看到的,「發送到隊列」之間有5秒鐘,但zookeeper ping很快。

2014-02-19 10:45:34,719 | DEBUG | Handling request for path /jolokia | io.hawt.web.AuthenticationFilter | qtp1217711018-227 
2014-02-19 10:45:34,724 | DEBUG | localhost Message ID:<hostname>-57776-1392803129562-0:0:1:1:2 sent to queue://IO_stab_test_Q | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///<ip address>:[email protected] 
2014-02-19 10:45:34,725 | DEBUG | IO_stab_test_Q toPageIn: 1, Inflight: 1, pagedInMessages.size 1, enqueueCount: 27, dequeueCount: 25 | org.apache.activemq.broker.region.Queue | ActiveMQ BrokerService[localhost] Task-20 
2014-02-19 10:45:34,731 | DEBUG | Handling request for path /jolokia | io.hawt.web.AuthenticationFilter | qtp1217711018-222 
2014-02-19 10:45:34,735 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:34,867 | DEBUG | Handling request for path /jolokia | io.hawt.web.AuthenticationFilter | qtp1217711018-222 
2014-02-19 10:45:35,403 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:35,634 | DEBUG | Handling request for path /jolokia | io.hawt.web.AuthenticationFilter | qtp1217711018-227 
2014-02-19 10:45:36,071 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:36,740 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:37,410 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:38,088 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 8ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:38,623 | DEBUG | Handling request for path /jolokia | io.hawt.web.AuthenticationFilter | qtp1217711018-222 
2014-02-19 10:45:38,750 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:39,420 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
2014-02-19 10:45:39,735 | DEBUG | localhost Message ID:<hostname>-57776-1392803129562-0:0:1:1:3 sent to queue://IO_stab_test_Q | org.apache.activemq.broker.region.Queue | ActiveMQ Transport: tcp:///<ip address>:[email protected] 
2014-02-19 10:45:39,737 | DEBUG | IO_stab_test_Q toPageIn: 1, Inflight: 2, pagedInMessages.size 2, enqueueCount: 28, dequeueCount: 25 | org.apache.activemq.broker.region.Queue | ActiveMQ BrokerService[localhost] Task-24 
2014-02-19 10:45:40,090 | DEBUG | Got ping response for sessionid: 0x244457fceb80003 after 0ms | org.apache.zookeeper.ClientCnxn | main-SendThread(<hostname>:2181) 
+0

我會首先測試5.10-SNAPSHOT,因爲自5.9.0發佈以來,我們爲LevelDB修復了大量修復程序。 –

+0

從RELEASE移到SNAPSHOT並不總是一個選項。這種延遲也對我們產生了負面影響,但我們無法在生產中運行SNAPSHOT。 –

回答

1

Set queuePrefetch = 0。

對我們的情況有些背景...

我們的消息尺寸相當小(< 1KB XML),但我們的消費者從快(< 1秒)變化慢(10小時以上)。之前我們已經設置了prefetch = 1,但即使這樣做會在緩慢消息正在工作並且另一個消息被預取後面時導致問題。

我們已經注意到,我們的快速消息通常會在生產者甚至得到確認之前完成處理!我們發現producer.send()方法花費了+5秒(精確)到我們所期望的。這就是導致我找到這個問題的原因。

無論如何,我們的解決方案是設置prefetch = 0。這爲我們完全消除了5秒的延遲,併爲我們解決了另一個問題。