使用zookeeper在activemq cms MessageProducer.send中等待五秒钟

时间:2014-02-19 10:03:46

标签: activemq redhat apache-zookeeper

我正在测试ActiveMQ 5.9.0 with Replicated LevelDB

针对具有本地LevelDB存储的独立ActiveMQ运行,每个producer.send(message)调用大约需要1毫秒。通过我的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毫秒。

更改zookeeper 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>:54727@61616
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>:54727@61616
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)

1 个答案:

答案 0 :(得分:1)

设置queuePrefetch = 0。

我们情况的一些背景......

我们的消息大小相当小(<1kb xml),但我们的消费者从快速(<1秒)到慢速(10小时以上)不等。以前我们已经设置了prefetch = 1,但即使这样做也会在我们处理慢速消息并在其后面预取另一条消息时给我们带来问题。

我们注意到我们的快速消息通常会在制作人获得确认之前完成处理!我们发现producer.send()方法花了+5秒(完全)达到了我们的预期。这就是我找到这个问题的原因。

无论如何,我们的解决方案是设置prefetch = 0。这完全消除了我们的5秒延迟,并为我们解决了另一个问题。