public void MsgQueueSerialization_Test() { QueuedMsgInfo msgInfo; QueuedMsg msg, msgTest; MsgQueueCmd cmd; msg = new QueuedMsg(); msg.TargetEP = "logical://target"; msg.ResponseEP = "logical://response"; msg.SessionID = Helper.NewGuid(); msg.SendTime = new DateTime(2000, 1, 1); msg.ExpireTime = new DateTime(2000, 1, 2); msg.Body = "Hello World!"; cmd = new MsgQueueCmd(MsgQueueCmd.EnqueueCmd); cmd.MessageHeader = msg.GetMessageHeader(new MsgQueueSettings()); cmd.MessageBody = msg.GetMessageBody(Compress.None); msgTest = new QueuedMsg(cmd, true); Assert.AreEqual(msg, msgTest); Assert.AreEqual(msg.TargetEP, msgTest.TargetEP); Assert.AreEqual(msg.ResponseEP, msgTest.ResponseEP); Assert.AreEqual(msg.SessionID, msgTest.SessionID); Assert.AreEqual(msg.SendTime, msgTest.SendTime); Assert.AreEqual(msg.ExpireTime, msgTest.ExpireTime); Assert.AreEqual(msg.Body, msgTest.Body); msgInfo = new QueuedMsgInfo(null, msgTest); Assert.AreEqual(msg.TargetEP, msgInfo.TargetEP); Assert.AreEqual(msg.ResponseEP, msgInfo.ResponseEP); Assert.AreEqual(msg.SessionID, msgInfo.SessionID); Assert.AreEqual(msg.SendTime, msgInfo.SendTime); Assert.AreEqual(msg.ExpireTime, msgInfo.ExpireTime); Assert.AreEqual(msg.BodyRaw.Length, msgInfo.BodySize); }
/// <summary> /// Initializes the message from from a <see cref="MsgQueueCmd" />, /// optionally deserializing the message body. /// </summary> /// <param name="msg">The <see cref="MsgQueueCmd" /> message.</param> /// <param name="deserialize"> /// Pass <c>true</c> to deserialize the message body, <c>false</c> to limit /// deserialization to the message headers. /// </param> /// <remarks> /// <note> /// This constructor is provided for applications that need to implement /// a custom <see cref="IMsgQueueStore" />. /// </note> /// </remarks> public QueuedMsg(MsgQueueCmd msg, bool deserialize) { Assertion.Test(msg.Command == MsgQueueCmd.EnqueueCmd); ParseHeaders(msg.MessageHeader); this.bodyRaw = msg.MessageBody; if (deserialize) { body = Serialize.FromBinary(bodyRaw); } else { body = null; } }