I am trying to implement performance testing on ActiveMQ, so have setup a basic producer and consumer to send and receive messages across a queue. I have created a producer with no problems, getting it to write a specific number of messages to the queue:
我正在尝试在ActiveMQ上实现性能测试,因此设置了一个基本的生产者和消费者来跨队列发送和接收消息。我创建了一个没有问题的生产者,让它将特定数量的消息写入队列:
for(int i = 0; i < numberOfMessages; i++){
try{
String message = generateText(sizeOfMessage);
produceMessage(message);
}
catch (Exception e) {
logger.error("Caught exception while sending message", e);
}
}
This continues to completion with no problems and I have confirmed this with checks on the admin website, that have the correct number of messages pending.
这种情况继续完成,没有任何问题,我已通过管理网站上的检查确认了这一点,该网站上有正确的待处理邮件数。
The problem occurs when I try to receive the messages from the queue. Using a simple consumer to read from the queue, it will read a various number of messages from the queue, but then will stop when trying to receive one of the messages. I can see that there are still messages in the queue to be read, but the client will not progress passed one of the messages. I am using a simple method to receive the messages:
当我尝试从队列接收消息时,会发生此问题。使用简单的使用者从队列中读取,它将从队列中读取各种数量的消息,但在尝试接收其中一条消息时将停止。我可以看到队列中仍有消息要读取,但客户端将无法通过其中一条消息。我使用一种简单的方法来接收消息:
Message message = jmsTemplate.receive();
and it works for some messages(about 20-30) but then just locks. It was suggested to me that some of the characters in the message may be an escape character (I was using a random string of varying length, due to this just being a performance test, not actually sending over any content) so I changed all messages to the same string, which is a repetition of the char '2' and still no luck. I am using Spring configuration to load all of the components needed to access the ActiveMQ queue, and the queue is running on my localhost.
它适用于某些消息(约20-30),但随后只是锁定。有人告诉我,消息中的一些字符可能是一个转义字符(我使用的是一个长度不一的随机字符串,因为这只是一个性能测试,而不是实际发送任何内容)所以我更改了所有消息相同的字符串,这是char'2'的重复,但仍然没有运气。我使用Spring配置加载访问ActiveMQ队列所需的所有组件,并且队列在我的localhost上运行。
2 个解决方案
#1
4
Not many views on this yet, but for future reference if anyone has the same problem, I have found the solution. The configuration for activeMQ limits the amount of memory used by the senders and receivers before slowing them down, the default values given to me were:
关于这一点的观点不多,但如果有人遇到同样的问题,为了将来参考,我找到了解决方案。 activeMQ的配置限制了发送器和接收器在减速之前使用的内存量,给出的默认值是:
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
I removed this configuration completely and now it works a dream. I'm carrying out performance testing, so you may want to put your own constraints in, but this was definitely the cause of my problems!
我完全删除了这个配置,现在它实现了梦想。我正在进行性能测试,所以你可能想把自己的约束放进去,但这肯定是我问题的原因!
#2
0
Its a classic issue with messaging; what to do with slow consumers. FWIW more recent ActiveMQ releases such as 5.2 allow you to spool to disk rather than blocking producers when memory gets low
它是消息传递的经典问题;如何处理缓慢的消费者。 FWIW最新的ActiveMQ版本(如5.2)允许您在内存不足时使用假脱机而不是阻塞生产者
#1
4
Not many views on this yet, but for future reference if anyone has the same problem, I have found the solution. The configuration for activeMQ limits the amount of memory used by the senders and receivers before slowing them down, the default values given to me were:
关于这一点的观点不多,但如果有人遇到同样的问题,为了将来参考,我找到了解决方案。 activeMQ的配置限制了发送器和接收器在减速之前使用的内存量,给出的默认值是:
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage>
I removed this configuration completely and now it works a dream. I'm carrying out performance testing, so you may want to put your own constraints in, but this was definitely the cause of my problems!
我完全删除了这个配置,现在它实现了梦想。我正在进行性能测试,所以你可能想把自己的约束放进去,但这肯定是我问题的原因!
#2
0
Its a classic issue with messaging; what to do with slow consumers. FWIW more recent ActiveMQ releases such as 5.2 allow you to spool to disk rather than blocking producers when memory gets low
它是消息传递的经典问题;如何处理缓慢的消费者。 FWIW最新的ActiveMQ版本(如5.2)允许您在内存不足时使用假脱机而不是阻塞生产者