use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testDeleteEntryPersistent.
@Test
public void testDeleteEntryPersistent() throws Exception {
long messageNumber = 1L;
final MessageEnqueueRecord record = mock(MessageEnqueueRecord.class);
when(record.getMessageNumber()).thenReturn(messageNumber);
when(record.getQueueId()).thenReturn(_queue.getId());
deleteEntry(messageNumber, record);
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class AsyncAutoCommitTransaction method enqueue.
@Override
public void enqueue(TransactionLogResource queue, EnqueueableMessage message, EnqueueAction postTransactionAction) {
Transaction txn = null;
try {
ListenableFuture<Void> future;
final MessageEnqueueRecord enqueueRecord;
if (queue.getMessageDurability().persist(message.isPersistent())) {
LOGGER.debug("Enqueue of message number {} to transaction log. Queue : {}", message.getMessageNumber(), queue.getName());
txn = _messageStore.newTransaction();
enqueueRecord = txn.enqueueMessage(queue, message);
future = txn.commitTranAsync(null);
txn = null;
} else {
future = Futures.immediateFuture(null);
enqueueRecord = null;
}
final EnqueueAction underlying = postTransactionAction;
addEnqueueFuture(future, new Action() {
@Override
public void postCommit() {
underlying.postCommit(enqueueRecord);
}
@Override
public void onRollback() {
underlying.onRollback();
}
}, message.isPersistent());
postTransactionAction = null;
} finally {
final EnqueueAction underlying = postTransactionAction;
rollbackIfNecessary(new Action() {
@Override
public void postCommit() {
}
@Override
public void onRollback() {
if (underlying != null) {
underlying.onRollback();
}
}
}, txn);
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class LocalTransaction method enqueue.
@Override
public void enqueue(Collection<? extends BaseQueue> queues, EnqueueableMessage message, EnqueueAction postTransactionAction) {
sync();
_outstandingWork = true;
initTransactionStartTimeIfNecessaryAndAdvanceUpdateTime();
_transactionObserver.onMessageEnqueue(this, message);
try {
final MessageEnqueueRecord[] records = new MessageEnqueueRecord[queues.size()];
int i = 0;
for (BaseQueue queue : queues) {
if (queue.getMessageDurability().persist(message.isPersistent())) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enqueue of message number " + message.getMessageNumber() + " to transaction log. Queue : " + queue.getName());
}
beginTranIfNecessary();
records[i] = _transaction.enqueueMessage(queue, message);
}
i++;
}
if (postTransactionAction != null) {
final EnqueueAction underlying = postTransactionAction;
_postTransactionActions.add(new Action() {
@Override
public void postCommit() {
underlying.postCommit(records);
}
@Override
public void onRollback() {
underlying.onRollback();
}
});
postTransactionAction = null;
}
} catch (RuntimeException e) {
if (postTransactionAction != null) {
final EnqueueAction underlying = postTransactionAction;
_postTransactionActions.add(new Action() {
@Override
public void postCommit() {
}
@Override
public void onRollback() {
underlying.onRollback();
}
});
}
tidyUpOnError(e);
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class AutoCommitTransaction method dequeue.
@Override
public void dequeue(Collection<MessageInstance> queueEntries, Action postTransactionAction) {
Transaction txn = null;
try {
for (MessageInstance entry : queueEntries) {
MessageEnqueueRecord enqueueRecord = entry.getEnqueueRecord();
if (enqueueRecord != null) {
LOGGER.debug("Dequeue of message number {} from transaction log. Queue : {}", enqueueRecord.getMessageNumber(), enqueueRecord.getQueueId());
if (txn == null) {
txn = _messageStore.newTransaction();
}
txn.dequeueMessage(enqueueRecord);
}
}
if (txn != null) {
txn.commitTran();
txn = null;
}
postTransactionAction.postCommit();
postTransactionAction = null;
} finally {
rollbackIfNecessary(postTransactionAction, txn);
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class RingOverflowPolicyTest method enqueueTestMessage.
private ServerMessage<?> enqueueTestMessage(final Queue<?> queue) {
final ServerMessage<?> message = createMessage(_messageId.incrementAndGet(), queue.getName());
final MessageEnqueueRecord record = createMessageEnqueueRecord(queue.getId(), message.getMessageNumber());
queue.enqueue(message, null, record);
return message;
}
Aggregations