public static Message AsAzureServiceBusMessage(this OutboundBrokeredMessage brokeredMessage)
        {
            var message = new Message(brokeredMessage.Body)
            {
                CorrelationId    = brokeredMessage.GetCorrelationId(),
                ContentType      = brokeredMessage.GetContentType(),
                Label            = brokeredMessage.GetSubject(),
                ReplyTo          = brokeredMessage.GetReplyToAddress(),
                ReplyToSessionId = brokeredMessage.GetReplyToGroupId(),
                SessionId        = brokeredMessage.GetGroupId(),
                PartitionKey     = brokeredMessage.GetPartitionKey(),
                ViaPartitionKey  = brokeredMessage.GetViaPartitionKey(),
                To = brokeredMessage.GetToAddress()
            }
            .WithHashedBodyMessageId(brokeredMessage.MessageId)
            .WithUserProperties(brokeredMessage.ApplicationProperties);

            if (brokeredMessage.GetTimeToLive() != null)
            {
                message.TimeToLive = brokeredMessage.GetTimeToLive().Value;
            }

            if (brokeredMessage.GetScheduledEnqueueTimeUtc() != null)
            {
                message.ScheduledEnqueueTimeUtc = brokeredMessage.GetScheduledEnqueueTimeUtc().Value;
            }

            return(message);
        }
        public static Message AsAzureServiceBusMessage(this OutboundBrokeredMessage brokeredMessage)
        {
            var message = new Message(brokeredMessage.Body)
            {
                MessageId        = string.IsNullOrWhiteSpace(brokeredMessage.MessageId) ? Guid.NewGuid().ToString() : brokeredMessage.MessageId,
                CorrelationId    = brokeredMessage.CorrelationId,
                ContentType      = brokeredMessage.ContentType,
                Label            = brokeredMessage.GetSubject(),
                ReplyTo          = brokeredMessage.GetReplyToAddress(),
                ReplyToSessionId = brokeredMessage.GetReplyToGroupId(),
                SessionId        = brokeredMessage.GetGroupId(),
                PartitionKey     = brokeredMessage.GetPartitionKey(),
                ViaPartitionKey  = brokeredMessage.GetViaPartitionKey(),
                To = brokeredMessage.GetToAddress()
            }
            .WithUserProperties(brokeredMessage.MessageContext);

            if (brokeredMessage.GetTimeToLive() != null)
            {
                message.TimeToLive = brokeredMessage.GetTimeToLive().Value;
            }

            if (brokeredMessage.GetScheduledEnqueueTimeUtc() != null)
            {
                message.ScheduledEnqueueTimeUtc = brokeredMessage.GetScheduledEnqueueTimeUtc().Value;
            }

            return(message);
        }