public static TransportMessage ToTransportMessage(this TransportMessageDto dto, Dictionary<string, string> headers)
        {
            Address replyToAddress = Address.Parse(dto.ReplyToAddress);
            byte[] body = Encoding.UTF8.GetBytes(dto.Body);

            var message = new TransportMessage(dto.MessageId, dto.CorrelationId, replyToAddress, TimeSpan.MaxValue, headers, body);

            message.Headers.Remove(HeaderKeys.FirstLevelRetryCount);
            message.Headers.Remove(HeaderKeys.SecondLevelRetryCount);
            message.Headers.Remove(HeaderKeys.FailureDetails);

            return message;
        }
Пример #2
0
        public TimeoutData(TransportMessage transportMessage)
        {
            if (!transportMessage.Headers.ContainsKey(HeaderKeys.TimeoutExpire))
            {
                throw new InvalidOperationException("Non-timeout message arrived at the timeout manager, id:" + transportMessage.MessageId);
            }

            if (!transportMessage.Headers.ContainsKey(HeaderKeys.RouteExpiredTimeoutTo))
            {
                throw new InvalidOperationException("No routing address provided for deferred message, id:" + transportMessage.MessageId);
            }

            DestinationAddress = transportMessage.Headers[HeaderKeys.RouteExpiredTimeoutTo];
            MessageId = transportMessage.MessageId;
            Body = transportMessage.Body;
            Expires = transportMessage.Headers[HeaderKeys.TimeoutExpire].ToUtcDateTime();
            CorrelationId = transportMessage.CorrelationId;
            Headers = transportMessage.Headers;
        }
Пример #3
0
        protected virtual void MessageReceived(TransportMessage transportMessage)
        {
            Logger.Debug("Message {0} with correlation Id {1} received", transportMessage.MessageId, transportMessage.CorrelationId);

            using (IContainer childContainer = container.BeginLifetimeScope())
            {
                try
                {
                    ServiceLocator.Current.SetCurrentLifetimeScope(childContainer);
                    var incomingContext = new IncomingMessageContext(transportMessage, childContainer);
                    ProcessMessage(incomingContext);
                }
                finally
                {
                    ServiceLocator.Current.SetCurrentLifetimeScope(null);
                }
            }
        }