Search in sources :

Example 16 with MessageReference

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;
}
Also used : MessageDeletedException(org.apache.qpid.server.message.MessageDeletedException) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 17 with MessageReference

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;
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MessageReference(org.apache.qpid.server.message.MessageReference)

Example 18 with MessageReference

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;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 19 with MessageReference

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;
}
Also used : ServerMessage(org.apache.qpid.server.message.ServerMessage) AMQMessageHeader(org.apache.qpid.server.message.AMQMessageHeader) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Example 20 with MessageReference

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;
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) ServerMessage(org.apache.qpid.server.message.ServerMessage) MessageReference(org.apache.qpid.server.message.MessageReference) TransactionLogResource(org.apache.qpid.server.store.TransactionLogResource)

Aggregations

MessageReference (org.apache.qpid.server.message.MessageReference)20 ServerMessage (org.apache.qpid.server.message.ServerMessage)13 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)10 StoredMessage (org.apache.qpid.server.store.StoredMessage)6 AMQMessageHeader (org.apache.qpid.server.message.AMQMessageHeader)5 MessageDeletedException (org.apache.qpid.server.message.MessageDeletedException)3 AccessControlException (java.security.AccessControlException)2 InstanceProperties (org.apache.qpid.server.message.InstanceProperties)2 MessageDestination (org.apache.qpid.server.message.MessageDestination)2 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)2 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)2 Transaction (org.apache.qpid.server.store.Transaction)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 MessageContainer (org.apache.qpid.server.message.MessageContainer)1 RoutingResult (org.apache.qpid.server.message.RoutingResult)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)1