org.jboss.jms.server.messagecounter
Class MessageCounter

java.lang.Object
  extended by org.jboss.jms.server.messagecounter.MessageCounter

public class MessageCounter
extends java.lang.Object

This class stores message count informations for a given queue At intervals this class samples the queue for message count data Note that the underlying queue *does not* update statistics every time a message is added since that would reall slow things down, instead we *sample* the queues at regular intervals - this means we are less intrusive on the queue

Version:
$Revision: 1.8 $
Author:
Ulf Schroeter, Stephan Steinbacher, Tim Fox

Field Summary
protected static Logger log
           
 
Constructor Summary
MessageCounter(java.lang.String name, java.lang.String subscription, Queue queue, boolean topic, boolean durable, int daycountmax)
          Constructor
 
Method Summary
 int getCount()
          Gets the total message count since startup or last counter reset
 int getCountDelta()
          Gets the message count delta since last method call
 java.lang.String getCounterAsString()
          Get message counter data as string in format "Topic/Queue, Name, Subscription, Durable, Count, CountDelta, Depth, DepthDelta, Timestamp Last Increment"
 boolean getDestinationDurable()
          Gets the related destination durable subscription flag
 java.lang.String getDestinationName()
          Gets the related destination name
 java.lang.String getDestinationSubscription()
          Gets the related destination subscription
 boolean getDestinationTopic()
          Gets the related destination topic flag
 java.lang.String getHistoryAsString()
          Get message counter history data as string in format "day count\n Date 1, hour counter 0, hour counter 1, ..., hour counter 23\n Date 2, hour counter 0, hour counter 1, ..., hour counter 23\n .....
 int getHistoryLimit()
          Get message counter history day count limit <0: unlimited, 0: history disabled, >0: day count
 long getLastUpdate()
          Gets the timestamp of the last message add
 int getMessageCount()
          Gets the current message count of pending messages within the destination waiting for dispatch
 int getMessageCountDelta()
          Gets the message count delta of pending messages since last method call.
static java.util.List getMessageStatistics(java.util.List counters)
          Get a list of message statistics from a list of message counters
 void onTimer()
           
 void resetCounter()
          Reset message counter values
 void resetHistory()
          Reset message counter history
 void setHistoryLimit(int daycountmax)
          Set message counter history day count limit <0: unlimited, 0: history disabled, >0: day count
 java.lang.String toString()
          Get string representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final Logger log
Constructor Detail

MessageCounter

public MessageCounter(java.lang.String name,
                      java.lang.String subscription,
                      Queue queue,
                      boolean topic,
                      boolean durable,
                      int daycountmax)
Constructor

Parameters:
name - destination name
subscription - subscription name
queue - internal queue object
topic - topic destination flag
durable - durable subsciption flag
daycountmax - max message history day count
Method Detail

getMessageStatistics

public static java.util.List getMessageStatistics(java.util.List counters)
                                           throws java.lang.Exception
Get a list of message statistics from a list of message counters

Parameters:
counter - the message counters
Returns:
the message statistics
Throws:
java.lang.Exception - for any error

toString

public java.lang.String toString()
Get string representation

Overrides:
toString in class java.lang.Object

onTimer

public void onTimer()

getDestinationName

public java.lang.String getDestinationName()
Gets the related destination name

Returns:
String destination name

getDestinationSubscription

public java.lang.String getDestinationSubscription()
Gets the related destination subscription

Returns:
String destination name

getDestinationTopic

public boolean getDestinationTopic()
Gets the related destination topic flag

Returns:
boolean true: topic destination, false: queue destination

getDestinationDurable

public boolean getDestinationDurable()
Gets the related destination durable subscription flag

Returns:
boolean true : durable subscription, false: non-durable subscription

getCount

public int getCount()
Gets the total message count since startup or last counter reset

Returns:
int message count

getCountDelta

public int getCountDelta()
Gets the message count delta since last method call

Returns:
int message count delta

getMessageCount

public int getMessageCount()
Gets the current message count of pending messages within the destination waiting for dispatch

Returns:
int message queue depth

getMessageCountDelta

public int getMessageCountDelta()
Gets the message count delta of pending messages since last method call. Therefore

Returns:
int message queue depth delta

getLastUpdate

public long getLastUpdate()
Gets the timestamp of the last message add

Returns:
long system time

resetCounter

public void resetCounter()
Reset message counter values


getCounterAsString

public java.lang.String getCounterAsString()
Get message counter data as string in format "Topic/Queue, Name, Subscription, Durable, Count, CountDelta, Depth, DepthDelta, Timestamp Last Increment"

Returns:
String message counter data string

getHistoryLimit

public int getHistoryLimit()
Get message counter history day count limit <0: unlimited, 0: history disabled, >0: day count


setHistoryLimit

public void setHistoryLimit(int daycountmax)
Set message counter history day count limit <0: unlimited, 0: history disabled, >0: day count


resetHistory

public void resetHistory()
Reset message counter history


getHistoryAsString

public java.lang.String getHistoryAsString()
Get message counter history data as string in format "day count\n Date 1, hour counter 0, hour counter 1, ..., hour counter 23\n Date 2, hour counter 0, hour counter 1, ..., hour counter 23\n ..... ..... Date n, hour counter 0, hour counter 1, ..., hour counter 23\n"

Returns:
String message history data string


Copyright © 2006 JBoss Inc. All Rights Reserved.