You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by marlet <vp...@freenet.de> on 2007/10/28 17:03:01 UTC

REST problem

Every time I want to pull out a message of a queue with a simple GET, two
messages are deleted in the queue.

I looked at org.apache.activemq.web.MessageServlet, method doMessages(..)
from the latest snapshot5

                    // send a response for each available message (up to max
                    // messages)
                    while ((maxMessages < 0 || messages < maxMessages) &&
message != null) {
                        //
System.err.println("message["+messages+"]="+message);
                        if (ajax) {
                            writer.print("<response type='object' id='");
                            writer.print(request.getParameter("id"));
                            writer.println("'>");
                        } else {
                            // only ever 1 message for non ajax!
                            setResponseHeaders(response, message);
                        }

                        writeMessageResponse(writer, message);

                        if (ajax) {
                            writer.println("</response>");
                        }

                        // look for next message
                        message = consumer.receiveNoWait();
                        messages++;
                    }

Shouldn't the message = consumer.receiveNoWait() only be executed if ajax is
true?

-- 
View this message in context: http://www.nabble.com/REST-problem-tf4707322s2354.html#a13454626
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: REST problem

Posted by marlet <vp...@freenet.de>.
Ok, I compiled the source code with following change in the two
doMessages(..) methods, and now it seems to be working:
                    ...
                    // send a response for each available message (up to max
                    // messages)
                    while ((maxMessages < 0 || messages < maxMessages) &&
message != null) {
                        //
System.err.println("message["+messages+"]="+message);
                        if (ajax) {
                            writer.print("<response type='object' id='");
                            writer.print(request.getParameter("id"));
                            writer.println("'>");
                        } else {
                            // only ever 1 message for non ajax!
                            setResponseHeaders(response, message);
                        }

                        writeMessageResponse(writer, message);

                        if (ajax) {
                            writer.println("</response>");
                            
                            // look for next message
                            message = consumer.receiveNoWait();
                        }

                       
                        messages++;
                    }
                    ...


-- 
View this message in context: http://www.nabble.com/REST-problem-tf4707322s2354.html#a13464922
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.