https://issues.apache.org/jira/browse/AMQ-4930 - limit browse page in iterations in case cursor and store are out of sync - avoid a spin when store does not return messages

This commit is contained in:
gtully 2014-10-09 23:05:09 +01:00
parent 41ca0d9464
commit 8216e7f4d5
1 changed files with 8 additions and 1 deletions

View File

@ -1104,8 +1104,15 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
public void doBrowse(List<Message> browseList, int max) {
final ConnectionContext connectionContext = createConnectionContext();
try {
int maxPageInAttempts = 1;
messagesLock.readLock().lock();
try {
maxPageInAttempts += (messages.size() / getMaxPageSize());
} finally {
messagesLock.readLock().unlock();
}
while (shouldPageInMoreForBrowse(max)) {
while (shouldPageInMoreForBrowse(max) && maxPageInAttempts-- > 0) {
pageInMessages(!memoryUsage.isFull(110));
};