Пример #1
0
        private void HandleMessageAsync(DisptachingMessage dispatchingMessage, IMessageHandlerProxy handlerProxy, int handlerTypeCode, int messageTypeCode, int retryTimes)
        {
            var message = dispatchingMessage.Message;

            _ioHelper.TryAsyncActionRecursively <AsyncTaskResult>("HandleMessageAsync",
                                                                  () => handlerProxy.HandleAsync(message),
                                                                  currentRetryTimes => HandleMessageAsync(dispatchingMessage, handlerProxy, handlerTypeCode, messageTypeCode, currentRetryTimes),
                                                                  result =>
            {
                var messageHandleRecord = new MessageHandleRecord
                {
                    MessageId       = message.Id,
                    HandlerTypeCode = handlerTypeCode,
                    MessageTypeCode = messageTypeCode,
                    Timestamp       = DateTime.Now
                };
                var sequenceMessage = message as ISequenceMessage;
                if (sequenceMessage != null)
                {
                    messageHandleRecord.AggregateRootTypeCode = sequenceMessage.AggregateRootTypeCode;
                    messageHandleRecord.AggregateRootId       = sequenceMessage.AggregateRootId;
                    messageHandleRecord.Version = sequenceMessage.Version;
                }

                AddMessageHandledRecordAsync(dispatchingMessage, messageHandleRecord, handlerProxy.GetInnerHandler().GetType(), handlerTypeCode, 0);
            },
                                                                  () => string.Format("[messageId:{0}, messageType:{1}, handlerType:{2}]", message.Id, message.GetType().Name, handlerProxy.GetInnerHandler().GetType().Name),
                                                                  null,
                                                                  retryTimes,
                                                                  true);
        }
Пример #2
0
        private void HandleMessageAsync(DisptachingMessage dispatchingMessage, IMessageHandlerProxy handlerProxy, int handlerTypeCode, int messageTypeCode, int retryTimes)
        {
            var message = dispatchingMessage.Message;

            _ioHelper.TryAsyncActionRecursively<AsyncTaskResult>("HandleMessageAsync",
            () => handlerProxy.HandleAsync(message),
            currentRetryTimes => HandleMessageAsync(dispatchingMessage, handlerProxy, handlerTypeCode, messageTypeCode, currentRetryTimes),
            result =>
            {
                var messageHandleRecord = new MessageHandleRecord
                {
                    MessageId = message.Id,
                    HandlerTypeCode = handlerTypeCode,
                    MessageTypeCode = messageTypeCode,
                    Timestamp = DateTime.Now
                };
                var sequenceMessage = message as ISequenceMessage;
                if (sequenceMessage != null)
                {
                    messageHandleRecord.AggregateRootTypeCode = sequenceMessage.AggregateRootTypeCode;
                    messageHandleRecord.AggregateRootId = sequenceMessage.AggregateRootId;
                    messageHandleRecord.Version = sequenceMessage.Version;
                }

                AddMessageHandledRecordAsync(dispatchingMessage, messageHandleRecord, handlerProxy.GetInnerHandler().GetType(), handlerTypeCode, 0);
            },
            () => string.Format("[messageId:{0}, messageType:{1}, handlerType:{2}]", message.Id, message.GetType().Name, handlerProxy.GetInnerHandler().GetType().Name),
            null,
            retryTimes,
            true);
        }