private Microsoft.ServiceBus.Messaging.Amqp.Framing.Error GetSessionLockLostError() { if (this.sessionReceiver) { AmqpLink unsafeInnerObject = this.receiveLink.UnsafeInnerObject; AmqpException amqpException = null; if (unsafeInnerObject != null) { AmqpException terminalException = unsafeInnerObject.TerminalException as AmqpException; amqpException = terminalException; if (terminalException != null && amqpException.Error.Condition.Equals(ClientConstants.SessionLockLostError)) { return(amqpException.Error); } } } return(null); }
protected override void OnProtocolHeader(ProtocolHeader header) { base.TransitState("R:HDR", StateTransition.ReceiveHeader); Exception amqpException = null; if (!this.isInitiator) { ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header); this.SendProtocolHeader(supportedHeader); if (!supportedHeader.Equals(header)) { amqpException = new AmqpException(AmqpError.NotImplemented, SRAmqp.AmqpProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } else if (!this.initialHeader.Equals(header)) { amqpException = new AmqpException(AmqpError.NotImplemented, SRAmqp.AmqpProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } if (amqpException != null) { base.CompleteOpen(false, amqpException); } }
private void OnReceiveBegin(Begin begin) { StateTransition stateTransition = base.TransitState("R:BEGIN", StateTransition.ReceiveOpen); this.incomingChannel.OnBegin(begin); if (stateTransition.To == AmqpObjectState.OpenReceived) { base.Open(); return; } Exception amqpException = null; Error error = this.Negotiate(begin); if (error != null) { amqpException = new AmqpException(error); } base.CompleteOpen(false, amqpException); if (amqpException != null) { base.SafeClose(amqpException); } }
public static Exception ToCommunicationContract(Exception exception) { Exception communicationContract = null; AmqpException amqpException = exception as AmqpException; AmqpException amqpException1 = amqpException; if (amqpException != null) { communicationContract = ExceptionHelper.ToCommunicationContract(amqpException1.Error, amqpException1); } else if (exception is CommunicationException || exception is TimeoutException) { communicationContract = exception; } else { SocketException socketException = exception as SocketException; SocketException socketException1 = socketException; if (socketException != null) { if (socketException1.SocketErrorCode == SocketError.ConnectionRefused || socketException1.SocketErrorCode == SocketError.HostDown || socketException1.SocketErrorCode == SocketError.HostNotFound || socketException1.SocketErrorCode == SocketError.HostUnreachable) { communicationContract = new EndpointNotFoundException(socketException1.Message, socketException1); } else if (socketException1.SocketErrorCode == SocketError.TimedOut) { communicationContract = new TimeoutException(socketException1.Message, socketException1); } } } if (communicationContract == null) { communicationContract = new CommunicationException(exception.Message, exception); } return(communicationContract); }
protected override void OnProtocolHeader(ProtocolHeader header) { Utils.Trace(TraceLevel.Frame, "RECV {0}", header); this.TransitState("R:HDR", StateTransition.ReceiveHeader); Exception exception = null; if (this.isInitiator) { if (!this.initialHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } else { ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header); this.SendProtocolHeader(supportedHeader); if (!supportedHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } if (exception != null) { this.CompleteOpen(false, exception); } }
public static Error ToAmqpError(Exception exception) { bool flag; if (exception == null) { return(null); } Error error = new Error() { Description = ExceptionHelper.GetExceptionMessage(exception, out flag) }; if (exception is AmqpException) { AmqpException amqpException = (AmqpException)exception; error.Condition = amqpException.Error.Condition; error.Info = amqpException.Error.Info; } else if (exception is UnauthorizedAccessException) { error.Condition = AmqpError.UnauthorizedAccess.Condition; } else if (exception is TransactionAbortedException) { error.Condition = AmqpError.TransactionRollback.Condition; } else if (exception is NotSupportedException) { error.Condition = AmqpError.NotImplemented.Condition; } else if (exception is MessagingEntityNotFoundException) { error.Condition = AmqpError.NotFound.Condition; } else if (exception is MessagingEntityAlreadyExistsException) { error.Condition = ClientConstants.EntityAlreadyExistsError; } else if (exception is AddressAlreadyInUseException) { error.Condition = ClientConstants.AddressAlreadyInUseError; } else if (exception is AuthorizationFailedException) { error.Condition = ClientConstants.AuthorizationFailedError; } else if (exception is MessageLockLostException) { error.Condition = ClientConstants.MessageLockLostError; } else if (exception is SessionLockLostException) { error.Condition = ClientConstants.SessionLockLostError; } else if (exception is Microsoft.ServiceBus.Messaging.QuotaExceededException || exception is System.ServiceModel.QuotaExceededException) { error.Condition = AmqpError.ResourceLimitExceeded.Condition; } else if (exception is TimeoutException) { error.Condition = ClientConstants.TimeoutError; } else if (exception is NoMatchingSubscriptionException) { error.Condition = ClientConstants.NoMatchingSubscriptionError; } else if (exception is ServerBusyException) { error.Condition = ClientConstants.ServerBusyError; } else if (exception is MessageStoreLockLostException) { error.Condition = ClientConstants.StoreLockLostError; } else if (exception is SessionCannotBeLockedException) { error.Condition = ClientConstants.SessionCannotBeLockedError; } else if (exception is PartitionNotOwnedException) { error.Condition = ClientConstants.PartitionNotOwnedError; } else if (exception is MessagingEntityDisabledException) { error.Condition = ClientConstants.EntityDisabledError; } else if (exception is OperationCanceledException) { error.Condition = ClientConstants.OperationCancelledError; } else if (exception is RelayNotFoundException) { error.Condition = ClientConstants.RelayNotFoundError; } else if (exception is MessageSizeExceededException) { error.Condition = AmqpError.MessageSizeExceeded.Condition; } else if (!(exception is ReceiverDisconnectedException)) { error.Condition = AmqpError.InternalError.Condition; if (flag) { if (exception is InvalidOperationException) { error.Condition = AmqpError.NotAllowed.Condition; } else if (exception is ArgumentOutOfRangeException) { error.Condition = ClientConstants.ArgumentOutOfRangeError; } else if (exception is ArgumentException) { error.Condition = ClientConstants.ArgumentError; } } error.Description = (ExceptionHelper.IncludeExceptionDetails || flag ? error.Description : SRClient.InternalServerError); } else { error.Condition = AmqpError.Stolen.Condition; } if (ExceptionHelper.IncludeExceptionDetails) { string stackTrace = exception.StackTrace; if (stackTrace != null) { if (stackTrace.Length > 32768) { stackTrace = stackTrace.Substring(0, 32768); } if (error.Info == null) { error.Info = new Fields(); } error.Info.Add(ClientConstants.StackTraceName, stackTrace); } } return(error); }
void OnReceiveBegin(Begin begin) { StateTransition stateTransition; this.TransitState("R:BEGIN", StateTransition.ReceiveOpen, out stateTransition); this.incomingChannel.OnBegin(begin); if (stateTransition.To == AmqpObjectState.OpenReceived) { this.Open(); } else { Exception exception = null; Error error = this.Negotiate(begin); if (error != null) { exception = new AmqpException(error); } this.CompleteOpen(false, exception); if (exception != null) { this.TryClose(exception); } } }