mirror of https://github.com/apache/activemq.git
- Read the first string of the request parameter if the value is a String[]
- Appended the message properties in the MessageListenerServlet. git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@395717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a16b869fd8
commit
c2aad2a074
|
@ -162,7 +162,8 @@ public class MessageListenerServlet extends MessageServletSupport {
|
|||
else if ("send".equals(type))
|
||||
{
|
||||
TextMessage message = client.getSession().createTextMessage(messages[i]);
|
||||
// TODO sent message parameters
|
||||
appendParametersToMessage(request, message);
|
||||
|
||||
client.send(destination, message);
|
||||
message_ids+=message.getJMSMessageID()+"\n";
|
||||
if (log.isDebugEnabled()) {
|
||||
|
@ -201,6 +202,8 @@ public class MessageListenerServlet extends MessageServletSupport {
|
|||
Destination destination=getDestination(client, request);
|
||||
String body = getPostedMessageBody(request);
|
||||
TextMessage message = client.getSession().createTextMessage(body );
|
||||
appendParametersToMessage(request, message);
|
||||
|
||||
client.send(destination, message);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sent to destination: " + destination + " body: " + body);
|
||||
|
|
|
@ -116,7 +116,7 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
|
||||
protected void appendParametersToMessage(HttpServletRequest request, TextMessage message) throws JMSException {
|
||||
Map parameters = new HashMap(request.getParameterMap());
|
||||
String correlationID = (String) parameters.remove("JMSCorrelationID");
|
||||
String correlationID = asString(parameters.remove("JMSCorrelationID"));
|
||||
if (correlationID != null) {
|
||||
message.setJMSCorrelationID(correlationID);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
if (replyTo != null) {
|
||||
message.setJMSReplyTo(replyTo);
|
||||
}
|
||||
String type = (String) parameters.remove("JMSType");
|
||||
String type = (String) asString(parameters.remove("JMSType"));
|
||||
if (correlationID != null) {
|
||||
message.setJMSType(type);
|
||||
}
|
||||
|
@ -170,6 +170,10 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
String text = (String) value;
|
||||
return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE);
|
||||
}
|
||||
if (value instanceof String[]) {
|
||||
String text = ((String[]) value)[0];
|
||||
return ActiveMQDestination.createDestination(text, ActiveMQDestination.QUEUE_TYPE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -180,6 +184,9 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
if (value instanceof String) {
|
||||
return Integer.valueOf((String) value);
|
||||
}
|
||||
if (value instanceof String[]) {
|
||||
return Integer.valueOf(((String[]) value)[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -190,6 +197,21 @@ public abstract class MessageServletSupport extends HttpServlet {
|
|||
if (value instanceof String) {
|
||||
return Long.valueOf((String) value);
|
||||
}
|
||||
if (value instanceof String[]) {
|
||||
return Long.valueOf(((String[]) value)[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String asString(Object value) {
|
||||
if (value instanceof String[]) {
|
||||
return ((String[])value)[0];
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue