Exemplo n.º 1
0
 private Microsoft.ServiceBus.Channels.ConnectionModeReader SetupModeReader(Microsoft.ServiceBus.Channels.IConnection connection, bool isCached)
 {
     Microsoft.ServiceBus.Channels.ConnectionModeReader connectionModeReader;
     Microsoft.ServiceBus.Channels.ConnectionModeReader connectionModeReader1;
     if (!isCached)
     {
         if (this.onConnectionModeKnown == null)
         {
             this.onConnectionModeKnown = new Microsoft.ServiceBus.Channels.ConnectionModeCallback(this.OnConnectionModeKnown);
         }
         connectionModeReader = new Microsoft.ServiceBus.Channels.ConnectionModeReader(connection, this.onConnectionModeKnown, this.onConnectionClosed);
     }
     else
     {
         if (this.onCachedConnectionModeKnown == null)
         {
             this.onCachedConnectionModeKnown = new Microsoft.ServiceBus.Channels.ConnectionModeCallback(this.OnCachedConnectionModeKnown);
         }
         connectionModeReader = new Microsoft.ServiceBus.Channels.ConnectionModeReader(connection, this.onCachedConnectionModeKnown, this.onConnectionClosed);
     }
     lock (this.ThisLock)
     {
         if (!this.isClosed)
         {
             this.connectionReaders.Add(connectionModeReader);
             connectionModeReader1 = connectionModeReader;
         }
         else
         {
             connectionModeReader.Dispose();
             connectionModeReader1 = null;
         }
     }
     return(connectionModeReader1);
 }
Exemplo n.º 2
0
 private void OnConnectionAvailable(Microsoft.ServiceBus.Channels.IConnection connection, Action connectionDequeuedCallback)
 {
     Microsoft.ServiceBus.Channels.ConnectionModeReader connectionModeReader = this.SetupModeReader(connection, false);
     if (connectionModeReader == null)
     {
         connectionDequeuedCallback();
         return;
     }
     connectionModeReader.StartReading(this.channelInitializationTimeout, connectionDequeuedCallback);
 }
Exemplo n.º 3
0
 public void ReuseConnection(Microsoft.ServiceBus.Channels.IConnection connection, TimeSpan closeTimeout)
 {
     connection.ExceptionEventType = TraceEventType.Information;
     Microsoft.ServiceBus.Channels.ConnectionModeReader connectionModeReader = this.SetupModeReader(connection, true);
     if (connectionModeReader != null)
     {
         if (this.reuseConnectionCallback == null)
         {
             this.reuseConnectionCallback = new Action <object>(this.ReuseConnectionCallback);
         }
         IOThreadScheduler.ScheduleCallbackNoFlow(this.reuseConnectionCallback, new Microsoft.ServiceBus.Channels.ConnectionDemuxer.ReuseConnectionState(connectionModeReader, closeTimeout));
     }
 }
Exemplo n.º 4
0
 public ReuseConnectionState(Microsoft.ServiceBus.Channels.ConnectionModeReader modeReader, TimeSpan closeTimeout)
 {
     this.modeReader   = modeReader;
     this.closeTimeout = closeTimeout;
 }
Exemplo n.º 5
0
        private void OnConnectionModeKnownCore(Microsoft.ServiceBus.Channels.ConnectionModeReader modeReader, bool isCached)
        {
            Microsoft.ServiceBus.Channels.FramingMode connectionMode;
            lock (this.ThisLock)
            {
                if (!this.isClosed)
                {
                    this.connectionReaders.Remove(modeReader);
                }
                else
                {
                    return;
                }
            }
            bool flag = true;

            try
            {
                try
                {
                    try
                    {
                        connectionMode = modeReader.GetConnectionMode();
                    }
                    catch (CommunicationException communicationException1)
                    {
                        CommunicationException communicationException = communicationException1;
                        TraceEventType         exceptionEventType     = modeReader.Connection.ExceptionEventType;
                        if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(exceptionEventType))
                        {
                            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, exceptionEventType);
                        }
                        return;
                    }
                    catch (TimeoutException timeoutException1)
                    {
                        TimeoutException timeoutException = timeoutException1;
                        if (!isCached)
                        {
                            string   channelInitializationTimeout = Resources.ChannelInitializationTimeout;
                            object[] objArray = new object[] { this.channelInitializationTimeout };
                            timeoutException = new TimeoutException(Microsoft.ServiceBus.SR.GetString(channelInitializationTimeout, objArray), timeoutException);
                            ErrorBehavior.ThrowAndCatch(timeoutException);
                        }
                        TraceEventType traceEventType = modeReader.Connection.ExceptionEventType;
                        if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(traceEventType))
                        {
                            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, traceEventType);
                        }
                        return;
                    }
                    switch (connectionMode)
                    {
                    case Microsoft.ServiceBus.Channels.FramingMode.Singleton:
                    {
                        this.OnSingletonConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback, modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize, modeReader.GetRemainingTimeout());
                        break;
                    }

                    case Microsoft.ServiceBus.Channels.FramingMode.Duplex:
                    {
                        this.OnDuplexConnection(modeReader.Connection, modeReader.ConnectionDequeuedCallback, modeReader.StreamPosition, modeReader.BufferOffset, modeReader.BufferSize, modeReader.GetRemainingTimeout());
                        break;
                    }

                    default:
                    {
                        string    framingModeNotSupported = Resources.FramingModeNotSupported;
                        object[]  objArray1            = new object[] { connectionMode };
                        Exception invalidDataException = new InvalidDataException(Microsoft.ServiceBus.SR.GetString(framingModeNotSupported, objArray1));
                        Exception protocolException    = new ProtocolException(invalidDataException.Message, invalidDataException);
                        Microsoft.ServiceBus.Channels.FramingEncodingString.AddFaultString(protocolException, "http://schemas.microsoft.com/ws/2006/05/framing/faults/UnsupportedMode");
                        ErrorBehavior.ThrowAndCatch(protocolException);
                        return;
                    }
                    }
                    flag = false;
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    TraceEventType exceptionEventType1 = modeReader.Connection.ExceptionEventType;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTrace(exceptionEventType1))
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, exceptionEventType1);
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    modeReader.Dispose();
                }
            }
        }
Exemplo n.º 6
0
 private void OnConnectionModeKnown(Microsoft.ServiceBus.Channels.ConnectionModeReader modeReader)
 {
     this.OnConnectionModeKnownCore(modeReader, false);
 }