mirror of https://github.com/apache/activemq.git
added support for standard JMS headers being passed along as parameters
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@395670 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
73187ab013
commit
4c91a69ead
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.activemq.web;
|
||||
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
|
||||
|
@ -30,6 +31,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpSession;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -113,7 +115,29 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
|
||||
|
||||
protected void appendParametersToMessage(HttpServletRequest request, TextMessage message) throws JMSException {
|
||||
for (Iterator iter = request.getParameterMap().entrySet().iterator(); iter.hasNext();) {
|
||||
Map parameters = new HashMap(request.getParameterMap());
|
||||
String correlationID = (String) parameters.remove("JMSCorrelationID");
|
||||
if (correlationID != null) {
|
||||
message.setJMSCorrelationID(correlationID);
|
||||
}
|
||||
Long expiration = asLong(parameters.remove("JMSExpiration"));
|
||||
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);
|
||||
}
|
||||
String type = (String) parameters.remove("JMSType");
|
||||
if (correlationID != null) {
|
||||
message.setJMSType(type);
|
||||
}
|
||||
|
||||
for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) iter.next();
|
||||
String name = (String) entry.getKey();
|
||||
if (!destinationParameter.equals(name) && !topicParameter.equals(name) && !bodyParameter.equals(name)) {
|
||||
|
@ -138,6 +162,37 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
}
|
||||
}
|
||||
|
||||
protected Destination asDestination(Object value) {
|
||||
if (value instanceof Destination) {
|
||||
return (Destination) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
String text = (String) value;
|
||||
return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Integer asInteger(Object value) {
|
||||
if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return Integer.valueOf((String) value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Long asLong(Object value) {
|
||||
if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return Long.valueOf((String) value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the destination to use for the current request
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue