use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class AbstractQueue method getOldestMessageArrivalTime.
@Override
public long getOldestMessageArrivalTime() {
long oldestMessageArrivalTime = -1L;
while (oldestMessageArrivalTime == -1L) {
QueueEntryList entries = getEntries();
QueueEntry entry = entries == null ? null : entries.getOldestEntry();
if (entry != null) {
ServerMessage message = entry.getMessage();
if (message != null) {
try (MessageReference reference = message.newReference()) {
oldestMessageArrivalTime = reference.getMessage().getArrivalTime();
} catch (MessageDeletedException e) {
// ignore - the oldest message was deleted after it was discovered - we need to find the new oldest message
}
}
} else {
oldestMessageArrivalTime = 0;
}
}
return oldestMessageArrivalTime;
}
use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class AbstractQueue method getMessagesOnTheQueue.
List<QueueEntry> getMessagesOnTheQueue(QueueEntryFilter filter) {
ArrayList<QueueEntry> entryList = new ArrayList<QueueEntry>();
QueueEntryIterator queueListIterator = getEntries().iterator();
while (queueListIterator.advance() && !filter.filterComplete()) {
QueueEntry node = queueListIterator.getNode();
MessageReference reference = node.newMessageReference();
if (reference != null) {
try {
if (!node.isDeleted() && filter.accept(node)) {
entryList.add(node);
}
} finally {
reference.release();
}
}
}
return entryList;
}
use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class LastValueQueueListTest method createTestServerMessage.
private ServerMessage createTestServerMessage(String conflationKeyValue) {
ServerMessage mockMessage = mock(ServerMessage.class);
AMQMessageHeader messageHeader = mock(AMQMessageHeader.class);
when(messageHeader.getHeader(CONFLATION_KEY)).thenReturn(conflationKeyValue);
when(mockMessage.getMessageHeader()).thenReturn(messageHeader);
MessageReference messageReference = mock(MessageReference.class);
when(mockMessage.newReference()).thenReturn(messageReference);
when(mockMessage.newReference(any(TransactionLogResource.class))).thenReturn(messageReference);
when(messageReference.getMessage()).thenReturn(mockMessage);
return mockMessage;
}
use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class QueueEntryListTestBase method createServerMessage.
private ServerMessage createServerMessage(long number) {
final ServerMessage message = mock(ServerMessage.class);
when(message.getMessageNumber()).thenReturn(number);
MessageReference ref = mock(MessageReference.class);
AMQMessageHeader hdr = mock(AMQMessageHeader.class);
when(ref.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(message.getMessageHeader()).thenReturn(hdr);
return message;
}
use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class QueueMessageRecoveryTest method createMockMessage.
private ServerMessage createMockMessage(final long i) {
ServerMessage msg = mock(ServerMessage.class);
when(msg.getMessageNumber()).thenReturn(i);
MessageReference ref = mock(MessageReference.class);
when(ref.getMessage()).thenReturn(msg);
when(msg.newReference()).thenReturn(ref);
when(msg.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(msg.getStoredMessage()).thenReturn(mock(StoredMessage.class));
return msg;
}
Aggregations