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:
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.
-
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:
<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!
-
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
0 comments:
Post a Comment