use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class LocalTransaction method dequeue.
@Override
public void dequeue(Collection<MessageInstance> queueEntries, Action postTransactionAction) {
sync();
_outstandingWork = true;
_postTransactionActions.add(postTransactionAction);
initTransactionStartTimeIfNecessaryAndAdvanceUpdateTime();
try {
for (MessageInstance entry : queueEntries) {
final MessageEnqueueRecord record = entry.getEnqueueRecord();
if (record != null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Dequeue of message number " + record.getMessageNumber() + " from transaction log. Queue : " + record.getQueueId());
}
beginTranIfNecessary();
_transaction.dequeueMessage(record);
}
}
} catch (RuntimeException e) {
tidyUpOnError(e);
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class LocalTransaction method enqueue.
@Override
public void enqueue(TransactionLogResource queue, EnqueueableMessage message, EnqueueAction postTransactionAction) {
sync();
_outstandingWork = true;
initTransactionStartTimeIfNecessaryAndAdvanceUpdateTime();
_transactionObserver.onMessageEnqueue(this, message);
if (queue.getMessageDurability().persist(message.isPersistent())) {
try {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Enqueue of message number " + message.getMessageNumber() + " to transaction log. Queue : " + queue.getName());
}
beginTranIfNecessary();
final MessageEnqueueRecord record = _transaction.enqueueMessage(queue, message);
if (postTransactionAction != null) {
final EnqueueAction underlying = postTransactionAction;
_postTransactionActions.add(new Action() {
@Override
public void postCommit() {
underlying.postCommit(record);
}
@Override
public void onRollback() {
underlying.onRollback();
}
});
}
} 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);
}
} else {
if (postTransactionAction != null) {
final EnqueueAction underlying = postTransactionAction;
_postTransactionActions.add(new Action() {
@Override
public void postCommit() {
underlying.postCommit((MessageEnqueueRecord) null);
}
@Override
public void onRollback() {
underlying.onRollback();
}
});
}
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class AutoCommitTransaction method enqueue.
@Override
public void enqueue(Collection<? extends BaseQueue> queues, EnqueueableMessage message, EnqueueAction postTransactionAction) {
Transaction txn = null;
try {
MessageEnqueueRecord[] enqueueRecords = new MessageEnqueueRecord[queues.size()];
int i = 0;
for (BaseQueue queue : queues) {
if (queue.getMessageDurability().persist(message.isPersistent())) {
LOGGER.debug("Enqueue of message number {} to transaction log. Queue : {}", message.getMessageNumber(), queue.getName());
if (txn == null) {
txn = _messageStore.newTransaction();
}
enqueueRecords[i] = txn.enqueueMessage(queue, message);
}
i++;
}
if (txn != null) {
txn.commitTran();
txn = null;
}
if (postTransactionAction != null) {
postTransactionAction.postCommit(enqueueRecords);
}
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 DtxBranch method prePrepareTransaction.
public void prePrepareTransaction() throws StoreException {
_transaction = _dtxRegistry.getMessageStore().newTransaction();
for (final EnqueueRecord enqueue : _enqueueRecords) {
final MessageEnqueueRecord record;
if (enqueue.isDurable()) {
record = _transaction.enqueueMessage(enqueue.getResource(), enqueue.getMessage());
} else {
record = null;
}
enqueue.getEnqueueAction().performAction(record);
}
for (DequeueRecord dequeue : _dequeueRecords) {
_transaction.dequeueMessage(dequeue.getEnqueueRecord());
}
}
use of org.apache.qpid.server.store.MessageEnqueueRecord in project qpid-broker-j by apache.
the class AutoCommitTransaction method enqueue.
@Override
public void enqueue(TransactionLogResource queue, EnqueueableMessage message, EnqueueAction postTransactionAction) {
Transaction txn = null;
try {
final MessageEnqueueRecord record;
if (queue.getMessageDurability().persist(message.isPersistent())) {
LOGGER.debug("Enqueue of message number {} to transaction log. Queue : {}", message.getMessageNumber(), queue.getName());
txn = _messageStore.newTransaction();
record = txn.enqueueMessage(queue, message);
txn.commitTran();
txn = null;
} else {
record = null;
}
if (postTransactionAction != null) {
postTransactionAction.postCommit(record);
}
postTransactionAction = null;
} finally {
final EnqueueAction underlying = postTransactionAction;
rollbackIfNecessary(new Action() {
@Override
public void postCommit() {
}
@Override
public void onRollback() {
if (underlying != null) {
underlying.onRollback();
}
}
}, txn);
}
}
Aggregations