org.apache.activemq.memory.list
public class: SimpleMessageList [javadoc |
source]
java.lang.Object
org.apache.activemq.memory.list.SimpleMessageList
All Implemented Interfaces:
MessageList
A simple fixed size
MessageList where there is a single, fixed size
list that all messages are added to for simplicity. Though this will lead to
possibly slow recovery times as many more messages than is necessary will
have to be iterated through for each subscription.
- version:
$
- Revision: 1.1 $
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.activemq.memory.list.SimpleMessageList Detail: |
public void add(MessageReference node) {
int delta = node.getMessageHardRef().getSize();
synchronized (lock) {
list.add(node);
size += delta;
while (size > maximumSize) {
MessageReference evicted = list.removeFirst();
size -= evicted.getMessageHardRef().getSize();
}
}
}
|
public Message[] browse(ActiveMQDestination destination) {
List< Message > result = new ArrayList< Message >();
DestinationFilter filter = DestinationFilter.parseFilter(destination);
synchronized (lock) {
for (Iterator< MessageReference > i = list.iterator(); i.hasNext();) {
MessageReference ref = i.next();
Message msg;
try {
msg = ref.getMessage();
if (filter.matches(msg.getDestination())) {
result.add(msg);
}
} catch (IOException e) {
LOG.error("Failed to get Message from MessageReference: " + ref, e);
}
}
}
return result.toArray(new Message[result.size()]);
}
|
public void clear() {
synchronized (lock) {
list.clear();
size = 0;
}
}
|
public List<MessageReference> getList() {
synchronized (lock) {
return new ArrayList< MessageReference >(list);
}
}
Returns a copy of the list |
public List<MessageReference> getMessages(ActiveMQDestination destination) {
return getList();
}
|
public int getSize() {
synchronized (lock) {
return size;
}
}
|