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);
}
}
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));
}
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;
}
Aggregations