protected override IEnumerator <IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .AsyncStep> GetAsyncSteps() { try { this.amqpMessage = this.CreateAmqpMessage(); } catch (Exception exception) { base.Complete(exception); goto Label0; } if (!this.parent.sendLink.TryGetOpenedObject(out this.amqpLink)) { AmqpMessageSender.SendAsyncResult sendAsyncResult = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.sendLink.BeginGetInstance(t, c, s); yield return(sendAsyncResult.CallAsync(beginCall, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.parent.sendLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { goto Label1; } base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.parent.messagingFactory.RemoteContainerId)); goto Label0; } Label1: if (this.amqpLink.Settings.MaxMessageSize.HasValue) { ulong serializedMessageSize = (ulong)this.amqpMessage.SerializedMessageSize; if (serializedMessageSize <= Convert.ToUInt64(this.amqpLink.Settings.MaxMessageSize)) { goto Label2; } AmqpMessageSender.SendAsyncResult sendAsyncResult1 = this; object value = this.amqpMessage.DeliveryId.Value; object obj = serializedMessageSize; ulong? maxMessageSize = this.amqpLink.Settings.MaxMessageSize; sendAsyncResult1.Complete(new MessageSizeExceededException(SRAmqp.AmqpMessageSizeExceeded(value, obj, maxMessageSize.Value))); goto Label0; } Label2: AmqpMessageSender.SendAsyncResult sendAsyncResult2 = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall1 = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.amqpLink.BeginSendMessage(thisPtr.amqpMessage, thisPtr.parent.GetDeliveryTag(), AmqpConstants.NullBinary, t, c, s); yield return(sendAsyncResult2.CallAsync(beginCall1, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.outcome = thisPtr.amqpLink.EndSendMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException != null) { base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.amqpLink.GetTrackingId())); } else if (this.outcome.DescriptorCode == Rejected.Code) { Rejected rejected = (Rejected)this.outcome; base.Complete(ExceptionHelper.ToMessagingContract(rejected.Error)); } Label0: yield break; }
public static Exception ToMessagingContract(Exception exception, string trackingId) { AmqpException amqpException = exception as AmqpException; if (amqpException != null) { return(ExceptionHelper.ToMessagingContract(amqpException.Error)); } return(ExceptionHelper.GetClientException(exception, trackingId)); }
protected override IEnumerator <IteratorAsyncResult <AmqpMessageReceiver.ReceiveAsyncResult> .AsyncStep> GetAsyncSteps() { if (!this.parent.receiveLink.TryGetOpenedObject(out this.amqpLink)) { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error = this.parent.GetSessionLockLostError(); if (error == null) { AmqpMessageReceiver.ReceiveAsyncResult receiveAsyncResult = this; IteratorAsyncResult <AmqpMessageReceiver.ReceiveAsyncResult> .BeginCall beginCall = (AmqpMessageReceiver.ReceiveAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.receiveLink.BeginGetInstance(t, c, s); yield return(receiveAsyncResult.CallAsync(beginCall, (AmqpMessageReceiver.ReceiveAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.parent.receiveLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { goto Label1; } if (this.shouldThrowTimeout || !(base.LastAsyncStepException is TimeoutException)) { base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.parent.messagingFactory.RemoteContainerId)); goto Label0; } else { base.Complete(null); goto Label0; } } else { base.Complete(ExceptionHelper.ToMessagingContract(error)); goto Label0; } } Label1: bool flag = true; do { Label3: if (!flag) { goto Label0; } AmqpMessageReceiver.ReceiveAsyncResult receiveAsyncResult1 = this; IteratorAsyncResult <AmqpMessageReceiver.ReceiveAsyncResult> .BeginCall beginCall1 = (AmqpMessageReceiver.ReceiveAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.BeginReceive(thisPtr.amqpLink, t, c, s); yield return(receiveAsyncResult1.CallAsync(beginCall1, (AmqpMessageReceiver.ReceiveAsyncResult thisPtr, IAsyncResult r) => thisPtr.AmqpMessages = thisPtr.EndReceive(thisPtr.amqpLink, r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { try { flag = false; if (this.AmqpMessages != null && this.AmqpMessages.Any <AmqpMessage>()) { flag = !this.ProcessMessage(this.AmqpMessages); } } catch (AmqpException amqpException) { base.Complete(ExceptionHelper.ToMessagingContract(amqpException.Error)); goto Label0; } if (base.RemainingTime() <= TimeSpan.Zero) { flag = false; } else { goto Label3; } } else { base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.amqpLink.GetTrackingId())); goto Label0; } }while (!this.shouldThrowTimeout); goto Label2; Label0: yield break; Label2: base.Complete(new TimeoutException(SRCore.TimeoutOnOperation(base.OriginalTimeout))); goto Label0; }
protected override IEnumerator <IteratorAsyncResult <AmqpMessageReceiver.DisposeAsyncResult> .AsyncStep> GetAsyncSteps() { Exception messagingContract; this.deliveryTag = this.PopulateDeliveryTag(); if (!this.parent.receiveLink.TryGetOpenedObject(out this.amqpLink)) { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error1 = this.parent.GetSessionLockLostError(); if (error1 == null) { AmqpMessageReceiver.DisposeAsyncResult disposeAsyncResult = this; IteratorAsyncResult <AmqpMessageReceiver.DisposeAsyncResult> .BeginCall beginCall = (AmqpMessageReceiver.DisposeAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.receiveLink.BeginGetInstance(t, c, s); yield return(disposeAsyncResult.CallAsync(beginCall, (AmqpMessageReceiver.DisposeAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.parent.receiveLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { goto Label1; } base.LastAsyncStepException = this.ProcessException(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.parent.messagingFactory.RemoteContainerId)); base.Complete(base.LastAsyncStepException); goto Label0; } else { base.Complete(ExceptionHelper.ToMessagingContract(error1)); goto Label0; } } Label1: AmqpMessageReceiver.DisposeAsyncResult disposeAsyncResult1 = this; IteratorAsyncResult <AmqpMessageReceiver.DisposeAsyncResult> .BeginCall beginCall1 = (AmqpMessageReceiver.DisposeAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.amqpLink.BeginDisposeMessage(thisPtr.deliveryTag, thisPtr.outcome, thisPtr.batchable, t, c, s); yield return(disposeAsyncResult1.CallAsync(beginCall1, (AmqpMessageReceiver.DisposeAsyncResult thisPtr, IAsyncResult r) => thisPtr.disposeOutcome = thisPtr.amqpLink.EndDisposeMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error = null; if (this.disposeOutcome.DescriptorCode == Rejected.Code) { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error2 = ((Rejected)this.disposeOutcome).Error; Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error3 = error2; error = error2; if (error3 != null) { if (!error.Condition.Equals(AmqpError.NotFound.Condition)) { base.LastAsyncStepException = ExceptionHelper.ToMessagingContract(error); } else if (this.IsDisposeWithoutSideEffect()) { base.LastAsyncStepException = null; } else if (!this.parent.sessionReceiver) { base.LastAsyncStepException = new MessageLockLostException(SRClient.MessageLockLost); } else { base.LastAsyncStepException = new SessionLockLostException(SRClient.SessionLockExpiredOnMessageSession); } base.Complete(this.ProcessException(base.LastAsyncStepException)); } } } else { if (!(base.LastAsyncStepException is OperationCanceledException) || this.amqpLink.State == AmqpObjectState.Opened) { base.LastAsyncStepException = ExceptionHelper.GetClientException(base.LastAsyncStepException, this.amqpLink.GetTrackingId()); } else if (!this.parent.sessionReceiver) { base.LastAsyncStepException = new MessageLockLostException(SRClient.MessageLockLost, base.LastAsyncStepException); } else { Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error4 = this.parent.GetSessionLockLostError(); AmqpMessageReceiver.DisposeAsyncResult disposeAsyncResult2 = this; if (error4 != null) { messagingContract = ExceptionHelper.ToMessagingContract(error4); } else { messagingContract = new SessionLockLostException(SRClient.SessionLockExpiredOnMessageSession, base.LastAsyncStepException); } disposeAsyncResult2.LastAsyncStepException = messagingContract; } base.Complete(this.ProcessException(base.LastAsyncStepException)); } Label0: yield break; }