cursor = getDeliveryDb().openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
QueueEntryBinding keyBinding = QueueEntryBinding.getInstance();
keyBinding.objectToEntry(new QueueEntryKey(queue.getId(),0l), key);
if(cursor.getSearchKeyRange(key,value,LockMode.DEFAULT) == OperationStatus.SUCCESS)
{
QueueEntryKey entry = keyBinding.entryToObject(key);
if(entry.getQueueId().equals(queue.getId()))
{
entries.add(entry);
}
while (cursor.getNext(key, value, LockMode.DEFAULT) == OperationStatus.SUCCESS)
{
entry = keyBinding.entryToObject(key);
if(entry.getQueueId().equals(queue.getId()))
{
entries.add(entry);
}
else
{
break;
}
}
}
}
catch (DatabaseException e)
{
throw getEnvironmentFacade().handleDatabaseException("Cannot visit message instances", e);
}
finally
{
closeCursorSafely(cursor, getEnvironmentFacade());
}
for(QueueEntryKey entry : entries)
{
UUID queueId = entry.getQueueId();
long messageId = entry.getMessageId();
if (!handler.handle(queueId, messageId))
{
break;
}
}