AMQ-3173: activemq-web can now show more JMS message types.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1395293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Claus Ibsen 2012-10-07 13:03:42 +00:00
parent ddda4004b4
commit c720601aaf
1 changed files with 21 additions and 14 deletions

View File

@ -19,12 +19,13 @@ package org.apache.activemq.web;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.jms.BytesMessage;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.MapMessage; import javax.jms.MapMessage;
import javax.jms.Message; import javax.jms.Message;
import javax.jms.ObjectMessage; import javax.jms.ObjectMessage;
import javax.jms.QueueBrowser; import javax.jms.QueueBrowser;
import javax.jms.StreamMessage;
import javax.jms.TextMessage; import javax.jms.TextMessage;
/** /**
@ -88,21 +89,27 @@ public class MessageQuery extends QueueBrowseQuery {
if (message instanceof MapMessage) { if (message instanceof MapMessage) {
return createMapBody((MapMessage) message); return createMapBody((MapMessage) message);
} }
return null; if (message instanceof BytesMessage) {
} BytesMessage msg = (BytesMessage) message;
int len = (int) msg.getBodyLength();
public Map<String, Object> getPropertiesMap() throws JMSException { if (len > -1) {
Map<String, Object> answer = new HashMap<String, Object>(); byte[] data = new byte[len];
Message aMessage = getMessage(); msg.readBytes(data);
Enumeration iter = aMessage.getPropertyNames(); return new String(data);
while (iter.hasMoreElements()) { } else {
String name = (String) iter.nextElement(); return "";
Object value = aMessage.getObjectProperty(name);
if (value != null) {
answer.put(name, value);
} }
} }
return answer; if (message instanceof StreamMessage) {
return "StreamMessage is not viewable";
}
// unknown message type
if (message != null) {
return "Unknown message type [" + message.getClass().getName() + "] " + message;
}
return null;
} }
protected Map<String, Object> createMapBody(MapMessage mapMessage) throws JMSException { protected Map<String, Object> createMapBody(MapMessage mapMessage) throws JMSException {