private static AmqpNmsMessageFacade CreateFromMsgAnnotation()

in src/NMS.AMQP/Provider/Amqp/Message/AmqpCodec.cs [47:77]


        private static AmqpNmsMessageFacade CreateFromMsgAnnotation(global::Amqp.Message message)
        {
            object annotation = message.MessageAnnotations?[SymbolUtil.JMSX_OPT_MSG_TYPE];

            if (annotation != null)
            {
                sbyte type = Convert.ToSByte(annotation);
                switch (type)
                {
                    case MessageSupport.JMS_TYPE_MSG:
                        return new AmqpNmsMessageFacade();
                    case MessageSupport.JMS_TYPE_TXT:
                        return new AmqpNmsTextMessageFacade();
                    case MessageSupport.JMS_TYPE_STRM:
                        return new AmqpNmsStreamMessageFacade();
                    case MessageSupport.JMS_TYPE_MAP:
                        return new AmqpNmsMapMessageFacade();
                    case MessageSupport.JMS_TYPE_BYTE:
                    // Java serialized objects should be treated as bytes messages
                    // as we cannot deserialize them in .NET world
                    case MessageSupport.JMS_TYPE_OBJ when IsContentType(SymbolUtil.SERIALIZED_JAVA_OBJECT_CONTENT_TYPE, GetContentType(message.Properties)):
                        return new AmqpNmsBytesMessageFacade();
                    case MessageSupport.JMS_TYPE_OBJ:
                        return new AmqpNmsObjectMessageFacade();
                    default:
                        throw new NMSException("Invalid Message Type annotation value found in message: " + annotation);
                }
            }

            return null;
        }