protected AmqpNmsMessageFacade CreateReceivedMessageFacade(IAmqpConsumer consumer, global::Amqp.Message message)
        {
            AmqpNmsMessageFacade facade = new AmqpNmsMessageFacade();

            facade.Initialize(consumer, message);
            return(facade);
        }
        public static INmsMessageFacade DecodeMessage(IAmqpConsumer consumer, global::Amqp.Message amqpMessage)
        {
            // First we try the easy way, if the annotation is there we don't have to work hard.
            AmqpNmsMessageFacade result = CreateFromMsgAnnotation(amqpMessage.MessageAnnotations);

            if (result == null)
            {
                // Next, match specific section structures and content types
                result = CreateWithoutAnnotation(amqpMessage.BodySection, amqpMessage.Properties);
            }

            if (result != null)
            {
                result.Initialize(consumer, amqpMessage);
                return(result);
            }

            throw new NMSException("Could not create a NMS message from incoming message");
        }