public ServerSingletonConnectionReader(Microsoft.ServiceBus.Channels.ServerSingletonPreambleConnectionReader preambleReader, Microsoft.ServiceBus.Channels.IConnection upgradedConnection, Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer) : base(upgradedConnection, preambleReader.BufferOffset, preambleReader.BufferSize, preambleReader.Security, preambleReader.TransportSettings, preambleReader.Via) { this.decoder = preambleReader.Decoder; this.contentType = this.decoder.ContentType; this.connectionDemuxer = connectionDemuxer; this.rawConnection = preambleReader.RawConnection; }
private void ReuseConnectionCallback(object state) { Microsoft.ServiceBus.Channels.ConnectionDemuxer.ReuseConnectionState reuseConnectionState = (Microsoft.ServiceBus.Channels.ConnectionDemuxer.ReuseConnectionState)state; bool flag = false; lock (this.ThisLock) { if (this.pooledConnectionCount < this.maxPooledConnections) { Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer = this; connectionDemuxer.pooledConnectionCount = connectionDemuxer.pooledConnectionCount + 1; } else { flag = true; } } if (!flag) { if (this.pooledConnectionDequeuedCallback == null) { this.pooledConnectionDequeuedCallback = new Action(this.PooledConnectionDequeuedCallback); } reuseConnectionState.ModeReader.StartReading(this.idleTimeout, this.pooledConnectionDequeuedCallback); return; } if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceWarning) { DiagnosticTrace diagnosticTrace = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DiagnosticTrace; string traceCodeServerMaxPooledConnectionsQuotaReached = Resources.TraceCodeServerMaxPooledConnectionsQuotaReached; object[] objArray = new object[] { this.maxPooledConnections }; diagnosticTrace.TraceEvent(TraceEventType.Warning, TraceCode.ServerMaxPooledConnectionsQuotaReached, Microsoft.ServiceBus.SR.GetString(traceCodeServerMaxPooledConnectionsQuotaReached, objArray), new StringTraceRecord("MaxOutboundConnectionsPerEndpoint", this.maxPooledConnections.ToString(CultureInfo.InvariantCulture)), null, this); } reuseConnectionState.ModeReader.CloseFromPool(reuseConnectionState.CloseTimeout); }
private void PooledConnectionDequeuedCallback() { lock (this.ThisLock) { Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer = this; connectionDemuxer.pooledConnectionCount = connectionDemuxer.pooledConnectionCount - 1; Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(this.pooledConnectionCount >= 0, "Connection Throttle should never be negative"); } }
public ServerFramingDuplexSessionChannel(Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelListener channelListener, Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader preambleReader, EndpointAddress localAddress, bool exposeConnectionProperty, Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer) : base(channelListener, localAddress, preambleReader.Via, exposeConnectionProperty) { this.channelListener = channelListener; this.connectionDemuxer = connectionDemuxer; base.Connection = preambleReader.Connection; this.decoder = preambleReader.Decoder; this.connectionBuffer = preambleReader.connectionBuffer; this.offset = preambleReader.BufferOffset; this.size = preambleReader.BufferSize; this.rawConnection = preambleReader.RawConnection; StreamUpgradeProvider upgrade = channelListener.Upgrade; if (upgrade != null) { this.upgradeAcceptor = upgrade.CreateUpgradeAcceptor(); } MessagingClientEtwProvider.Provider.RelayChannelConnectionTransfer(base.Activity, base.Connection.Activity); }
protected override void ReturnConnectionIfNecessary(bool abort, TimeSpan timeout) { Microsoft.ServiceBus.Channels.IConnection rawConnection = null; if (this.sessionReader != null) { lock (base.ThisLock) { rawConnection = this.sessionReader.GetRawConnection(); } } if (rawConnection != null) { if (!abort) { this.connectionDemuxer.ReuseConnection(rawConnection, timeout); } else { rawConnection.Abort(); } this.connectionDemuxer = null; } }
public IDuplexSessionChannel CreateDuplexSessionChannel(Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelListener channelListener, EndpointAddress localAddress, bool exposeConnectionProperty, Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer) { return(new Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.ServerFramingDuplexSessionChannel(channelListener, this, localAddress, exposeConnectionProperty, connectionDemuxer)); }
internal void OnHandleServerSessionPreamble(Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleReader, Microsoft.ServiceBus.Channels.ConnectionDemuxer connectionDemuxer) { Uri via = serverSessionPreambleReader.Via; TChannelListener channelListener = this.GetChannelListener(via); if (channelListener == null) { serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound"); ExceptionUtility exceptionUtility = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility; string duplexSessionListenerNotFound = Resources.DuplexSessionListenerNotFound; object[] str = new object[] { via.ToString() }; throw exceptionUtility.ThrowHelperError(new EndpointNotFoundException(Microsoft.ServiceBus.SR.GetString(duplexSessionListenerNotFound, str))); } Microsoft.ServiceBus.Channels.ISessionPreambleHandler sessionPreambleHandler = (object)channelListener as Microsoft.ServiceBus.Channels.ISessionPreambleHandler; if (sessionPreambleHandler == null || !((object)channelListener is IChannelListener <IDuplexSessionChannel>)) { serverSessionPreambleReader.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode"); ExceptionUtility exceptionUtility1 = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility; string framingModeNotSupported = Resources.FramingModeNotSupported; object[] objArray = new object[] { Microsoft.ServiceBus.Channels.FramingMode.Duplex }; throw exceptionUtility1.ThrowHelperError(new ProtocolException(Microsoft.ServiceBus.SR.GetString(framingModeNotSupported, objArray))); } sessionPreambleHandler.HandleServerSessionPreamble(serverSessionPreambleReader, connectionDemuxer); }