示例#1
0
        protected override void OnProcessTransfer(Delivery delivery, Transfer transfer, Frame frame)
        {
            if (base.Settings.MaxMessageSize.HasValue)
            {
                ulong bytesTransfered = (ulong)(this.currentMessage.BytesTransfered + (long)frame.Payload.Count);
                if (bytesTransfered > base.Settings.MaxMessageSize.Value)
                {
                    if (!base.IsClosing())
                    {
                        Microsoft.ServiceBus.Messaging.Amqp.Framing.Error messageSizeExceeded = AmqpError.MessageSizeExceeded;
                        object value          = this.currentMessage.DeliveryId.Value;
                        object obj            = bytesTransfered;
                        ulong? maxMessageSize = base.Settings.MaxMessageSize;
                        throw new AmqpException(messageSizeExceeded, SRAmqp.AmqpMessageSizeExceeded(value, obj, maxMessageSize.Value));
                    }
                    return;
                }
            }
            ArraySegment <byte> payload = frame.Payload;

            frame.RawByteBuffer.AdjustPosition(payload.Offset, payload.Count);
            frame.RawByteBuffer.Clone();
            this.currentMessage.AddPayload(frame.RawByteBuffer, !transfer.More());
            if (!transfer.More())
            {
                AmqpMessage amqpMessage = this.currentMessage;
                this.currentMessage = null;
                Action <ReceivingAmqpLink, uint, int> action = (ReceivingAmqpLink source, uint id, int count) => {
                };
                SequenceNumber deliveryId = amqpMessage.DeliveryId;
                MessagingClientEtwProvider.TraceClient <ReceivingAmqpLink, uint, int>(action, this, deliveryId.Value, amqpMessage.RawByteBuffers.Count);
                this.OnReceiveMessage(amqpMessage);
            }
        }
示例#2
0
 private AmqpException(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error, string message, Exception innerException) : base(message ?? SRAmqp.AmqpErrorOccurred(error.Condition), innerException)
 {
     this.Error = error;
     if (!string.IsNullOrEmpty(message))
     {
         this.Error.Description = message;
     }
 }
示例#3
0
 public static AmqpException FromError(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error)
 {
     if (error == null || error.Condition.Value == null)
     {
         return(null);
     }
     if (error.Description != null)
     {
         return(new AmqpException(error, error.Description));
     }
     return(new AmqpException(AmqpError.GetError(error.Condition)));
 }
示例#4
0
        private Rejected GetRejectedOutcome(IDictionary <string, object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription)
        {
            object   obj;
            Rejected rejectedOutcome = AmqpConstants.RejectedOutcome;

            if (deadLetterReason != null || deadLetterErrorDescription != null || propertiesToModify != null)
            {
                Rejected rejected = new Rejected();
                Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error = new Microsoft.ServiceBus.Messaging.Amqp.Framing.Error()
                {
                    Condition = ClientConstants.DeadLetterName,
                    Info      = new Fields()
                };
                rejected.Error  = error;
                rejectedOutcome = rejected;
                if (deadLetterReason != null)
                {
                    rejectedOutcome.Error.Info.Add("DeadLetterReason", deadLetterReason);
                }
                if (deadLetterErrorDescription != null)
                {
                    rejectedOutcome.Error.Info.Add("DeadLetterErrorDescription", deadLetterErrorDescription);
                }
                if (propertiesToModify != null)
                {
                    foreach (KeyValuePair <string, object> keyValuePair in propertiesToModify)
                    {
                        if (!MessageConverter.TryGetAmqpObjectFromNetObject(keyValuePair.Value, MappingType.ApplicationProperty, out obj))
                        {
                            continue;
                        }
                        rejectedOutcome.Error.Info.Add(keyValuePair.Key, obj);
                    }
                }
            }
            return(rejectedOutcome);
        }
示例#5
0
            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;
            }
示例#6
0
            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;
            }
示例#7
0
 private AmqpException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     this.Error = (Microsoft.ServiceBus.Messaging.Amqp.Framing.Error)info.GetValue("Error", typeof(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error));
 }
示例#8
0
 public AmqpException(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error, Exception innerException) : this(error, error.Description ?? innerException.Message, innerException)
 {
 }
示例#9
0
 public AmqpException(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error, string message) : this(error, message, null)
 {
 }
示例#10
0
 public AmqpException(Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error) : this(error, error.Description, null)
 {
 }