org.apache.activemq.tool
Class MemMessageIdList

java.lang.Object
  extended by org.apache.activemq.tool.MemMessageIdList
All Implemented Interfaces:
MessageListener
Direct Known Subclasses:
MemConsumer

public class MemMessageIdList
extends Object
implements MessageListener

A simple container of messages for performing testing and rendezvous style code. You can use this class a MessageListener and then make assertions about how many messages it has received allowing a certain maximum amount of time to ensure that the test does not hang forever.

Also you can chain these instances together with the setParent(MessageListener) method so that you can aggregate the total number of messages consumed across a number of consumers.


Field Summary
protected static Logger LOG
           
 
Constructor Summary
MemMessageIdList()
           
MemMessageIdList(Object semaphore)
           
 
Method Summary
 boolean equals(Object that)
           
 List<String> flushMessages()
           
 int getMessageCount()
           
 List<String> getMessageIds()
           
 MessageListener getParent()
           
 int hashCode()
           
 boolean hasReceivedMessage()
           
 boolean hasReceivedMessages(int messageCount)
           
 boolean isVerbose()
           
 void onMessage(Message message)
           
 void setParent(MessageListener parent)
          Allows a parent listener to be specified such as to aggregate messages consumed across consumers
 void setVerbose(boolean verbose)
           
 String toString()
           
 void waitForMessagesToArrive(int messageCount)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final Logger LOG
Constructor Detail

MemMessageIdList

public MemMessageIdList()

MemMessageIdList

public MemMessageIdList(Object semaphore)
Method Detail

equals

public boolean equals(Object that)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

flushMessages

public List<String> flushMessages()
Returns:
all the messages on the list so far, clearing the buffer

getMessageIds

public List<String> getMessageIds()

onMessage

public void onMessage(Message message)
Specified by:
onMessage in interface MessageListener

getMessageCount

public int getMessageCount()

waitForMessagesToArrive

public void waitForMessagesToArrive(int messageCount)

hasReceivedMessage

public boolean hasReceivedMessage()

hasReceivedMessages

public boolean hasReceivedMessages(int messageCount)

isVerbose

public boolean isVerbose()

setVerbose

public void setVerbose(boolean verbose)

getParent

public MessageListener getParent()

setParent

public void setParent(MessageListener parent)
Allows a parent listener to be specified such as to aggregate messages consumed across consumers



Copyright © 2005–2013 The Apache Software Foundation. All rights reserved.