use of org.apache.qpid.server.store.Transaction 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.Transaction 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);
}
Aggregations