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
This commit is contained in:
James Strachan 2007-06-22 15:30:36 +00:00
parent fccb3cc2b0
commit e7ca882392
3 changed files with 20 additions and 13 deletions

View File

@ -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());

View File

@ -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;
}

View File

@ -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()) {