private byte[] bodyRaw; // The serialized message body (or null) /// <summary> /// Constructs an empty message with a unique ID. /// </summary> public QueuedMsg() { this.id = Helper.NewGuid(); this.expireTime = DateTime.MinValue; this.flags = MsgQueueFlag.None; this.priority = DeliveryPriority.Normal; this.body = null; this.bodyRaw = null; }
/// <summary> /// Initializes the record with information from a <see cref="QueuedMsg" /> /// and sets default values for all remaining fields. /// </summary> /// <param name="persistID"> /// The <see cref="IMsgQueueStore" /> specific ID used to identify and /// locate the message. /// </param> /// <param name="msg">The message</param> public QueuedMsgInfo(object persistID, QueuedMsg msg) { this.PersistID = persistID; this.ID = msg.ID; this.SessionID = msg.SessionID; this.TargetEP = msg.TargetEP; this.ResponseEP = msg.ResponseEP; this.Priority = msg.Priority; this.Flags = msg.Flags; this.SendTime = msg.SendTime; this.ExpireTime = msg.ExpireTime; this.DeliveryTime = DateTime.MinValue; this.BodySize = msg.BodyRaw.Length; this.DeliveryAttempts = 0; this.LockID = Guid.Empty; this.ProviderData = null; }
/// <summary> /// Constructor. /// </summary> /// <param name="persistID"> /// The <see cref="IMsgQueueStore" /> specific ID used to identify and /// locate the message. /// </param> /// <param name="targetEP">The message's target queue <see cref="MsgEP" />.</param> public QueuedMsgInfo(object persistID, MsgEP targetEP) { this.PersistID = persistID; this.ID = this.SessionID = Guid.Empty; this.TargetEP = targetEP; this.ResponseEP = null; this.Priority = DeliveryPriority.Normal; this.Flags = MsgQueueFlag.None; this.SendTime = DateTime.UtcNow; this.ExpireTime = DateTime.MaxValue; this.DeliveryTime = DateTime.MinValue; this.BodySize = 0; this.DeliveryAttempts = 0; this.LockID = Guid.Empty; this.ProviderData = null; }
/// <summary> /// Parses the metadata from a <see cref="ArgCollection" /> formatted string /// generated by a previous <see cref="ToString" /> call. /// </summary> /// <param name="input">The input string.</param> /// <remarks> /// <note> /// This method does not initialize the <see cref="PersistID" /> and /// <see cref="ProviderData" /> properties. /// </note> /// </remarks> public QueuedMsgInfo(string input) { var args = ArgCollection.Parse(input, '=', '\t'); this.PersistID = null; this.ID = args.Get("ID", Guid.Empty); this.SessionID = args.Get("SessionID", Guid.Empty); this.TargetEP = args.Get("TargetEP"); this.ResponseEP = args.Get("ResponseEP"); this.Priority = args.Get <DeliveryPriority>("Priority", DeliveryPriority.Normal); this.Flags = (MsgQueueFlag)args.Get("Flags", 0); this.SendTime = args.Get("SendTime", DateTime.MinValue); this.ExpireTime = args.Get("ExpireTime", DateTime.MaxValue); this.DeliveryTime = args.Get("DeliveryTime", DateTime.MinValue); this.BodySize = args.Get("BodySize", 0); this.DeliveryAttempts = args.Get("DeliveryAttempts", 0); this.LockID = args.Get("LockID", Guid.Empty); this.ProviderData = null; }
/// <summary> /// Constructor. /// </summary> /// <param name="msgInfo">A <see cref="QueuedMsgInfo" /> instance with the header information.</param> /// <param name="bodyRaw">The raw message body.</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(QueuedMsgInfo msgInfo, byte[] bodyRaw, bool deserialize) { this.id = msgInfo.ID; this.targetEP = msgInfo.TargetEP; this.responseEP = msgInfo.ResponseEP; this.sessionID = msgInfo.SessionID; this.sendTime = msgInfo.SendTime; this.expireTime = msgInfo.ExpireTime; this.flags = msgInfo.Flags; this.priority = msgInfo.Priority; this.bodyRaw = bodyRaw; if (deserialize) { body = Serialize.FromBinary(bodyRaw); } else { body = null; } }
/// <summary> /// Extracts the message headers from a <see cref="ArgCollection" /> /// encoded string. /// </summary> /// <param name="headers">The encoded headers.</param> private void ParseHeaders(string headers) { var args = ArgCollection.Parse(headers, '=', '\t'); string v; this.id = args.Get("id", Guid.Empty); this.sessionID = args.Get("session-id", Guid.Empty); this.sendTime = args.Get("send-time", DateTime.MinValue); this.expireTime = args.Get("expire-time", DateTime.MinValue); this.flags = (MsgQueueFlag)args.Get("flags", 0); this.priority = (DeliveryPriority)args.Get("priority", (int)DeliveryPriority.Normal); v = args.Get("target-ep"); if (v == null) { this.targetEP = null; } else { this.targetEP = MsgEP.Parse(v); if (!targetEP.IsLogical) { throw new ArgumentException("TargetEP must be logical."); } } v = args.Get("response-ep"); if (v == null) { this.responseEP = null; } else { this.responseEP = MsgEP.Parse(v); if (!responseEP.IsLogical) { throw new ArgumentException("ResponseEP must be logical."); } } }