protected override MessageBase CopyImpl(MessageBase clone)
 {
     // Instantiate the clone, if a derived type hasn't already.
     if (clone == null) clone = new AsyncMessage();
     // Allow base type(s) to copy their state into the new clone.
     base.CopyImpl(clone);
     // Copy our state into the clone.
     ((AsyncMessage)clone)._correlationId = _correlationId;
     return clone;
 }
示例#2
0
 protected override MessageBase CopyImpl(MessageBase clone)
 {
     // Instantiate the clone, if a derived type hasn't already.
     if (clone == null)
     {
         clone = new AsyncMessage();
     }
     // Allow base type(s) to copy their state into the new clone.
     base.CopyImpl(clone);
     // Copy our state into the clone.
     ((AsyncMessage)clone)._correlationId = _correlationId;
     return(clone);
 }
示例#3
0
        private AsyncMessage ConvertMsmqMessage(Message message)
        {
            AsyncMessage asyncMessage = new AsyncMessage();
            asyncMessage.body = message.Body;
            asyncMessage.destination = DestinationDefinition.Id;
            asyncMessage.clientId = Guid.NewGuid().ToString("D");
            asyncMessage.messageId = Guid.NewGuid().ToString("D");
            asyncMessage.timestamp = Environment.TickCount;

            asyncMessage.headers["MSMQId"] = message.Id;
            asyncMessage.headers["MSMQLabel"] = message.Label;
            //asyncMessage.headers["MSMQBody"] = message.Body;
            if (message.Body != null)
            {
                PropertyInfo[] propertyInfos = message.Body.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
                foreach (PropertyInfo pi in propertyInfos)
                {
                    if (pi.GetGetMethod() != null && pi.GetGetMethod().GetParameters().Length == 0)
                        asyncMessage.headers[pi.Name] = pi.GetValue(message.Body, null);
                }
                FieldInfo[] fieldInfos = message.Body.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
                foreach (FieldInfo fi in fieldInfos)
                {
                    asyncMessage.headers[fi.Name] = fi.GetValue(message.Body);
                }
            }
            return asyncMessage;
        }
示例#4
0
 /// <summary>
 /// Send message to output stream and handle exceptions.
 /// </summary>
 /// <param name="message"></param>
 private void DoPushMessage(AsyncMessage message)
 {
     try
     {
         _msgOut.PushMessage(message);
         if (message is RtmpMessage)
         {
             IRtmpEvent body = ((RtmpMessage)message).body;
             if (body is IStreamData && ((IStreamData)body).Data != null)
             {
                 _bytesSent += ((IStreamData)body).Data.Limit;
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Error while pushing message.", ex);
     }
 }
示例#5
0
        private AsyncMessage convertToFlexMessage(IMessage message, String clientId)
        {
            AsyncMessage asyncMessage = new AsyncMessage();

            if (message is ActiveMQObjectMessage)
            {
                ActiveMQObjectMessage objectMessage = ((ActiveMQObjectMessage)message);
                asyncMessage.body = objectMessage.Body;
            }
            else if (message is ActiveMQTextMessage)
            {
                asyncMessage.body = ((ActiveMQTextMessage)message).Text;
            }

            try
            {
                asyncMessage.destination = this.DestinationDefinition.Id;
                asyncMessage.clientId = clientId;
                asyncMessage.messageId = message.NMSMessageId;
                asyncMessage.timestamp = message.NMSTimestamp.Ticks;
                asyncMessage.correlationId = message.NMSCorrelationID;

                foreach (String key in message.Properties.Keys)
                {
                    asyncMessage.headers.Add(key, message.Properties[key]);
                }
            }
            catch (Exception ex)
            {
                log.Error("Error while converting to Flex Message", ex);
            }

            return asyncMessage;
        }