public async Task ProcessAsync(ProcessingCommand processingCommand, CommandExecutedResult executedResult) { using (await asyncLock.LockAsync()) { lastActiveOn = DateTime.UtcNow; try { if (processingCommand.QueueSequence == previousSequence + 1) { queue.TryRemove(processingCommand.QueueSequence); previousSequence = await ProcessWaitingAsync(processingCommand.QueueSequence); } else if (processingCommand.QueueSequence > previousSequence + 1) { waitingQueue[processingCommand.QueueSequence] = executedResult; } else { queue.TryRemove(processingCommand.QueueSequence); await executedResultProcessor.ProcessAsync(processingCommand, executedResult); waitingQueue.TryRemove(processingCommand.QueueSequence); } } catch (Exception ex) { logger.LogError(ex, $"队列处理失败。 [AggregateRootId = {aggregateRootId}, CommandType = {processingCommand.Command.GetType()}, CommandId = {processingCommand.Command.Id}]"); } } }
public Task ProcessAsync(ProcessingCommand processingCommand, CommandExecutedResult result) => Task.CompletedTask;