Exemplo n.º 1
0
        public override string ToString()
        {
            string result = string.Format("{0}:\n", this.GetType());

            result += string.Format("inner amqp message: \n{0}\n", AMQPMessageCloak.ToString(message));
            result += "NMS Fields = [\n";
            foreach (MemberInfo info in this.GetType().GetMembers())
            {
                if (info is PropertyInfo)
                {
                    PropertyInfo prop = info as PropertyInfo;
                    if (prop.GetGetMethod(true).IsPublic)
                    {
                        try
                        {
                            Object val = prop.GetValue(this, null);
                            if (val is IPrimitiveMap)
                            {
                                result += prop.Name + " = " + ConversionSupport.ToString(val as IPrimitiveMap) + ",\n";
                            }
                            else
                            {
                                result += string.Format("{0} = {1},\n", prop.Name, val);
                            }
                        }catch (TargetInvocationException tie)
                        {
                            Tracer.InfoFormat("Failed to invoke Member field accessor: {0}, cause: {1}", prop.Name, tie);
                        }
                    }
                }
            }
            result = result.Substring(0, result.Length - 2) + "\n]";
            return(result);
        }
Exemplo n.º 2
0
        public virtual IMessageCloak Copy()
        {
            IMessageCloak copy = null;

            switch (JMSMessageType)
            {
            case MessageSupport.JMS_TYPE_MSG:
                copy = new AMQPMessageCloak(connection);
                break;

            case MessageSupport.JMS_TYPE_BYTE:
                copy = new AMQPBytesMessageCloak(connection);
                break;

            case MessageSupport.JMS_TYPE_TXT:
                copy = new AMQPTextMessageCloak(connection);
                break;

            case MessageSupport.JMS_TYPE_MAP:
                copy = new AMQPMapMessageCloak(connection);
                break;

            case MessageSupport.JMS_TYPE_STRM:
                copy = new AMQPStreamMessageCloak(connection);
                break;

            case MessageSupport.JMS_TYPE_OBJ:
                copy = new AMQPObjectMessageCloak(connection, (this as AMQPObjectMessageCloak).Type);
                break;

            default:
                throw new NMSException("Fatal error Invalid JMS type.");
            }

            CopyInto(copy);
            return(copy);
        }
        private static IMessage CreateMessage(MessageConsumer consumer, Amqp.Message message)
        {
            IMessageCloak cloak = new AMQPMessageCloak(consumer, message);

            return(new Message(cloak));
        }