private void AddProblemAggregateMailBoxToDict(ProcessingEventMailBox mailbox) { if (_problemAggregateRootMailBoxDict.TryAdd(mailbox.AggregateRootId, mailbox)) { _logger.WarnFormat("Added problem aggregate mailbox, aggregateRootTypeName: {0}, aggregateRootId: {1}", mailbox.AggregateRootTypeName, mailbox.AggregateRootId); } }
private void TryToRefreshAggregateMailBoxNextExpectingEventVersion(ProcessingEventMailBox processingEventMailBox) { if (_refreshingAggregateRootDict.TryAdd(processingEventMailBox.AggregateRootId, true)) { GetAggregateRootLatestPublishedEventVersion(processingEventMailBox, 0); } }
private void AddToRefreshAggregateMailBoxToDict(ProcessingEventMailBox mailbox) { if (_toRefreshAggregateRootMailBoxDict.TryAdd(mailbox.AggregateRootId, mailbox)) { _logger.InfoFormat("Added toRefreshPublishedVersion aggregate mailbox, aggregateRootTypeName: {0}, aggregateRootId: {1}", mailbox.AggregateRootTypeName, mailbox.AggregateRootId); TryToRefreshAggregateMailBoxNextExpectingEventVersion(mailbox); } }
private void TryToRefreshAggregateMailBoxNextExpectingEventVersion(ProcessingEventMailBox processingEventMailBox) { if (_refreshingAggregateRootDict.TryAdd(processingEventMailBox.AggregateRootId, true)) { Task.Factory.StartNew(async() => { var latestPublishedEventVersion = await GetAggregateRootLatestPublishedEventVersion(processingEventMailBox.AggregateRootTypeName, processingEventMailBox.AggregateRootId); processingEventMailBox.SetNextExpectingEventVersion(latestPublishedEventVersion + 1); _refreshingAggregateRootDict.TryRemove(processingEventMailBox.AggregateRootId, out bool removed); }); } }
private void GetAggregateRootLatestPublishedEventVersion(ProcessingEventMailBox processingEventMailBox, int retryTimes) { _ioHelper.TryAsyncActionRecursively("GetAggregateRootLatestPublishedEventVersion", () => _publishedVersionStore.GetPublishedVersionAsync(Name, processingEventMailBox.AggregateRootTypeName, processingEventMailBox.AggregateRootId), currentRetryTimes => GetAggregateRootLatestPublishedEventVersion(processingEventMailBox, currentRetryTimes), result => { processingEventMailBox.SetNextExpectingEventVersion(result + 1); _refreshingAggregateRootDict.TryRemove(processingEventMailBox.AggregateRootId, out bool removed); }, () => string.Format("_publishedVersionStore.GetPublishedVersionAsync has unknown exception, aggregateRootTypeName: {0}, aggregateRootId: {1}", processingEventMailBox.AggregateRootTypeName, processingEventMailBox.AggregateRootId), null, retryTimes, true); }
private bool IsMailBoxAllowRemove(ProcessingEventMailBox mailbox) { return(mailbox.IsInactive(_timeoutSeconds) && !mailbox.IsRunning && mailbox.TotalUnHandledMessageCount == 0 && mailbox.WaitingMessageCount == 0); }
private void AddProblemAggregateMailBoxToDict(ProcessingEventMailBox mailbox) { _problemAggregateRootMailBoxDict.TryAdd(mailbox.AggregateRootId, mailbox); }