public void ScheduleMessage(X processingMessage)
 {
     Task.Factory.StartNew(obj =>
     {
         _messageHandler.HandleAsync((X)obj);
     }, processingMessage);
 }
Пример #2
0
        public async Task Run()
        {
            _lastActiveTime = DateTime.Now;
            X processingMessage = null;

            try
            {
                if (_messageQueue.TryDequeue(out processingMessage))
                {
                    await _messageHandler.HandleAsync(processingMessage);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message mailbox run has unknown exception, routingKey: {0}, commandId: {1}", _routingKey, processingMessage != null ? processingMessage.Message.Id : string.Empty), ex);
                Thread.Sleep(1);
            }
            finally
            {
                if (processingMessage == null)
                {
                    Exit();
                    if (!_messageQueue.IsEmpty)
                    {
                        TryRun();
                    }
                }
            }
        }
Пример #3
0
        private void RetryConcurrentCommand(EventCommittingContext context)
        {
            var processingCommand = context.ProcessingCommand;
            var command           = processingCommand.Message;

            processingCommand.IncreaseConcurrentRetriedCount();
            processingCommand.CommandExecuteContext.Clear();
            _logger.InfoFormat("Begin to retry command as it meets the concurrent conflict. commandType:{0}, commandId:{1}, aggregateRootId:{2}, retried count:{3}.", command.GetType().Name, command.Id, processingCommand.Message.AggregateRootId, processingCommand.ConcurrentRetriedCount);
            _processingCommandHandler.HandleAsync(processingCommand);
        }
Пример #4
0
        public void Run()
        {
            X processingMessage = null;

            try
            {
                if (_messageQueue.TryDequeue(out processingMessage))
                {
                    _messageHandler.HandleAsync(processingMessage);
                }
            }
            finally
            {
                if (processingMessage == null)
                {
                    ExitHandlingMessage();
                    if (!_messageQueue.IsEmpty)
                    {
                        RegisterForExecution();
                    }
                }
            }
        }