https://issues.apache.org/jira/browse/AMQ-6164 - allow journal write batching on a single destination

This commit is contained in:
gtully 2016-02-09 12:49:53 +00:00
parent 90726a60af
commit 499e39e52c
4 changed files with 34 additions and 39 deletions

View File

@ -829,8 +829,6 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
producerExchange.incrementSend();
do {
checkUsage(context, producerExchange, message);
sendLock.lockInterruptibly();
try {
message.getMessageId().setBrokerSequenceId(getDestinationSequenceId());
if (store != null && message.isPersistent()) {
message.getMessageId().setFutureOrSequenceLong(null);
@ -854,9 +852,6 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
if(tryOrderedCursorAdd(message, context)) {
break;
}
} finally {
sendLock.unlock();
}
} while (started.get());
if (store == null || (!context.isInTransaction() && !message.isPersistent())) {

View File

@ -59,13 +59,13 @@ public class MemoryMessageStore extends AbstractMessageStore {
synchronized (messageTable) {
messageTable.put(message.getMessageId(), message);
incMessageStoreStatistics(getMessageStoreStatistics(), message);
}
message.incrementReferenceCount();
message.getMessageId().setFutureOrSequenceLong(sequenceId++);
if (indexListener != null) {
indexListener.onAdd(new IndexListener.MessageContext(context, message, null));
}
}
}
// public void addMessageReference(ConnectionContext context,MessageId
// messageId,long expirationTime,String messageRef)

View File

@ -326,10 +326,9 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter {
return task;
}
// with asyncTaskMap locked
protected void addQueueTask(KahaDBMessageStore store, StoreQueueTask task) throws IOException {
synchronized (store.asyncTaskMap) {
store.asyncTaskMap.put(new AsyncJobKey(task.getMessage().getMessageId(), store.getDestination()), task);
}
this.queueExecutor.execute(task);
}
@ -390,10 +389,12 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter {
message.getMessageId().setFutureOrSequenceLong(future);
message.setRecievedByDFBridge(true); // flag message as concurrentStoreAndDispatch
result.aquireLocks();
synchronized (asyncTaskMap) {
addQueueTask(this, result);
if (indexListener != null) {
indexListener.onAdd(new IndexListener.MessageContext(context, message, null));
}
}
return future;
} else {
return super.asyncAddQueueMessage(context, message);

View File

@ -758,7 +758,7 @@ class LevelDBStore extends LockableServiceSupport with BrokerServiceAware with P
uow.addCompleteListener({
message.decrementReferenceCount()
})
val sequence = lastSeq.synchronized {
lastSeq.synchronized {
val seq = lastSeq.incrementAndGet()
message.getMessageId.setFutureOrSequenceLong(seq);
// null context on xa recovery, we want to bypass the cursor & pending adds as it will be reset
@ -768,9 +768,8 @@ class LevelDBStore extends LockableServiceSupport with BrokerServiceAware with P
def run(): Unit = pendingCursorAdds.synchronized { pendingCursorAdds.remove(seq) }
}))
}
seq
uow.enqueue(key, seq, message, delay)
}
uow.enqueue(key, sequence, message, delay)
}
override def asyncAddQueueMessage(context: ConnectionContext, message: Message) = asyncAddQueueMessage(context, message, false)