this.propertyName = propertyName;
}
@Override
public MessageReference[] evictMessages(LinkedList messages) throws IOException {
MessageReference oldest = (MessageReference)messages.getFirst();
HashMap<Object, MessageReference> pivots = new HashMap<Object, MessageReference>();
Iterator iter = messages.iterator();
for (int i = 0; iter.hasNext(); i++) {
MessageReference reference = (MessageReference) iter.next();
if (propertyName != null && reference.getMessage().getProperty(propertyName) != null) {
Object key = reference.getMessage().getProperty(propertyName);
if (pivots.containsKey(key)) {
MessageReference pivot = pivots.get(key);
if (reference.getMessage().getTimestamp() > pivot.getMessage().getTimestamp()) {
pivots.put(key, reference);
}
} else {
pivots.put(key, reference);
}