1 18 package org.apache.activemq.broker.region.policy; 19 20 import org.apache.activemq.broker.region.MessageReference; 21 22 import java.io.IOException ; 23 import java.util.Iterator ; 24 import java.util.LinkedList ; 25 26 33 public class OldestMessageWithLowestPriorityEvictionStrategy extends MessageEvictionStrategySupport { 34 35 public MessageReference[] evictMessages(LinkedList messages) throws IOException { 36 byte lowestPriority = Byte.MAX_VALUE; 37 int pivot = 0; 38 Iterator iter = messages.iterator(); 39 for (int i = 0; iter.hasNext(); i++) { 40 MessageReference reference = (MessageReference) iter.next(); 41 byte priority = reference.getMessage().getPriority(); 42 if (priority < lowestPriority) { 43 lowestPriority = priority; 44 pivot = i; 45 } 46 } 47 return new MessageReference[] {(MessageReference) messages.remove(pivot)}; 48 } 49 } 50 | Popular Tags |