Ejemplo n.º 1
0
        internal void EnqueueSessionAndDispatch(ListenerSessionConnection session)
        {
            lock (SessionLock)
            {
                if (!CanDispatch)
                {
                    TransportListener.SendFault(session.Connection, FramingEncodingString.EndpointUnavailableFault);
                    OnDispatchFailure(transportType);
                    return;
                }
                else if (sessionMessages.Count >= maxQueueSize)
                {
                    // Abort the connection when the queue is full.
                    if (TD.PendingSessionQueueFullIsEnabled())
                    {
                        TD.PendingSessionQueueFull(session.EventTraceActivity,
                                                   (session.Via != null) ? session.Via.ToString() : string.Empty,
                                                   sessionMessages.Count);
                    }
                    session.Connection.Abort();
                    OnDispatchFailure(transportType);
                    return;
                }
                else
                {
                    sessionMessages.Enqueue(session);
                    if (TD.PendingSessionQueueRatioIsEnabled())
                    {
                        TD.PendingSessionQueueRatio(sessionMessages.Count, maxQueueSize);
                    }
                }
            }

            OnSessionEnqueued();
            DispatchSession();
        }