public virtual void Enqueue(QueueMessage message) { if (message == null) { return; } lock (lockObj) { rearIndex = (rearIndex + 1) % this.Messages.Length; if (rearIndex == this.allowedMessageSize) { return; } Messages[rearIndex] = message; if (QueueIsFull()) { QueueMessage[] temp = new QueueMessage[rearIndex + 2]; Array.Copy(Messages, 0, temp, 0, temp.Length - 1); Messages = temp; } CurrentOffset = rearIndex; message.SetQueueId(this.QueueId); // recorde queueId in queue message message.SetOffset(this.CurrentOffset); //recode queue current offset } }