Search in sources :

Example 21 with StoredMessage

use of org.apache.qpid.server.store.StoredMessage in project qpid-broker-j by apache.

the class AbstractBDBMessageStore method recordXid.

private List<Runnable> recordXid(Transaction txn, long format, byte[] globalId, byte[] branchId, org.apache.qpid.server.store.Transaction.EnqueueRecord[] enqueues, org.apache.qpid.server.store.Transaction.DequeueRecord[] dequeues) throws StoreException {
    DatabaseEntry key = new DatabaseEntry();
    Xid xid = new Xid(format, globalId, branchId);
    XidBinding keyBinding = XidBinding.getInstance();
    keyBinding.objectToEntry(xid, key);
    DatabaseEntry value = new DatabaseEntry();
    PreparedTransaction preparedTransaction = new PreparedTransaction(enqueues, dequeues);
    PreparedTransactionBinding.objectToEntry(preparedTransaction, value);
    for (org.apache.qpid.server.store.Transaction.EnqueueRecord enqueue : enqueues) {
        StoredMessage storedMessage = enqueue.getMessage().getStoredMessage();
        if (storedMessage instanceof StoredBDBMessage) {
            ((StoredBDBMessage) storedMessage).store(txn);
        }
    }
    try {
        getXidDb().put(txn, key, value);
        return Collections.emptyList();
    } catch (RuntimeException e) {
        getLogger().error("Failed to write xid: " + e.getMessage(), e);
        throw getEnvironmentFacade().handleDatabaseException("Error writing xid to database", e);
    }
}
Also used : Xid(org.apache.qpid.server.txn.Xid) PreparedTransaction(org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction) PreparedTransaction(org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction) Transaction(com.sleepycat.je.Transaction) StoredMessage(org.apache.qpid.server.store.StoredMessage) XidBinding(org.apache.qpid.server.store.berkeleydb.tuple.XidBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 22 with StoredMessage

use of org.apache.qpid.server.store.StoredMessage in project qpid-broker-j by apache.

the class FlowToDiskTransactionObserverTest method testBreachLimitTwice.

public void testBreachLimitTwice() throws Exception {
    EnqueueableMessage<?> message1 = createMessage(MAX_UNCOMMITTED_IN_MEMORY_SIZE + 1);
    _flowToDiskMessageObserver.onMessageEnqueue(_transaction, message1);
    StoredMessage handle1 = message1.getStoredMessage();
    verify(handle1).flowToDisk();
    verify(_eventLogger, times(1)).message(same(_logSubject), any(LogMessage.class));
    _flowToDiskMessageObserver.onDischarge(_transaction);
    EnqueueableMessage<?> message2 = createMessage(MAX_UNCOMMITTED_IN_MEMORY_SIZE / 2);
    EnqueueableMessage<?> message3 = createMessage((MAX_UNCOMMITTED_IN_MEMORY_SIZE / 2) + 1);
    _flowToDiskMessageObserver.onMessageEnqueue(_transaction, message2);
    StoredMessage handle2 = message2.getStoredMessage();
    verify(handle2, never()).flowToDisk();
    _flowToDiskMessageObserver.onMessageEnqueue(_transaction, message3);
    StoredMessage handle3 = message3.getStoredMessage();
    verify(handle2).flowToDisk();
    verify(handle3).flowToDisk();
    verify(_eventLogger, times(2)).message(same(_logSubject), any(LogMessage.class));
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) LogMessage(org.apache.qpid.server.logging.LogMessage)

Example 23 with StoredMessage

use of org.apache.qpid.server.store.StoredMessage in project qpid-broker-j by apache.

the class AsynchronousMessageStoreRecovererTest method createTestMessage.

private StoredMessage<?> createTestMessage(final long messageNumber) {
    final StorableMessageMetaData metaData = new TestMessageMetaData(messageNumber, 0);
    final StoredMessage storedMessage = mock(StoredMessage.class);
    when(storedMessage.getMessageNumber()).thenReturn(messageNumber);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    return storedMessage;
}
Also used : StoredMessage(org.apache.qpid.server.store.StoredMessage) TestMessageMetaData(org.apache.qpid.server.store.TestMessageMetaData) StorableMessageMetaData(org.apache.qpid.server.store.StorableMessageMetaData)

Aggregations

StoredMessage (org.apache.qpid.server.store.StoredMessage)23 MessageReference (org.apache.qpid.server.message.MessageReference)5 ServerMessage (org.apache.qpid.server.message.ServerMessage)4 Transaction (org.apache.qpid.server.store.Transaction)4 UUID (java.util.UUID)3 LogMessage (org.apache.qpid.server.logging.LogMessage)3 HashMap (java.util.HashMap)2 ObjectToMimeContentConverter (org.apache.qpid.server.message.mimecontentconverter.ObjectToMimeContentConverter)2 Queue (org.apache.qpid.server.model.Queue)2 MessageMetaData_0_10 (org.apache.qpid.server.protocol.v0_10.MessageMetaData_0_10)2 MessageMetaData (org.apache.qpid.server.protocol.v0_8.MessageMetaData)2 ContentHeaderBody (org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody)2 MessagePublishInfo (org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo)2 ConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.ConvertedContentAndMimeType)2 MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType (org.apache.qpid.server.protocol.v1_0.MessageConverter_from_1_0.getAmqp0xConvertedContentAndMimeType)2 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)2 MessageStore (org.apache.qpid.server.store.MessageStore)2 StorableMessageMetaData (org.apache.qpid.server.store.StorableMessageMetaData)2 TransactionLogResource (org.apache.qpid.server.store.TransactionLogResource)2 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1