This discussion is archived
0 Replies Latest reply: Nov 9, 2010 6:27 AM by 733639 RSS

Coherence Messaging JSP for Status

733639 Newbie
Currently Being Moderated
I built a standalone jsp that can be used to display the current states of the messaging destinations, queues and subscriptions. Figured I would share for anyone who wants it.

<%@ page import="javax.management.MBeanServer,
javax.management.MBeanServerFactory,
javax.management.ObjectName,
java.util.HashSet,
java.util.Iterator,
java.util.Set"%>

<%@page import="com.oracle.coherence.patterns.messaging.MessagingSession"%>
<%@page import="com.oracle.coherence.patterns.messaging.DefaultMessagingSession"%>
<%@page import="com.oracle.coherence.common.identifiers.Identifier"%>
<%@page import="com.tangosol.net.CacheFactory"%>
<%@page import="com.tangosol.net.NamedCache"%>
<%@page import="java.util.Enumeration"%>
<%@page import="com.oracle.coherence.patterns.messaging.Subscriber"%>
<%@page import="com.oracle.coherence.patterns.messaging.Queue"%>

<%@page import="com.oracle.coherence.patterns.messaging.Message"%>
<%@page import="com.oracle.coherence.patterns.messaging.QueueSubscription"%>

<html>
<title>Coherence: JMX Cache Information</title>
<body>
<h3>Queues</h3>
<table>
     <tr>
          <th>Queue Identifier</th>
          <th>Waiting</th>
          <th>Redelivered</th>
               <th>Received</th>
          <th>Delivered</th>
          <th>Subscriber</th>
     </tr>
     <%
     NamedCache messagingDestinations = CacheFactory.getCache("coherence.messagingpattern.destinations");
     out.println("<p>" + messagingDestinations.getCacheName() + " has " + messagingDestinations.size() + " Objects" + "</p>");
     Set<Object> messagingDestinationKeys = messagingDestinations.keySet();
     for (Object messagingDestinationKey : messagingDestinationKeys) {
          Queue q = (Queue)messagingDestinations.get(messagingDestinationKey);
          %>
          <tr>
               <td align="left"><%= q.getName() %></td>
               <td align="right"><%= q.getNumMessagesToDeliver() %></td>
               <td align="right"><%= q.getNumMessagesToRedeliver() %></td>
               <td align="right"><%= q.getNumMessagesReceived() %></td>
               <td align="right"><%= q.getNumMessagesDelivered() %></td>
               <td align="right"><%= q.getNumWaitingSubscriptions() %></td>
          </tr>
          <%
     }
     %>
     </table>
     <hr/>
     
     <h3>Messages In Queues</h3>
     <table>
     <tr>
          <th>Key</th>
          <th>Queue Identifier</th>
          <th>Message Identifier</th>
               <th>Payload</th>
     </tr>
     <%
     NamedCache messages = CacheFactory.getCache("coherence.messagingpattern.messages");
     out.println("<p>" + messages.getCacheName() + " has " + messages.size() + " Objects" + "</p>");
     Set<Object> messageKeys = messages.keySet();
     for (Object messageKey : messageKeys) {
          Message message = (Message) messages.get(messageKey);
          %>
          <tr>
               <td align="right"><%= message.getKey() %></td>
               <td align="left"><%= message.getDestinationIdentifier() %></td>
               <td align="right"><%= message.getMessageIdentifier() %></td>
               <td align="left"><%= message.getPayload() %></td>
          </tr>
          <%
     }
     %>
     </table>
     <hr/>
     
     <h3>Queue Subscriber Information</h3>
     <table>
     <tr>
          <th>Name</th>
          <th>Identifier</th>
          <th>Num Messages</th>
          <th>Num Messages Ack</th>
               <th>Num Messages Recv</th>
     </tr>
     <%
     NamedCache subscriptions = CacheFactory.getCache("coherence.messagingpattern.subscriptions");
     out.println("<p>" + subscriptions.getCacheName() + " has " + subscriptions.size() + " Objects" + "</p>");
     Set<Object> subscriptionKeys = subscriptions.keySet();
     for (Object subscriptionKey : subscriptionKeys) {
          QueueSubscription queueSubscription = (QueueSubscription) subscriptions.get(subscriptionKey);
          %>
          <tr>
               <td align="right"><%= queueSubscription.getName() %></td>
               <td align="right"><%= queueSubscription.getIdentifier() %></td>
               <td align="right"><%= queueSubscription.getNumMessages() %></td>
               <td align="right"><%= queueSubscription.getNumMessagesAcknowledged() %></td>
               <td align="right"><%= queueSubscription.getNumMessagesReceived() %></td>
          </tr>
          <%
     }
     %>
     </table>
     
</body>
</html>

Cheers!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points