org.apache.qpid.test.framework
Class MessageMonitor

java.lang.Object
  extended by org.apache.qpid.test.framework.MessageMonitor
All Implemented Interfaces:
MessageListener

public class MessageMonitor
extends Object
implements MessageListener

MessageMonitor is used to record information about messages received. This will provide methods to check various properties, such as the type, number and content of messages received in order to verify the correct behaviour of tests.

CRC Card
Responsibilities Collaborations
Count incoming messages.
Record time ellapsed since the arrival of the first message.
Reset all counts and timings.


Field Summary
protected  Long firstMessageTime
          Holds the time of arrival of the first message.
protected  AtomicInteger numMessages
          Holds the count of messages received since the last query.
 
Constructor Summary
MessageMonitor()
           
 
Method Summary
 int getNumMessage()
          Gets the count of messages.
 long getTime()
          Gets the time elapsed since the first message arrived, in nanos, or zero if no messages have arrived yet.
 void onMessage(Message message)
          Handles received messages.
 void reset()
          Resets the message count and timer to zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numMessages

protected AtomicInteger numMessages
Holds the count of messages received since the last query.


firstMessageTime

protected Long firstMessageTime
Holds the time of arrival of the first message.

Constructor Detail

MessageMonitor

public MessageMonitor()
Method Detail

onMessage

public void onMessage(Message message)
Handles received messages. Does Nothing.

Specified by:
onMessage in interface MessageListener
Parameters:
message - The message. Ignored.

getNumMessage

public int getNumMessage()
Gets the count of messages.

Returns:
The count of messages.

getTime

public long getTime()
Gets the time elapsed since the first message arrived, in nanos, or zero if no messages have arrived yet.

Returns:
The time elapsed since the first message arrived, in nanos, or zero if no messages have arrived yet.

reset

public void reset()
Resets the message count and timer to zero.



Licensed to the Apache Software Foundation