internal void Enqueue(IList <SerializedRelayMessage> messages) { if (_enabled && messages.Count > 0) { lock (_inMessageQueueLock) { while (InMessageQueue.Count > 0 && InMessageQueue.Count >= (_maxCount - messages.Count)) { Forwarder.RaiseMessageDropped(InMessageQueue.Dequeue()); NodeManager.Instance.Counters.DecrementErrorQueue(); } for (int i = 0; i < messages.Count; i++) { InMessageQueue.Enqueue(messages[i]); } } NodeManager.Instance.Counters.IncrementErrorQueueBy(messages.Count); } else { for (int i = 0; i < messages.Count; i++) { Forwarder.RaiseMessageDropped(messages[i]); } } }
/// <summary> /// Enqueues a single message to the error queue. /// </summary> /// <remarks> /// Two-way messages are ignored. /// </remarks> /// <param name="message">The message.</param> internal void Enqueue(SerializedRelayMessage message) { if (message.IsTwoWayMessage) return; SerializedRelayMessage discard = null; if (_enabled) { lock (_inMessageQueueLock) { NodeManager.Instance.Counters.IncrementErrorQueue(); InMessageQueue.Enqueue(message); if (_persistence == null && InMessageQueue.Count > _maxCount) { discard = InMessageQueue.Dequeue(); } } if (discard != null) { Forwarder.RaiseMessageDropped(discard); NodeManager.Instance.Counters.DecrementErrorQueue(); IncrementDiscardsBy(1); } StartSpill(); } else { Forwarder.RaiseMessageDropped(message); } }
/// <summary> /// Enqueues a list of messages to the error queue. /// </summary> /// <remarks> /// Two-way messages in the message list are ignored. /// </remarks> /// <param name="messages">The list of messages.</param> internal void Enqueue(IList<SerializedRelayMessage> messages) { if (_enabled && messages.Count > 0) { int count = 0; SerializedRelayMessage[] discards = null; lock (_inMessageQueueLock) { for (int i = 0; i < messages.Count; ++i) { var message = messages[i]; if (!message.IsTwoWayMessage) { InMessageQueue.Enqueue(message); ++count; } } if (_persistence == null && InMessageQueue.Count > _maxCount) { discards = new SerializedRelayMessage[InMessageQueue.Count - _maxCount]; for (int i = 0; i < discards.Length; ++i) { discards[i] = InMessageQueue.Dequeue(); } } } if (discards != null) { for (int i = 0; i < discards.Length; ++i) { Forwarder.RaiseMessageDropped(discards[i]); } NodeManager.Instance.Counters.DecrementErrorQueueBy(discards.Length); IncrementDiscardsBy(discards.Length); } if (count > 0) { NodeManager.Instance.Counters.IncrementErrorQueueBy(count); StartSpill(); } } else { for (int i = 0; i < messages.Count; i++) { var message = messages[i]; if (!message.IsTwoWayMessage) Forwarder.RaiseMessageDropped(message); } } }
internal void Enqueue(SerializedRelayMessage message) { if (_enabled) { if (message.IsTwoWayMessage) { return; } lock (_inMessageQueueLock) { while (InMessageQueue.Count >= (_maxCount - 1)) { Forwarder.RaiseMessageDropped(InMessageQueue.Dequeue()); NodeManager.Instance.Counters.DecrementErrorQueue(); } NodeManager.Instance.Counters.IncrementErrorQueue(); InMessageQueue.Enqueue(message); } } else { Forwarder.RaiseMessageDropped(message); } }