added a message detail page

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@397237 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-04-26 17:00:01 +00:00
parent edbadd930b
commit c99a7597aa
10 changed files with 260 additions and 115 deletions

View File

@ -1,43 +0,0 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.web;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQMessage;
import javax.jms.Message;
/**
*
* @version $Revision$
*/
public class MessageFacade extends BrokerFacade {
private String id;
private ActiveMQMessage message;
public MessageFacade(BrokerService brokerService) {
super(brokerService);
}
public ActiveMQMessage getMessage() {
if (message != null) {
// TODO ??
}
return message;
}
}

View File

@ -0,0 +1,115 @@
/**
*
* Copyright 2005-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.web;
import org.apache.activemq.broker.BrokerService;
import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Allow the user to browse a message on a queue by its ID
*
* @version $Revision$
*/
public class MessageQuery extends QueueBrowseQuery {
private String id;
private Message message;
public MessageQuery(BrokerService brokerService, SessionPool sessionPool) throws JMSException {
super(brokerService, sessionPool);
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void setMessage(Message message) {
this.message = message;
}
public Message getMessage() throws JMSException {
if (message == null) {
if (id != null) {
Enumeration iter = getBrowser().getEnumeration();
while (iter.hasMoreElements()) {
Message item = (Message) iter.nextElement();
if (id.equals(item.getJMSMessageID())) {
message = item;
break;
}
}
}
}
return message;
}
public Object getBody() throws JMSException {
Message message = getMessage();
if (message instanceof TextMessage) {
return ((TextMessage) message).getText();
}
if (message instanceof ObjectMessage) {
return ((ObjectMessage) message).getObject();
}
if (message instanceof MapMessage) {
return createMapBody((MapMessage) message);
}
return null;
}
public Map getPropertiesMap() throws JMSException {
Map answer = new HashMap();
Message aMessage = getMessage();
Enumeration iter = aMessage.getPropertyNames();
while (iter.hasMoreElements()) {
String name = (String) iter.nextElement();
Object value = aMessage.getObjectProperty(name);
if (value != null) {
answer.put(name, value);
}
}
return answer;
}
protected Map createMapBody(MapMessage mapMessage) throws JMSException {
Map answer = new HashMap();
Enumeration iter = mapMessage.getMapNames();
while (iter.hasMoreElements()) {
String name = (String) iter.nextElement();
Object value = mapMessage.getObject(name);
if (value != null) {
answer.put(name, value);
}
}
return answer;
}
}

View File

@ -39,7 +39,7 @@ public class QueueBrowseQuery extends DestinationFacade implements DisposableBea
super(brokerService);
this.sessionPool = sessionPool;
this.session = sessionPool.borrowSession();
setJMSDestinationType("query");
}
public void destroy() throws Exception {

View File

@ -11,7 +11,8 @@
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool"/>
<bean id="brokerQuery" class="org.apache.activemq.web.BrokerFacade" autowire='constructor'/>
<bean id="brokerQuery" class="org.apache.activemq.web.BrokerFacade" autowire='constructor' singleton="false"/>
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire='constructor' singleton="false"/>
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire='constructor' singleton="false"/>
</beans>

View File

@ -0,0 +1,13 @@
<%@ attribute name="var" type="java.lang.String" required="true" %>
<%@ attribute name="items" type="java.util.Map" required="true" %>
<%@ tag import="java.util.Iterator" %>
<%
Iterator iter = items.entrySet().iterator();
while (iter.hasNext()) {
request.setAttribute(var, iter.next());
%>
<jsp:doBody/>
<%
}
%>

View File

@ -1,17 +0,0 @@
<%@ attribute name="message" type="javax.jms.Message" required="true" %>
<%@ attribute name="var" type="java.lang.String" required="true" %>
<%@ tag import="javax.jms.TextMessage" %>
<%@ tag import="javax.jms.ObjectMessage" %>
<%
Object value = null;
if (message != null) {
if (message instanceof TextMessage) {
value = ((TextMessage) message).getText();
}
else if (message instanceof ObjectMessage) {
value = ((ObjectMessage) message).getObject();
}
}
request.setAttribute(var, value);
System.out.println("var: " + var + " is now: " + value);
%>

View File

@ -26,8 +26,8 @@
---%>
<jms:forEachMessage queueBrowser="${requestContext.queueBrowser.browser}" var="row">
<tr>
<jms:body message="${row}" var="body"/>
<td><a href="message.jsp?id=${row.JMSMessageID}" title="${body}">${row.JMSMessageID}</a></td>
<td><a href="message.jsp?id=${row.JMSMessageID}&JMSDestination=${requestContext.queueBrowser.JMSDestination}"
title="${row.properties}">${row.JMSMessageID}</a></td>
<td>${row.JMSCorrelationID}</td>
<td><jms:persistent message="${row}"/></td>
<td>${row.JMSPriority}</td>

View File

@ -1,59 +1,123 @@
<html>
<head>
<title>Message ${requestContext.messageBrowser.id}</title>
<c:set var="row" value="${requestContext.messageQuery.message}"/>
<title>Message ${requestContext.messageQuery.id}</title>
</head>
<body>
<table id="message" class="sortable autostripe">
<thead>
<tr>
<th>
Message Details
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="label">Message ID</td>
<td>${row.JMSMessageID</td>
</tr>
<tr>
<td class="label">Destination</td>
<td>${row.JMSDestination}</td>
</tr>
<tr>
<td class="label">Correlation ID</td>
<td>${row.JMSCorrelationID}</td>
</tr>
<tr>
<td class="label">Persistence</td>
<td><jms:persistent message="${row}"/></td>
</tr>
<tr>
<td class="label">Priority</td>
<td>${row.JMSPriority}</td>
</tr>
<tr>
<td class="label">Redelivered</td>
<td>${row.JMSRedelivered}</td>
</tr>
<tr>
<td class="label">Reply To</td>
<td>${row.JMSReplyTo}</td>
</tr>
<tr>
<td class="label">Timestamp</td>
<td>${row.JMSTimestamp}</td>
</tr>
<tr>
<td class="label">Type</td>
<td>${row.JMSType}</td>
</tr>
</tbody>
<c:choose>
<c:when test="${empty row}">
<div>
No message could be found for ID ${requestContext.messageQuery.JMSMessageID}
</div>
</c:when>
<c:otherwise>
<table class="layout">
<tr>
<td class="layout" valign="top">
<table id="header" class="sortable autostripe">
<thead>
<tr>
<th colspan="2">
Headers
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="label">Message ID</td>
<td>${row.JMSMessageID}</td>
</tr>
<tr>
<td class="label">Destination</td>
<td>${row.JMSDestination}</td>
</tr>
<tr>
<td class="label">Correlation ID</td>
<td>${row.JMSCorrelationID}</td>
</tr>
<tr>
<td class="label">Persistence</td>
<td><jms:persistent message="${row}"/></td>
</tr>
<tr>
<td class="label">Priority</td>
<td>${row.JMSPriority}</td>
</tr>
<tr>
<td class="label">Redelivered</td>
<td>${row.JMSRedelivered}</td>
</tr>
<tr>
<td class="label">Reply To</td>
<td>${row.JMSReplyTo}</td>
</tr>
<tr>
<td class="label">Timestamp</td>
<td>${row.JMSTimestamp}</td>
</tr>
<tr>
<td class="label">Type</td>
<td>${row.JMSType}</td>
</tr>
</tbody>
</table>
</td>
<td class="layout" valign="top">
<table id="properties" class="sortable autostripe">
<thead>
<tr>
<th colspan="2">
Properties
</th>
</tr>
</thead>
<tbody>
<form:forEachMapEntry items="${requestContext.messageQuery.propertiesMap}" var="row">
<tr>
<td class="label">${row.key}</td>
<td>${row.value}</td>
</tr>
<tr>
</form:forEachMapEntry>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="layout" colspan="2">
<table id="body" width="100%">
<thead>
<tr>
<th>
Message Details
</th>
</tr>
</thead>
<tbody>
<tr>
<td>${requestContext.messageQuery.body}</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</c:otherwise>
</c:choose>
</body>
</html>

View File

@ -7,9 +7,8 @@ table {
border-right: 1px solid #aaa;
margin-bottom: 1em;
width: 80%;
margin: 1em auto;
border-collapse: collapse;
margin: 1em auto;
border-collapse: collapse;
}
th {
@ -19,13 +18,15 @@ th {
background-color: #cccccc;
}
tfoot td {
tfoot {
border-top: 1px solid black;
}
td {
padding: 0.5em;
border: 1px solid black;
/** border-top: 1px solid black; */
}
@ -47,3 +48,14 @@ th.numeric {
td.label {
background-color: #f3f3f3;
}
table.layout {
border-bottom: solid white;
border-right: solid white;
margin-bottom: solid white;
}
td.layout {
border-top: 1px solid black;
border: solid white;
}