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]);
         }
     }
 }
Exemple #2
0
		/// <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);
			}
		}
Exemple #3
0
		/// <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);
				}
			}
		}
Exemple #4
0
		/// <summary>
		/// Populates this error queue from the messages stored in a previous instance of the error queue.
		/// </summary>
		/// <remarks>
		/// <para>
		/// When an AppDomain restart occurs the error queues are serialized into the Forwarding component's
		/// RunState.  Upon restart they are deserialized and all messages from the memory queue from the old
		/// AppDomain are copied into the error queues for the new AppDomain.
		/// </para>
		/// <para>
		/// If persistent error queues are enabled then the memory queues will normally be empty as they are
		/// flushed to perisistent storage before serializing the error queues.
		/// </para>
		/// </remarks>
		/// <param name="errorQueue">The original error queue.</param>
		/// <param name="incrementCounters">if set to <see langword="true"/> the performance counter for messages
		/// in the error queue will be incremented by the number of messages in the source error queue.</param>
		internal void Populate(ErrorQueue errorQueue, bool incrementCounters)
		{
			if (errorQueue.InMessageQueueCount == 0) return;

			if (_persistence != null && !_persistence.CreateSpillFolder())
				_persistence = null;

			lock (_inMessageQueueLock)
			{
				SerializedRelayMessage[] curMessages = null;
				if (InMessageQueue.Count > 0)
				{
					curMessages = InMessageQueue.ToArray();
					InMessageQueue.Clear();
				}

				foreach (var message in errorQueue.InMessageQueue)
				{
					InMessageQueue.Enqueue(message);
				}

				if (curMessages != null)
				{
					foreach (var message in curMessages)
					{
						InMessageQueue.Enqueue(message);
					}
				}
			}

			if (incrementCounters)
			{
				NodeManager.Instance.Counters.IncrementErrorQueueBy(errorQueue.InMessageQueue.Count);
			}

			StartSpill();
		}
 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);
     }
 }