On 5/20/07, gminet <[EMAIL PROTECTED]> wrote:
Hi,
To test our ajax/amq application, we diminished the maximumMessages value in
MessageListenerServlet to some ridiculous value: 2 instead of 100.
We immediately began to lose every third message whenever there were more
that 2 messages waiting in the queue. I think we found the bug in
MessageListenerServlet:
In the following extract of doMessages() :
// Look for any available messages
message = consumer.receiveNoWait();
while (message != null && messages < maximumMessages) {
String id = (String) consumerIdMap.get(consumer);
writer.print("<response id='");
writer.print(id);
writer.print("'>");
writeMessageResponse(writer, message);
writer.println("</response>");
messages++;
message = consumer.receiveNoWait();
}
If we reach the messages > maximumMessages condition, the last one that has
been removed from the queue (message = consumer.receiveNoWait()) wont ever
be sent to the client;
If just added the following code as a quick fix after the while loop:
if (message != null) {
String id = (String) consumerIdMap.get(consumer);
writer.print("<response id='");
writer.print(id);
writer.print("'>");
writeMessageResponse(writer, message);
writer.println("</response>");
messages++;
}
Hope it helps
Regards
Gaetan
Many thanks for the fix; patch applied on trunk!
I made a slight change to the code to avoid having to duplicate code;
I just split the boolean expression and moved the check for null
messages inside the while loop
--
James
-------
http://macstrac.blogspot.com/