diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java b/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java index 5c34affde3..b7735440f6 100755 --- a/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/region/cursors/StoreDurableSubscriberCursor.java @@ -20,9 +20,9 @@ import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; import org.apache.activemq.advisory.AdvisorySupport; import org.apache.activemq.broker.Broker; import org.apache.activemq.broker.ConnectionContext; @@ -47,7 +47,7 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor { private String clientId; private String subscriberName; private Map topics = new HashMap(); - private LinkedList storePrefetches = new LinkedList(); + private List storePrefetches = new CopyOnWriteArrayList(); private boolean started; private PendingMessageCursor nonPersistent; private PendingMessageCursor currentCursor; @@ -322,7 +322,10 @@ public class StoreDurableSubscriberCursor extends AbstractPendingMessageCursor { } } // round-robin - storePrefetches.addLast(storePrefetches.removeFirst()); + if (storePrefetches.size()>1) { + PendingMessageCursor first = storePrefetches.remove(0); + storePrefetches.add(first); + } } return currentCursor; }