/// <summary>
        /// Convert current brokered message object in a AMQP message
        /// </summary>
        /// <returns>AMQP message</returns>
        internal Message ToAmqpMessage()
        {
            Message message = null;

            if (this.bodyStream == null)
            {
                message = new Message();
            }
            else
            {
                byte[] buffer = new byte[this.bodyStream.Length];
                this.bodyStream.Read(buffer, 0, buffer.Length);
                message = new Message()
                {
                    BodySection = new Data()
                    {
                        Binary = buffer
                    }
                };
            }

            if (message.Properties == null)
            {
                message.Properties = new Properties();
            }

            this.MessageId = NewMessageId();

            MessageConverter.BrokeredMessageToAmqpMessage(this, message);
            return(message);
        }