From 6fbb56868ff7d11c28c55ca2134c2a93e3a778d3 Mon Sep 17 00:00:00 2001 From: Gregory John Wilkins Date: Tue, 20 Jun 2006 22:26:49 +0000 Subject: [PATCH] changed parameter handling to impose a strict ordering to avoid reordering of messages by client libraries git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@415827 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/web/MessageListenerServlet.java | 55 +++++++++++-------- .../resources/org/apache/activemq/web/_amq.js | 9 ++- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java index 4c8493e496..185bc6f93a 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageListenerServlet.java @@ -90,7 +90,16 @@ public class MessageListenerServlet extends MessageServletSupport { } /** - * Sends a message to a destination + * Sends a message to a destination or manage subscriptions. + * + * If the the content type of the POST is application/x-www-form-urlencoded, then the form parameters + * "destination", "message" and "type" are used to pass a message or a subscription. If multiple messages + * or subscriptions are passed in a single post, then additional parameters are shortened to "dN", "mN" and "tN" + * where N is an index starting from 1. The type is either "send", "listen" or "unlisten". For send types, + * the message is the text of the TextMessage, otherwise it is the ID to be used for the subscription. + * + * If the content type is not application/x-www-form-urlencoded, then the body of the post is + * sent as the message to a destination that is derived from a query parameter, the URL or the default destination. * * @param request * @param response @@ -110,30 +119,30 @@ public class MessageListenerServlet extends MessageServletSupport { log.debug("POST client="+client+" session="+request.getSession().getId()+" info="+request.getPathInfo()+" contentType="+request.getContentType()); // dump(request.getParameterMap()); } - String[] destinations = request.getParameterValues("destination"); - String[] messages = request.getParameterValues("message"); - String[] types = request.getParameterValues("type"); - if (destinations.length!=messages.length || messages.length!=types.length) - { - if (log.isDebugEnabled()) { - log.debug("ERROR destination="+destinations.length+" message="+messages.length+" type="+types.length); - } - response.sendError(HttpServletResponse.SC_BAD_REQUEST,"missmatched destination, message or type"); - return; - } + int messages=0; - for (int i=0;i0) { - amq._messageQueue+=(amq._messages==0?'destination=':'&destination=')+destination+'&message='+message+'&type='+type; + if (amq._messages==0) + { + amq._messageQueue='destination='+destination+'&message='+message+'&type='+type; + } + else + { + amq._messageQueue='d'+amq._messages+'='+destination+'&m'+amq._messages+'='+message+'&t'+amq._messages+'='+type; + } amq._messages++; } else