Search in sources :

Example 6 with EnqueueableMessage

use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.

the class FlowToDiskTransactionObserverTest method createMessage.

private EnqueueableMessage<?> createMessage(int size) {
    EnqueueableMessage message = mock(EnqueueableMessage.class);
    StoredMessage handle = mock(StoredMessage.class);
    when(message.getStoredMessage()).thenReturn(handle);
    when(handle.getContentSize()).thenReturn(size);
    final StorableMessageMetaData metadata = mock(StorableMessageMetaData.class);
    when(metadata.getStorableSize()).thenReturn(0);
    when(metadata.getContentSize()).thenReturn(size);
    when(handle.getMetaData()).thenReturn(metadata);
    return message;
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage) StorableMessageMetaData(org.apache.qpid.server.store.StorableMessageMetaData)

Example 7 with EnqueueableMessage

use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.

the class MessageStoreTestCase method createEnqueueableMessage.

private EnqueueableMessage createEnqueueableMessage(long messageId1) {
    final StoredMessage<TestMessageMetaData> message1 = _store.addMessage(new TestMessageMetaData(messageId1, 0)).allContentAdded();
    EnqueueableMessage enqueueableMessage1 = createMockEnqueueableMessage(messageId1, message1);
    return enqueueableMessage1;
}
Also used : EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage)

Example 8 with EnqueueableMessage

use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.

the class MessageStoreTestCase method testRollbackTransactionAfterCommit.

public void testRollbackTransactionAfterCommit() throws Exception {
    final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
    TransactionLogResource mockQueue = createTransactionLogResource(mockQueueId);
    long messageId1 = 30L;
    long messageId2 = 31L;
    long messageId3 = 32L;
    final EnqueueableMessage enqueueableMessage1 = createEnqueueableMessage(messageId1);
    final EnqueueableMessage enqueueableMessage2 = createEnqueueableMessage(messageId2);
    final EnqueueableMessage enqueueableMessage3 = createEnqueueableMessage(messageId3);
    Transaction txn = getStore().newTransaction();
    txn.enqueueMessage(mockQueue, enqueueableMessage1);
    txn.commitTran();
    txn = getStore().newTransaction();
    txn.enqueueMessage(mockQueue, enqueueableMessage2);
    txn.abortTran();
    txn = getStore().newTransaction();
    txn.enqueueMessage(mockQueue, enqueueableMessage3);
    txn.commitTran();
    QueueFilteringMessageInstanceHandler filter = new QueueFilteringMessageInstanceHandler(mockQueueId);
    _storeReader.visitMessageInstances(filter);
    Set<Long> enqueuedIds = filter.getEnqueuedIds();
    assertEquals("Number of enqueued messages is incorrect", 2, enqueuedIds.size());
    assertTrue("Message with id " + messageId1 + " is not found", enqueuedIds.contains(messageId1));
    assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
Also used : EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage) UUID(java.util.UUID)

Example 9 with EnqueueableMessage

use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.

the class MessageStoreTestCase method testRollbackTransactionBeforeCommit.

public void testRollbackTransactionBeforeCommit() throws Exception {
    final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
    TransactionLogResource mockQueue = createTransactionLogResource(mockQueueId);
    long messageId1 = 21L;
    long messageId2 = 22L;
    long messageId3 = 23L;
    final EnqueueableMessage enqueueableMessage1 = createEnqueueableMessage(messageId1);
    final EnqueueableMessage enqueueableMessage2 = createEnqueueableMessage(messageId2);
    final EnqueueableMessage enqueueableMessage3 = createEnqueueableMessage(messageId3);
    Transaction txn = getStore().newTransaction();
    txn.enqueueMessage(mockQueue, enqueueableMessage1);
    txn.abortTran();
    txn = getStore().newTransaction();
    txn.enqueueMessage(mockQueue, enqueueableMessage2);
    txn.enqueueMessage(mockQueue, enqueueableMessage3);
    txn.commitTran();
    QueueFilteringMessageInstanceHandler filter = new QueueFilteringMessageInstanceHandler(mockQueueId);
    _storeReader.visitMessageInstances(filter);
    Set<Long> enqueuedIds = filter.getEnqueuedIds();
    assertEquals("Number of enqueued messages is incorrect", 2, enqueuedIds.size());
    assertTrue("Message with id " + messageId2 + " is not found", enqueuedIds.contains(messageId2));
    assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
Also used : EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage) UUID(java.util.UUID)

Example 10 with EnqueueableMessage

use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.

the class MessageStoreTestCase method createMockEnqueueableMessage.

private EnqueueableMessage createMockEnqueueableMessage(long messageId, final StoredMessage<TestMessageMetaData> message) {
    EnqueueableMessage enqueueableMessage = mock(EnqueueableMessage.class);
    when(enqueueableMessage.isPersistent()).thenReturn(true);
    when(enqueueableMessage.getMessageNumber()).thenReturn(messageId);
    when(enqueueableMessage.getStoredMessage()).thenReturn(message);
    return enqueueableMessage;
}
Also used : EnqueueableMessage(org.apache.qpid.server.message.EnqueueableMessage)

Aggregations

EnqueueableMessage (org.apache.qpid.server.message.EnqueueableMessage)13 UUID (java.util.UUID)7 StorableMessageMetaData (org.apache.qpid.server.store.StorableMessageMetaData)2 Transaction (org.apache.qpid.server.store.Transaction)2 MessageInstanceHandler (org.apache.qpid.server.store.handler.MessageInstanceHandler)2 ArrayList (java.util.ArrayList)1 MessageDurability (org.apache.qpid.server.store.MessageDurability)1 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)1 MessageStore (org.apache.qpid.server.store.MessageStore)1 NullMessageStore (org.apache.qpid.server.store.NullMessageStore)1 StoredMessage (org.apache.qpid.server.store.StoredMessage)1 EnqueueRecord (org.apache.qpid.server.store.Transaction.EnqueueRecord)1 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)1 DistributedTransactionHandler (org.apache.qpid.server.store.handler.DistributedTransactionHandler)1 MessageHandler (org.apache.qpid.server.store.handler.MessageHandler)1 DtxBranch (org.apache.qpid.server.txn.DtxBranch)1 DtxRegistry (org.apache.qpid.server.txn.DtxRegistry)1 Xid (org.apache.qpid.server.txn.Xid)1