activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gminet <gmi...@easynet.be>
Subject Ajax/amq: Lost messages in MessageListenerServlet if more than maxMessages waiting
Date Sun, 20 May 2007 13:28:33 GMT

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
-- 
View this message in context: http://www.nabble.com/Ajax-amq%3A-Lost-messages-in-MessageListenerServlet-if-more-than-maxMessages-waiting-tf3785745s2354.html#a10705883
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message