use of org.apache.qpid.server.queue.BaseQueue in project qpid-broker-j by apache.
the class AutoCommitTransactionTest 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 BaseQueue queue = createTestAMQQueue(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() {
if (hasRecord) {
return mock(MessageEnqueueRecord.class);
} else {
return null;
}
}
});
}
return queueEntries;
}
use of org.apache.qpid.server.queue.BaseQueue in project qpid-broker-j by apache.
the class LocalTransactionTest method createQueue.
private BaseQueue createQueue(final boolean durable) {
BaseQueue queue = mock(BaseQueue.class);
when(queue.getMessageDurability()).thenReturn(durable ? MessageDurability.DEFAULT : MessageDurability.NEVER);
return queue;
}
use of org.apache.qpid.server.queue.BaseQueue 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);
}
}
Aggregations