NServiceBus.MsmqUtilities.ExtractHeaders C# (CSharp) Method

ExtractHeaders() public static method

public static ExtractHeaders ( Message msmqMessage ) : string>.Dictionary
msmqMessage Message
return string>.Dictionary
        public static Dictionary<string, string> ExtractHeaders(Message msmqMessage)
        {
            var headers = DeserializeMessageHeaders(msmqMessage);

            //note: we can drop this line when we no longer support interop btw v3 + v4
            if (msmqMessage.ResponseQueue != null)
            {
                headers[Headers.ReplyToAddress] = GetIndependentAddressForQueue(msmqMessage.ResponseQueue).ToString();
            }

            if (Enum.IsDefined(typeof(MessageIntentEnum), msmqMessage.AppSpecific))
            {
                headers[Headers.MessageIntent] = ((MessageIntentEnum)msmqMessage.AppSpecific).ToString();
            }

            headers[Headers.CorrelationId] = GetCorrelationId(msmqMessage, headers);

            return headers;
        }

Usage Example

Exemplo n.º 1
0
        protected bool TryExtractHeaders(Message message, out Dictionary <string, string> headers)
        {
            try
            {
                headers = MsmqUtilities.ExtractHeaders(message);
                return(true);
            }
            catch (Exception ex)
            {
                var error = $"Message '{message.Id}' has corrupted headers";

                Logger.Warn(error, ex);

                headers = null;
                return(false);
            }
        }