From e7ca8823922dfbd3045356a7fddff9441393ab94 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Fri, 22 Jun 2007 15:30:36 +0000 Subject: [PATCH] applied patch from Dejan Bosanac for AMQ-1227 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@549845 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/activemq/web/MessageServlet.java | 4 +-- .../activemq/web/MessageServletSupport.java | 27 ++++++++++++------- .../org/apache/activemq/web/WebClient.java | 2 +- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java index dbfae76195..1572b62249 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java @@ -93,13 +93,13 @@ public class MessageServlet extends MessageServletSupport { if (log.isDebugEnabled()) { log.debug("Sending message to: " + destination + " with text: " + text); } - + TextMessage message = client.getSession().createTextMessage(text); appendParametersToMessage(request, message); boolean persistent = isSendPersistent(request); int priority = getSendPriority(request); long timeToLive = getSendTimeToLive(request); - client.send(destination, message); + client.send(destination, message, persistent, priority, timeToLive); // lets return a unique URI for reliable messaging response.setHeader("messageID", message.getJMSMessageID()); diff --git a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java index 33204ee2f6..f36cbb8165 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/MessageServletSupport.java @@ -21,9 +21,8 @@ package org.apache.activemq.web; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.TextMessage; @@ -52,7 +51,7 @@ import java.util.Map; public abstract class MessageServletSupport extends HttpServlet { private static final transient Log log = LogFactory.getLog(MessageServletSupport.class); - + private boolean defaultTopicFlag = true; private Destination defaultDestination; private String destinationParameter = "destination"; @@ -76,7 +75,6 @@ public abstract class MessageServletSupport extends HttpServlet { if (log.isDebugEnabled()) { log.debug("Defaulting to use topics: " + defaultTopicFlag); } - name = servletConfig.getInitParameter("destination"); if (name != null) { if (defaultTopicFlag) { @@ -119,10 +117,6 @@ public abstract class MessageServletSupport extends HttpServlet { if (expiration != null) { message.setJMSExpiration(expiration.longValue()); } - Integer priority = asInteger(parameters.remove("JMSPriority")); - if (expiration != null) { - message.setJMSPriority(priority.intValue()); - } Destination replyTo = asDestination(parameters.remove("JMSReplyTo")); if (replyTo != null) { message.setJMSReplyTo(replyTo); @@ -135,7 +129,12 @@ public abstract class MessageServletSupport extends HttpServlet { for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); - if (!destinationParameter.equals(name) && !typeParameter.equals(name) && !bodyParameter.equals(name)) { + if (!destinationParameter.equals(name) + && !typeParameter.equals(name) + && !bodyParameter.equals(name) + && !"JMSDeliveryMode".equals(name) + && !"JMSPriority".equals(name) + && !"JMSTimeToLive".equals(name)) { Object value = entry.getValue(); if (value instanceof Object[]) { Object[] array = (Object[]) value; @@ -146,7 +145,7 @@ public abstract class MessageServletSupport extends HttpServlet { log.warn("Can't use property: " + name + " which is of type: " + value.getClass().getName() + " value"); value = null; for (int i = 0, size = array.length; i < size; i++) { - log.debug("value[" + i + "] = " + array[i]); + log.debug("value[" + i + "] = " + array[i]); } } } @@ -174,6 +173,14 @@ public abstract class MessageServletSupport extends HttpServlet { } protected boolean isSendPersistent(HttpServletRequest request) { + String text = request.getParameter("JMSDeliveryMode"); + if (text != null) { + if (text.trim().equalsIgnoreCase("persistent")) { + return true; + } else { + return false; + } + } return defaultMessagePersistent; } diff --git a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java index 8ed940cfba..156e1ea47d 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/WebClient.java @@ -205,7 +205,7 @@ public class WebClient implements HttpSessionActivationListener, HttpSessionBind } } - public void send(Destination destination, Message message, boolean persistent, int priority, int timeToLive) throws JMSException { + public void send(Destination destination, Message message, boolean persistent, int priority, long timeToLive) throws JMSException { int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; getProducer().send(destination, message, deliveryMode, priority, timeToLive); if (log.isDebugEnabled()) {