use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class LocalTransactionTest method createTestQueueEntries.
private Collection<MessageInstance> createTestQueueEntries(boolean[] queueDurableFlags, boolean[] messagePersistentFlags) {
Collection<MessageInstance> queueEntries = new ArrayList<MessageInstance>();
assertTrue("Boolean arrays must be the same length", queueDurableFlags.length == messagePersistentFlags.length);
for (int i = 0; i < queueDurableFlags.length; i++) {
final TransactionLogResource queue = createQueue(queueDurableFlags[i]);
final ServerMessage message = createTestMessage(messagePersistentFlags[i]);
final boolean hasRecord = queueDurableFlags[i] && messagePersistentFlags[i];
queueEntries.add(new MockMessageInstance() {
@Override
public ServerMessage getMessage() {
return message;
}
@Override
public TransactionLogResource getOwningResource() {
return queue;
}
@Override
public MessageEnqueueRecord getEnqueueRecord() {
return hasRecord ? mock(MessageEnqueueRecord.class) : null;
}
});
}
return queueEntries;
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method enqueueMessages.
private List<MessageEnqueueRecord> enqueueMessages(final MessageStore store, final TransactionLogResource resource, final int numberOfMessages) {
final Transaction transaction = store.newTransaction();
final String name = resource.getName();
final List<MessageEnqueueRecord> records = LongStream.rangeClosed(1, numberOfMessages).boxed().map(i -> {
final InternalMessage m = addTestMessage(store, name, i + "");
return transaction.enqueueMessage(resource, m);
}).collect(Collectors.toList());
transaction.commitTran();
return records;
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method testEnqueueTransactionCommitAsync.
@Test
public void testEnqueueTransactionCommitAsync() throws Exception {
final String queueName = getTestName();
final UUID transactionalLogId = UUID.randomUUID();
final MessageStore store = getStore();
final TransactionLogResource transactionalLog = mockTransactionLogResource(transactionalLogId, queueName);
final InternalMessage message = addTestMessage(store, queueName, "test");
final Transaction transaction = store.newTransaction();
final MessageEnqueueRecord record = transaction.enqueueMessage(transactionalLog, message);
assertNotNull("Message enqueue record should not be null", record);
assertEquals("Unexpected queue id", transactionalLogId, record.getQueueId());
assertEquals("Unexpected message number", message.getMessageNumber(), record.getMessageNumber());
final ListenableFuture<Void> future = transaction.commitTranAsync(null);
future.get(1000, TimeUnit.MILLISECONDS);
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method testDequeueTransactionCommitAsync.
@Test
public void testDequeueTransactionCommitAsync() throws Exception {
final String queueName = getTestName();
final UUID transactionalLogId = UUID.randomUUID();
final MessageStore store = getStore();
final TransactionLogResource transactionalLog = mockTransactionLogResource(transactionalLogId, queueName);
final InternalMessage message = addTestMessage(store, queueName, "test2");
final Transaction enqueueTransaction = store.newTransaction();
MessageEnqueueRecord record = enqueueTransaction.enqueueMessage(transactionalLog, message);
enqueueTransaction.commitTran();
final Transaction dequeueTransaction = store.newTransaction();
dequeueTransaction.dequeueMessage(record);
final ListenableFuture<Void> future = dequeueTransaction.commitTranAsync(null);
future.get(1000, TimeUnit.MILLISECONDS);
}
Aggregations