private FramingDuplexSessionChannel(ChannelManagerBase manager, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, EndpointAddress localAddress, Uri localVia, EndpointAddress remoteAddresss, Uri via, bool exposeConnectionProperty) : base(manager, remoteAddresss, via, settings.ManualAddressing, settings.MessageVersion) { this.localAddress = localAddress; this.localVia = localVia; this.exposeConnectionProperty = exposeConnectionProperty; this.bufferManager = settings.BufferManager; this.Activity = new EventTraceActivity(); }
protected SingletonConnectionReader(Microsoft.ServiceBus.Channels.IConnection connection, int offset, int size, SecurityMessageProperty security, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings transportSettings, Uri via) { this.connection = connection; this.offset = offset; this.size = size; this.security = security; this.transportSettings = transportSettings; this.via = via; }
public StreamedFramingRequestChannel(ChannelManagerBase factory, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, Microsoft.ServiceBus.Channels.IConnectionInitiator connectionInitiator, Microsoft.ServiceBus.Channels.ConnectionPool connectionPool) : base(factory, remoteAddresss, via, settings.ManualAddressing) { this.settings = settings; this.connectionInitiator = connectionInitiator; this.connectionPool = connectionPool; this.messageEncoder = settings.MessageEncoderFactory.Encoder; this.upgrade = settings.Upgrade; this.Activity = new EventTraceActivity(); }
public StreamedFramingRequestContext(Microsoft.ServiceBus.Channels.SingletonConnectionReader parent, Message requestMessage) : base(requestMessage, parent.transportSettings.CloseTimeout, parent.transportSettings.SendTimeout) { this.parent = parent; this.connection = parent.connection; this.settings = parent.transportSettings; }
private void ContinueReading() { bool flag = false; try { try { while (true) { if (this.size == 0) { if (Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback == null) { Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback = new WaitCallback(Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.ReadCallback); } if (base.Connection.BeginRead(0, (int)this.connectionBuffer.Length, this.GetRemainingTimeout(), Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback, this) == AsyncReadResult.Queued) { break; } this.GetReadResult(); } int num = this.decoder.Decode(this.connectionBuffer, this.offset, this.size); if (num > 0) { Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleConnectionReader = this; serverSessionPreambleConnectionReader.offset = serverSessionPreambleConnectionReader.offset + num; Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleConnectionReader1 = this; serverSessionPreambleConnectionReader1.size = serverSessionPreambleConnectionReader1.size - num; } if (this.decoder.CurrentState == Microsoft.ServiceBus.Channels.ServerSessionDecoder.State.PreUpgradeStart) { this.via = this.decoder.Via; if (base.Connection.Validate(this.via)) { if (this.viaDelegate != null) { try { this.viaDelegate(this.via); } catch (ServiceActivationException serviceActivationException1) { ServiceActivationException serviceActivationException = serviceActivationException1; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(serviceActivationException, TraceEventType.Information); } this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/ServiceActivationFailed"); break; } } this.settings = this.transportSettingsCallback(this.via); if (this.settings != null) { this.callback(this); break; } else { string endpointNotFound = Resources.EndpointNotFound; object[] via = new object[] { this.decoder.Via }; EndpointNotFoundException endpointNotFoundException = new EndpointNotFoundException(Microsoft.ServiceBus.SR.GetString(endpointNotFound, via)); if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(endpointNotFoundException, TraceEventType.Information); } this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound"); return; } } else { return; } } } flag = true; } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, TraceEventType.Information); } } catch (TimeoutException timeoutException1) { TimeoutException timeoutException = timeoutException1; if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation) { Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, TraceEventType.Information); } } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } if (!ExceptionHandler.HandleTransportExceptionHelper(exception)) { throw; } } } finally { if (!flag) { base.Abort(); } } }
protected FramingDuplexSessionChannel(ChannelManagerBase factory, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, EndpointAddress remoteAddresss, Uri via, bool exposeConnectionProperty) : this(factory, settings, EndpointAddress2.AnonymousAddress, (Uri)InvokeHelper.InvokeInstanceGet(typeof(AddressingVersion), settings.MessageVersion.Addressing, "AnonymousUri"), remoteAddresss, via, exposeConnectionProperty) { this.duplexSession = Microsoft.ServiceBus.Channels.FramingDuplexSessionChannel.ConnectionDuplexSession.CreateSession(this, settings.Upgrade); }
public static void WriteMessage(Message message, Microsoft.ServiceBus.Channels.IConnection connection, bool isRequest, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, ref TimeoutHelper timeoutHelper) { bool flag; byte[] envelopeEndBytes = null; if (message != null) { MessageEncoder encoder = settings.MessageEncoderFactory.Encoder; byte[] envelopeStartBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeStartBytes; if (!isRequest) { envelopeEndBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndBytes; flag = Microsoft.ServiceBus.Channels.TransferModeHelper.IsResponseStreamed(settings.TransferMode); } else { envelopeEndBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndFramingEndBytes; flag = Microsoft.ServiceBus.Channels.TransferModeHelper.IsRequestStreamed(settings.TransferMode); } if (!flag) { ArraySegment <byte> nums = encoder.WriteMessage(message, 2147483647, settings.BufferManager, (int)envelopeStartBytes.Length + 5); nums = Microsoft.ServiceBus.Channels.SingletonEncoder.EncodeMessageFrame(nums); Buffer.BlockCopy(envelopeStartBytes, 0, nums.Array, nums.Offset - (int)envelopeStartBytes.Length, (int)envelopeStartBytes.Length); connection.Write(nums.Array, nums.Offset - (int)envelopeStartBytes.Length, nums.Count + (int)envelopeStartBytes.Length, true, timeoutHelper.RemainingTime(), settings.BufferManager); } else { connection.Write(envelopeStartBytes, 0, (int)envelopeStartBytes.Length, false, timeoutHelper.RemainingTime()); Microsoft.ServiceBus.Channels.StreamingConnectionHelper.StreamingOutputConnectionStream streamingOutputConnectionStream = new Microsoft.ServiceBus.Channels.StreamingConnectionHelper.StreamingOutputConnectionStream(connection, settings) { Immediate = !message.Properties.AllowOutputBatching }; encoder.WriteMessage(message, new Microsoft.ServiceBus.Channels.TimeoutStream(streamingOutputConnectionStream, ref timeoutHelper)); } } else if (isRequest) { envelopeEndBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EndBytes; } if (envelopeEndBytes != null) { connection.Write(envelopeEndBytes, 0, (int)envelopeEndBytes.Length, true, timeoutHelper.RemainingTime()); } }
public WriteMessageAsyncResult(Message message, Microsoft.ServiceBus.Channels.IConnection connection, bool isRequest, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, ref TimeoutHelper timeoutHelper, AsyncCallback callback, object state) : base(callback, state) { bool flag; this.connection = connection; this.encoder = settings.MessageEncoderFactory.Encoder; this.bufferManager = settings.BufferManager; this.timeoutHelper = timeoutHelper; this.message = message; this.settings = settings; bool flag1 = true; bool flag2 = false; if (message != null) { try { byte[] envelopeStartBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeStartBytes; if (!isRequest) { this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndBytes; flag = Microsoft.ServiceBus.Channels.TransferModeHelper.IsResponseStreamed(settings.TransferMode); } else { this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EnvelopeEndFramingEndBytes; flag = Microsoft.ServiceBus.Channels.TransferModeHelper.IsRequestStreamed(settings.TransferMode); } if (!flag) { ArraySegment <byte> nums = settings.MessageEncoderFactory.Encoder.WriteMessage(message, 2147483647, this.bufferManager, (int)envelopeStartBytes.Length + 5); nums = Microsoft.ServiceBus.Channels.SingletonEncoder.EncodeMessageFrame(nums); this.bufferToFree = nums.Array; Buffer.BlockCopy(envelopeStartBytes, 0, nums.Array, nums.Offset - (int)envelopeStartBytes.Length, (int)envelopeStartBytes.Length); if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage == null) { Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteBufferedMessage)); } IAsyncResult asyncResult = connection.BeginWrite(nums.Array, nums.Offset - (int)envelopeStartBytes.Length, nums.Count + (int)envelopeStartBytes.Length, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteBufferedMessage, this); if (asyncResult.CompletedSynchronously) { flag2 = this.HandleWriteBufferedMessage(asyncResult); } } else { if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes == null) { Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ThunkAsyncCallback(new AsyncCallback(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteStartBytes)); } IAsyncResult asyncResult1 = connection.BeginWrite(envelopeStartBytes, 0, (int)envelopeStartBytes.Length, true, timeoutHelper.RemainingTime(), Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytes, this); if (asyncResult1.CompletedSynchronously) { if (Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled == null) { Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled = new Action <object>(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.OnWriteStartBytesScheduled); } IOThreadScheduler.ScheduleCallbackNoFlow(Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult.onWriteStartBytesScheduled, asyncResult1); } } flag1 = false; } finally { if (flag1) { this.Cleanup(); } } } else { if (isRequest) { this.endBytes = Microsoft.ServiceBus.Channels.SingletonEncoder.EndBytes; } flag2 = this.WriteEndBytes(); } if (flag2) { base.Complete(true); } }
public static IAsyncResult BeginWriteMessage(Message message, Microsoft.ServiceBus.Channels.IConnection connection, bool isRequest, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, ref TimeoutHelper timeoutHelper, AsyncCallback callback, object state) { return(new Microsoft.ServiceBus.Channels.StreamingConnectionHelper.WriteMessageAsyncResult(message, connection, isRequest, settings, ref timeoutHelper, callback, state)); }
public ClientSingletonConnectionReader(Microsoft.ServiceBus.Channels.IConnection connection, Microsoft.ServiceBus.Channels.StreamedFramingRequestChannel.StreamedConnectionPoolHelper connectionPoolHelper, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings) : base(connection, 0, 0, connectionPoolHelper.RemoteSecurity, settings, null) { this.connectionPoolHelper = connectionPoolHelper; }
public ClientDuplexConnectionReader(Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel channel, Microsoft.ServiceBus.Channels.IConnection connection, Microsoft.ServiceBus.Channels.ClientDuplexDecoder decoder, Microsoft.ServiceBus.Channels.IConnectionOrientedTransportFactorySettings settings, MessageEncoder messageEncoder) : base(connection, null, 0, 0, null) { this.decoder = decoder; this.maxBufferSize = settings.MaxBufferSize; this.bufferManager = settings.BufferManager; this.messageEncoder = messageEncoder; this.channel = channel; }