protected override IEnumerator <IteratorAsyncResult <TIteratorAsyncResult> .AsyncStep> GetAsyncSteps()
        {
            if (this.Transaction == null)
            {
                this.wcfMessage = this.CreateWcfMessage();
            }
            else
            {
                SbmpMessageCreator sbmpMessageCreator1 = (this.controlMessageCreator == null ? this.MessageCreator : this.controlMessageCreator.Value);
                SbmpTransactionalAsyncResult <TIteratorAsyncResult>   sbmpTransactionalAsyncResult = this;
                IteratorAsyncResult <TIteratorAsyncResult> .BeginCall beginCall = (TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => {
                    SbmpResourceManager             resourceManager       = thisPtr.messagingFactory.ResourceManager;
                    System.Transactions.Transaction transaction           = thisPtr.Transaction;
                    IRequestSessionChannel          requestSessionChannel = thisPtr.channel;
                    SbmpMessageCreator sbmpMessageCreator = sbmpMessageCreator1;
                    object             obj = thisPtr;
                    return(resourceManager.BeginEnlist(transaction, requestSessionChannel, sbmpMessageCreator, new Action <RequestInfo>(obj.PartitionInfoSetter), t, c, s));
                };
                yield return(sbmpTransactionalAsyncResult.CallAsync(beginCall, (TIteratorAsyncResult thisPtr, IAsyncResult a) => thisPtr.txnSeqNumber = thisPtr.messagingFactory.ResourceManager.EndEnlist(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                this.wcfMessage = this.CreateWcfMessage();
                WorkUnitInfo.AddTo(this.wcfMessage.Headers, "TxnWorkUnit", this.Transaction.TransactionInformation.LocalIdentifier, this.txnSeqNumber);
            }
            SbmpTransactionalAsyncResult <TIteratorAsyncResult> sbmpTransactionalAsyncResult1 = this;

            IteratorAsyncResult <TIteratorAsyncResult> .BeginCall beginCall1 = (TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginRequest(thisPtr.wcfMessage, SbmpProtocolDefaults.BufferTimeout(t, this.messagingFactory.GetSettings().EnableAdditionalClientTimeout), c, s);
            yield return(sbmpTransactionalAsyncResult1.CallAsync(beginCall1, (TIteratorAsyncResult thisPtr, IAsyncResult a) => thisPtr.Response = thisPtr.channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
        }
Exemplo n.º 2
0
            protected override IEnumerator <IteratorAsyncResult <AmqpCbsLink.SendTokenAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                string str;

                AmqpCbsLink.SendTokenAsyncResult sendTokenAsyncResult = this;
                IteratorAsyncResult <AmqpCbsLink.SendTokenAsyncResult> .BeginCall beginCall = (AmqpCbsLink.SendTokenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.tokenProvider.BeginGetMessagingToken(this.namespaceAddress, thisPtr.resource, thisPtr.requiredClaims[0], false, t, c, s);
                yield return(sendTokenAsyncResult.CallAsync(beginCall, (AmqpCbsLink.SendTokenAsyncResult thisPtr, IAsyncResult r) => thisPtr.swt = (SimpleWebSecurityToken)thisPtr.tokenProvider.EndGetMessagingToken(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                if (this.swt is SharedAccessSignatureToken)
                {
                    str = "servicebus.windows.net:sastoken";
                }
                else if (this.swt != null)
                {
                    str = "amqp:swt";
                }
                else
                {
                    str = null;
                }
                string str1 = str;

                if (str1 != null)
                {
                    if (!this.cbsLink.FaultTolerantLink.TryGetOpenedObject(out this.requestResponseLink))
                    {
                        AmqpCbsLink.SendTokenAsyncResult sendTokenAsyncResult1 = this;
                        IteratorAsyncResult <AmqpCbsLink.SendTokenAsyncResult> .BeginCall beginCall1 = (AmqpCbsLink.SendTokenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.cbsLink.FaultTolerantLink.BeginGetInstance(t, c, s);
                        yield return(sendTokenAsyncResult1.CallAsync(beginCall1, (AmqpCbsLink.SendTokenAsyncResult thisPtr, IAsyncResult r) => thisPtr.requestResponseLink = thisPtr.cbsLink.FaultTolerantLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                    }
                    AmqpValue amqpValue = new AmqpValue()
                    {
                        Value = this.swt.Token
                    };
                    AmqpMessage applicationProperty = AmqpMessage.Create(amqpValue);
                    applicationProperty.ApplicationProperties = new ApplicationProperties();
                    applicationProperty.ApplicationProperties.Map["operation"]  = "put-token";
                    applicationProperty.ApplicationProperties.Map["type"]       = str1;
                    applicationProperty.ApplicationProperties.Map["name"]       = this.audience;
                    applicationProperty.ApplicationProperties.Map["expiration"] = this.swt.ExpiresOn;
                    AmqpMessage amqpMessage = null;
                    yield return(base.CallAsync((AmqpCbsLink.SendTokenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => this.requestResponseLink.BeginRequest(applicationProperty, t, c, s), (AmqpCbsLink.SendTokenAsyncResult thisPtr, IAsyncResult r) => amqpMessage = this.requestResponseLink.EndRequest(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                    int    item  = (int)amqpMessage.ApplicationProperties.Map["status-code"];
                    string item1 = (string)amqpMessage.ApplicationProperties.Map["status-description"];
                    if (item != 202)
                    {
                        base.Complete(AmqpCbsLink.SendTokenAsyncResult.ConvertToException(item, item1));
                    }
                    else
                    {
                        this.ValidTo = this.swt.ValidTo;
                    }
                }
                else
                {
                    base.Complete(new InvalidOperationException(SRAmqp.AmqpUnssuportedTokenType));
                }
            }
Exemplo n.º 3
0
            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;
            }
        protected override IEnumerator <IteratorAsyncResult <CloseOrAbortLinkAsyncResult> .AsyncStep> GetAsyncSteps()
        {
            Exception exception;

            if (this.batchManager != null)
            {
                if (!this.aborting)
                {
                    CloseOrAbortLinkAsyncResult closeOrAbortLinkAsyncResult = this;
                    IteratorAsyncResult <CloseOrAbortLinkAsyncResult> .BeginCall beginCall = (CloseOrAbortLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.batchManager.BeginClose(t, c, s);
                    IteratorAsyncResult <CloseOrAbortLinkAsyncResult> .EndCall   endCall   = (CloseOrAbortLinkAsyncResult thisPtr, IAsyncResult a) => thisPtr.batchManager.EndClose(a);
                    yield return(closeOrAbortLinkAsyncResult.CallAsync(beginCall, endCall, (CloseOrAbortLinkAsyncResult thisPtr, TimeSpan t) => thisPtr.batchManager.Close(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                }
                else
                {
                    this.batchManager.Abort();
                }
            }
            try
            {
                RequestInfo requestInfo = new RequestInfo()
                {
                    ServerTimeout = new TimeSpan?(SbmpProtocolDefaults.BufferTimeout(base.RemainingTime(), true))
                };
                RequestInfo requestInfo1 = requestInfo;
                this.closeMessage = this.linkMessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CloseLink", new CloseLinkCommand(), this.parentLinkId, null, null, requestInfo1);
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                if (Fx.IsFatal(exception1))
                {
                    throw;
                }
                CloseOrAbortLinkAsyncResult closeOrAbortLinkAsyncResult1 = this;
                if (this.aborting)
                {
                    exception = null;
                }
                else
                {
                    exception = exception1;
                }
                closeOrAbortLinkAsyncResult1.Complete(exception);
                goto Label0;
            }
            IteratorAsyncResult <CloseOrAbortLinkAsyncResult> .ExceptionPolicy exceptionPolicy = (this.aborting ? IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue : IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer);
            CloseOrAbortLinkAsyncResult closeOrAbortLinkAsyncResult2 = this;

            IteratorAsyncResult <CloseOrAbortLinkAsyncResult> .BeginCall beginCall1 = (CloseOrAbortLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginRequest(thisPtr.closeMessage, SbmpProtocolDefaults.BufferTimeout(t, true), c, s);
            yield return(closeOrAbortLinkAsyncResult2.CallAsync(beginCall1, (CloseOrAbortLinkAsyncResult thisPtr, IAsyncResult a) => thisPtr.channel.EndRequest(a), (IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy)exceptionPolicy));

Label0:
            yield break;
        }
        protected override IEnumerator <IteratorAsyncResult <GetMessageSessionsAsyncResult> .AsyncStep> GetAsyncSteps()
        {
            Message message = null;

            do
            {
                Message message1 = this.CreateRequestMessage();
                GetMessageSessionsAsyncResult getMessageSessionsAsyncResult = this;
                IteratorAsyncResult <GetMessageSessionsAsyncResult> .BeginCall beginCall = (GetMessageSessionsAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.MessagingFactory.Channel.BeginRequest(message1, SbmpProtocolDefaults.BufferTimeout(t, thisPtr.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), c, s);
                yield return(getMessageSessionsAsyncResult.CallAsync(beginCall, (GetMessageSessionsAsyncResult thisPtr, IAsyncResult r) => message = thisPtr.MessagingFactory.Channel.EndRequest(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));
            }while (base.LastAsyncStepException == null && message != null && this.ShouldContinue(message));
            base.Complete(base.LastAsyncStepException);
        }
Exemplo n.º 6
0
            protected override IEnumerator <IteratorAsyncResult <SbmpBrowsableMessageSession.GetStateAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                object obj  = null;
                bool   flag = false;

                if (this.sbmpMessageSession.InnerMessageReceiver == null)
                {
                    bool flag1 = false;
                    try
                    {
                        object thisLock = this.sbmpMessageSession.ThisLock;
                        object obj1     = thisLock;
                        obj = thisLock;
                        Monitor.Enter(obj1, ref flag1);
                        this.sbmpMessageSession.resetEvent.WaitOne();
                    }
                    finally
                    {
                        if (flag1)
                        {
                            Monitor.Exit(obj);
                        }
                    }
                    try
                    {
                        if (this.sbmpMessageSession.InnerMessageReceiver != null)
                        {
                            goto Label0;
                        }
                        flag = true;
                        SbmpBrowsableMessageSession.GetStateAsyncResult getStateAsyncResult = this;
                        IteratorAsyncResult <SbmpBrowsableMessageSession.GetStateAsyncResult> .BeginCall beginCall = (SbmpBrowsableMessageSession.GetStateAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.BeginAcceptMessageSessionBrowser(t, c, s);
                        yield return(getStateAsyncResult.CallAsync(beginCall, (SbmpBrowsableMessageSession.GetStateAsyncResult thisPtr, IAsyncResult r) => thisPtr.EndAcceptMessageSessionBrowser(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                    }
                    finally
                    {
                        this.sbmpMessageSession.resetEvent.Set();
                    }
                }
Label0:
                if (this.sbmpMessageSession.InnerMessageReceiver != null && !flag)
                {
                    GetSessionStateCommand getSessionStateCommand = new GetSessionStateCommand()
                    {
                        SessionId     = this.sbmpMessageSession.SessionId,
                        Timeout       = base.RemainingTime(),
                        TransactionId = null,
                        IsBrowseMode  = true
                    };
                    GetSessionStateCommand getSessionStateCommand1 = getSessionStateCommand;
                    RequestInfo            requestInfo1            = new RequestInfo()
                    {
                        ServerTimeout = new TimeSpan?(getSessionStateCommand1.Timeout)
                    };
                    RequestInfo         requestInfo          = requestInfo1;
                    SbmpMessageReceiver innerMessageReceiver = (SbmpMessageReceiver)this.sbmpMessageSession.InnerMessageReceiver;
                    this.wcfMessage = innerMessageReceiver.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageReceiver/GetSessionState", getSessionStateCommand1, null, this.sbmpMessageSession.RetryPolicy, this.trackingContext, requestInfo);
                    yield return(base.CallAsync((SbmpBrowsableMessageSession.GetStateAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => innerMessageReceiver.SbmpMessagingFactory.Channel.BeginRequest(thisPtr.wcfMessage, SbmpProtocolDefaults.BufferTimeout(t, innerMessageReceiver.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), c, s), (SbmpBrowsableMessageSession.GetStateAsyncResult thisPtr, IAsyncResult a) => thisPtr.Response = innerMessageReceiver.SbmpMessagingFactory.Channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                    if (base.LastAsyncStepException == null)
                    {
                        this.SessionState = this.Response.GetBody <GetSessionStateResponseCommand>().SessionState;
                    }
                }
            }
Exemplo n.º 7
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;
            }
 protected override IEnumerator <IteratorAsyncResult <AmqpSubscriptionClient.CloseAsyncResult> .AsyncStep> GetAsyncSteps()
 {
     if (this.client.controlLink.TryGetOpenedObject(out this.amqpLink))
     {
         AmqpSubscriptionClient.CloseAsyncResult closeAsyncResult = this;
         IteratorAsyncResult <AmqpSubscriptionClient.CloseAsyncResult> .BeginCall beginCall = (AmqpSubscriptionClient.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.client.messagingFactory.BeginCloseEntity(thisPtr.amqpLink, t, c, s);
         yield return(closeAsyncResult.CallAsync(beginCall, (AmqpSubscriptionClient.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.client.messagingFactory.EndCloseEntity(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
     }
     AmqpSubscriptionClient.CloseAsyncResult closeAsyncResult1 = this;
     IteratorAsyncResult <AmqpSubscriptionClient.CloseAsyncResult> .BeginCall beginCall1 = (AmqpSubscriptionClient.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.client.BaseOnBeginClose(t, c, s);
     IteratorAsyncResult <AmqpSubscriptionClient.CloseAsyncResult> .EndCall   endCall    = (AmqpSubscriptionClient.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.client.BaseOnEndClose(r);
     yield return(closeAsyncResult1.CallAsync(beginCall1, endCall, (AmqpSubscriptionClient.CloseAsyncResult thisPtr, TimeSpan t) => thisPtr.client.BaseOnClose(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
 }
Exemplo n.º 9
0
            protected override IEnumerator <IteratorAsyncResult <SocketMessageHelper.SendMessageAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                this.countBytes = BitConverter.GetBytes(this.messageBytes.Count);
                SocketMessageHelper.SendMessageAsyncResult sendMessageAsyncResult = this;
                IteratorAsyncResult <SocketMessageHelper.SendMessageAsyncResult> .BeginCall beginCall = (SocketMessageHelper.SendMessageAsyncResult thisRef, TimeSpan t, AsyncCallback c, object s) => thisRef.connection.BeginWrite(thisRef.countBytes, 0, (int)thisRef.countBytes.Length, true, t, c, s);
                yield return(sendMessageAsyncResult.CallAsync(beginCall, (SocketMessageHelper.SendMessageAsyncResult thisRef, IAsyncResult r) => thisRef.connection.EndWrite(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                SocketMessageHelper.SendMessageAsyncResult sendMessageAsyncResult1 = this;
                IteratorAsyncResult <SocketMessageHelper.SendMessageAsyncResult> .BeginCall beginCall1 = (SocketMessageHelper.SendMessageAsyncResult thisRef, TimeSpan t, AsyncCallback c, object s) => thisRef.connection.BeginWrite(thisRef.messageBytes.Array, thisRef.messageBytes.Offset, thisRef.messageBytes.Count, true, t, c, s);
                yield return(sendMessageAsyncResult1.CallAsync(beginCall1, (SocketMessageHelper.SendMessageAsyncResult thisRef, IAsyncResult r) => thisRef.connection.EndWrite(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
            }
Exemplo n.º 10
0
                protected override IEnumerator <IteratorAsyncResult <AmqpChannelListener.AmqpInputSessionChannel.TryReceiveAsyncResult> .AsyncStep> GetAsyncSteps()
                {
                    if (!this.inputChannel.DoneReceivingInCurrentState())
                    {
                        AmqpChannelListener.AmqpInputSessionChannel.TryReceiveAsyncResult tryReceiveAsyncResult = this;
                        IteratorAsyncResult <AmqpChannelListener.AmqpInputSessionChannel.TryReceiveAsyncResult> .BeginCall beginCall = (AmqpChannelListener.AmqpInputSessionChannel.TryReceiveAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.inputChannel.link.BeginReceiveMessage(t, c, s);
                        yield return(tryReceiveAsyncResult.CallAsync(beginCall, (AmqpChannelListener.AmqpInputSessionChannel.TryReceiveAsyncResult thisPtr, IAsyncResult a) => thisPtr.Outcome = thisPtr.inputChannel.link.EndReceiveMessage(a, out thisPtr.amqpMessage), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                        this.Message = this.inputChannel.AmqpMessageToChannelMessage(this.amqpMessage);
                        if (this.amqpMessage != null)
                        {
                            this.inputChannel.link.DisposeMessage(this.amqpMessage, AmqpConstants.AcceptedOutcome, true, this.amqpMessage.Batchable);
                        }
                    }
                    else
                    {
                        this.Message = null;
                        this.Outcome = true;
                    }
                }
            protected override IEnumerator <IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                if (this.factory.ShouldIntialize)
                {
                    SbmpMessagingFactory.OpenAsyncResult openAsyncResult = this;
                    IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .BeginCall beginCall = (SbmpMessagingFactory.OpenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => Microsoft.ServiceBus.Messaging.NetworkDetector.BeginCheckTcp(thisPtr.factory.baseAddresses, SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout), c, s);
                    yield return(openAsyncResult.CallAsync(beginCall, (SbmpMessagingFactory.OpenAsyncResult thisPtr, IAsyncResult r) => thisPtr.factory.Initialize(!Microsoft.ServiceBus.Messaging.NetworkDetector.EndCheckTcp(r), true, thisPtr.factory.baseAddresses), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));
                }
                SbmpMessagingFactory.OpenAsyncResult openAsyncResult1 = this;
                IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .BeginCall beginCall1 = (SbmpMessagingFactory.OpenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.ChannelFactory.BeginOpen(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout), c, s);
                IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .EndCall   endCall    = (SbmpMessagingFactory.OpenAsyncResult thisPtr, IAsyncResult r) => thisPtr.factory.ChannelFactory.EndOpen(r);
                yield return(openAsyncResult1.CallAsync(beginCall1, endCall, (SbmpMessagingFactory.OpenAsyncResult thisPtr, TimeSpan t) => thisPtr.factory.ChannelFactory.Open(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout)), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                if (this.ContinueAfterCommunicationException(base.LastAsyncStepException))
                {
                    EndpointAddress endpointAddress = this.factory.CreateEndpointAddress(string.Empty);
                    this.factory.Channel = this.factory.ChannelFactory.CreateChannel(endpointAddress);
                    SbmpMessagingFactory.OpenAsyncResult openAsyncResult2 = this;
                    IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .BeginCall beginCall2 = (SbmpMessagingFactory.OpenAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.Channel.BeginOpen(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout), c, s);
                    IteratorAsyncResult <SbmpMessagingFactory.OpenAsyncResult> .EndCall   endCall1   = (SbmpMessagingFactory.OpenAsyncResult thisPtr, IAsyncResult r) => thisPtr.factory.Channel.EndOpen(r);
                    yield return(openAsyncResult2.CallAsync(beginCall2, endCall1, (SbmpMessagingFactory.OpenAsyncResult thisPtr, TimeSpan t) => thisPtr.factory.Channel.Open(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout)), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                    this.ContinueAfterCommunicationException(base.LastAsyncStepException);
                }
            }
            protected override IEnumerator <IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                SbmpMessagingFactory.CloseAsyncResult closeAsyncResult = this;
                IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .BeginCall beginCall = (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.BaseOnBeginClose(t, c, s);
                IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .EndCall   endCall   = (SbmpMessagingFactory.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.factory.BaseOnEndClose(r);
                yield return(closeAsyncResult.CallAsync(beginCall, endCall, (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t) => thisPtr.factory.BaseClose(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                if (this.ContinueAfterCommunicationException(base.LastAsyncStepException))
                {
                    if (this.channel != null)
                    {
                        SbmpMessagingFactory.CloseAsyncResult closeAsyncResult1 = this;
                        IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .BeginCall beginCall1 = (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginClose(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout), c, s);
                        IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .EndCall   endCall1   = (SbmpMessagingFactory.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.channel.EndClose(r);
                        yield return(closeAsyncResult1.CallAsync(beginCall1, endCall1, (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t) => thisPtr.channel.Close(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout)), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        if (!this.ContinueAfterCommunicationException(base.LastAsyncStepException))
                        {
                            goto Label0;
                        }
                    }
                    if (this.factory.ChannelFactory != null)
                    {
                        SbmpMessagingFactory.CloseAsyncResult closeAsyncResult2 = this;
                        IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .BeginCall beginCall2 = (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.ChannelFactory.BeginClose(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout), c, s);
                        IteratorAsyncResult <SbmpMessagingFactory.CloseAsyncResult> .EndCall   endCall2   = (SbmpMessagingFactory.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.factory.ChannelFactory.EndClose(r);
                        yield return(closeAsyncResult2.CallAsync(beginCall2, endCall2, (SbmpMessagingFactory.CloseAsyncResult thisPtr, TimeSpan t) => thisPtr.factory.ChannelFactory.Close(SbmpProtocolDefaults.BufferTimeout(t, thisPtr.factory.GetSettings().EnableAdditionalClientTimeout)), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));
                    }
                    this.ContinueAfterCommunicationException(base.LastAsyncStepException);
                }
Label0:
                yield break;
            }
Exemplo n.º 13
0
                protected override IEnumerator <IteratorAsyncResult <SbmpResourceManager.TransactionEnlistment.CreateInstanceAsyncResult> .AsyncStep> GetAsyncSteps()
                {
                    CreateTransactionCommand createTransactionCommand = new CreateTransactionCommand()
                    {
                        TransactionId = this.owner.transactionId,
                        Timeout       = base.RemainingTime()
                    };
                    RequestInfo nullable = this.owner.RequestInfo.Clone();

                    nullable.ServerTimeout = new TimeSpan?(createTransactionCommand.Timeout);
                    nullable.TransactionId = createTransactionCommand.TransactionId;
                    this.request           = this.owner.messageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CreateTransaction", createTransactionCommand, nullable);
                    SbmpResourceManager.TransactionEnlistment.CreateInstanceAsyncResult createInstanceAsyncResult = this;
                    IteratorAsyncResult <SbmpResourceManager.TransactionEnlistment.CreateInstanceAsyncResult> .BeginCall beginCall = (SbmpResourceManager.TransactionEnlistment.CreateInstanceAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.owner.channel.BeginRequest(thisPtr.request, SbmpProtocolDefaults.BufferTimeout(t, thisPtr.owner.messageCreator.DisableClientOperationTimeBuffer), c, s);
                    yield return(createInstanceAsyncResult.CallAsync(beginCall, (SbmpResourceManager.TransactionEnlistment.CreateInstanceAsyncResult thisPtr, IAsyncResult r) => thisPtr.response = thisPtr.owner.channel.EndRequest(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                    if (this.response.IsFault)
                    {
                        base.Complete(new MessagingException(this.response.ToString()));
                    }
                }
        protected override IEnumerator <IteratorAsyncResult <GetRuntimeEntityDescriptionAsyncResult> .AsyncStep> GetAsyncSteps()
        {
            MessagingClientEtwProvider.TraceClient(() => {
            });
            if (!this.executeOnce)
            {
                while (this.ShouldGetEntityInfo(MessagingExceptionHelper.Unwrap(base.LastAsyncStepException as CommunicationException)))
                {
                    if (!RuntimeEntityDescriptionCache.TryGet(this.entityAddress, out this.runtimeEntityDescription))
                    {
                        this.request = this.CreateOrGetRequestMessage();
                        GetRuntimeEntityDescriptionAsyncResult getRuntimeEntityDescriptionAsyncResult     = this;
                        IteratorAsyncResult <GetRuntimeEntityDescriptionAsyncResult> .BeginCall beginCall = (GetRuntimeEntityDescriptionAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.Channel.BeginRequest(thisPtr.request, t, c, s);
                        yield return(getRuntimeEntityDescriptionAsyncResult.CallAsync(beginCall, (GetRuntimeEntityDescriptionAsyncResult thisPtr, IAsyncResult a) => thisPtr.response = thisPtr.factory.Channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        if (base.LastAsyncStepException == null)
                        {
                            this.runtimeEntityDescription = GetRuntimeEntityDescriptionAsyncResult.BuildRuntimeEntityDescription(this.response);
                            RuntimeEntityDescriptionCache.AddOrUpdate(this.entityAddress, this.runtimeEntityDescription);
                            this.clientEntity.RuntimeEntityDescription = this.runtimeEntityDescription;
                        }
                        else
                        {
                            if (!base.LastAsyncStepException.IsWrappedExceptionTransient())
                            {
                                yield return(base.CallAsyncSleep(Constants.GetRuntimeEntityDescriptionNonTransientSleepTimeout));
                            }
                            else
                            {
                                yield return(base.CallAsyncSleep(TimeSpan.FromSeconds((double)(this.attempt % 60)) + TimeSpan.FromMilliseconds((double)ConcurrentRandom.Next(1, 1000))));
                            }
                            GetRuntimeEntityDescriptionAsyncResult getRuntimeEntityDescriptionAsyncResult1 = this;
                            getRuntimeEntityDescriptionAsyncResult1.attempt = getRuntimeEntityDescriptionAsyncResult1.attempt + 1;
                        }
                    }
                    else
                    {
                        this.clientEntity.RuntimeEntityDescription = this.runtimeEntityDescription;
                    }
                }
            }
            else
            {
                if (!RuntimeEntityDescriptionCache.TryGet(this.entityAddress, out this.runtimeEntityDescription))
                {
                    this.request = this.CreateOrGetRequestMessage();
                    GetRuntimeEntityDescriptionAsyncResult getRuntimeEntityDescriptionAsyncResult2     = this;
                    IteratorAsyncResult <GetRuntimeEntityDescriptionAsyncResult> .BeginCall beginCall1 = (GetRuntimeEntityDescriptionAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.factory.Channel.BeginRequest(thisPtr.request, t, c, s);
                    yield return(getRuntimeEntityDescriptionAsyncResult2.CallAsync(beginCall1, (GetRuntimeEntityDescriptionAsyncResult thisPtr, IAsyncResult a) => thisPtr.response = thisPtr.factory.Channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                    this.runtimeEntityDescription = GetRuntimeEntityDescriptionAsyncResult.BuildRuntimeEntityDescription(this.response);
                    RuntimeEntityDescriptionCache.AddOrUpdate(this.entityAddress, this.runtimeEntityDescription);
                }
                this.clientEntity.RuntimeEntityDescription = this.runtimeEntityDescription;
            }
        }
 protected override IEnumerator <IteratorAsyncResult <SbmpSubscriptionClient.CloseAsyncResult> .AsyncStep> GetAsyncSteps()
 {
     if (!this.aborting)
     {
         if (this.parent.ControlMessageCreator.IsValueCreated)
         {
             SbmpSubscriptionClient.CloseAsyncResult closeAsyncResult = this;
             IteratorAsyncResult <SbmpSubscriptionClient.CloseAsyncResult> .BeginCall beginCall = (SbmpSubscriptionClient.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => (new CloseOrAbortLinkAsyncResult(thisPtr.parent.ControlMessageCreator.Value, ((SbmpMessagingFactory)thisPtr.parent.MessagingFactory).Channel, null, t, false, c, s)).Start();
             yield return(closeAsyncResult.CallAsync(beginCall, (SbmpSubscriptionClient.CloseAsyncResult thisPtr, IAsyncResult r) => AsyncResult <CloseOrAbortLinkAsyncResult> .End(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
         }
         SbmpSubscriptionClient.CloseAsyncResult closeAsyncResult1 = this;
         IteratorAsyncResult <SbmpSubscriptionClient.CloseAsyncResult> .BeginCall beginCall1 = (SbmpSubscriptionClient.CloseAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.BaseBeginClose(t, c, s);
         yield return(closeAsyncResult1.CallAsync(beginCall1, (SbmpSubscriptionClient.CloseAsyncResult thisPtr, IAsyncResult r) => thisPtr.parent.EndBaseClose(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
     }
     else
     {
         if (this.parent.ControlMessageCreator.IsValueCreated)
         {
             CloseOrAbortLinkAsyncResult closeOrAbortLinkAsyncResult = new CloseOrAbortLinkAsyncResult(this.parent.ControlMessageCreator.Value, ((SbmpMessagingFactory)this.parent.MessagingFactory).Channel, null, base.RemainingTime(), true, null, null);
             closeOrAbortLinkAsyncResult.Schedule();
         }
         this.parent.BaseAbort();
     }
 }
Exemplo n.º 16
0
            protected override IEnumerator <IteratorAsyncResult <AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                if (!this.managementLink.FaultTolerantLink.TryGetOpenedObject(out this.requestResponseLink))
                {
                    AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult getEventHubRuntimeInfoAsyncResult          = this;
                    IteratorAsyncResult <AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult> .BeginCall beginCall = (AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.managementLink.FaultTolerantLink.BeginGetInstance(t, c, s);
                    yield return(getEventHubRuntimeInfoAsyncResult.CallAsync(beginCall, (AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult thisPtr, IAsyncResult r) => thisPtr.requestResponseLink = thisPtr.managementLink.FaultTolerantLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                }
                AmqpMessage applicationProperty = AmqpMessage.Create();

                applicationProperty.ApplicationProperties                  = new ApplicationProperties();
                applicationProperty.ApplicationProperties.Map["name"]      = this.eventHubPath;
                applicationProperty.ApplicationProperties.Map["operation"] = "READ";
                applicationProperty.ApplicationProperties.Map["type"]      = "com.microsoft:eventhub";
                AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult getEventHubRuntimeInfoAsyncResult1          = this;
                IteratorAsyncResult <AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult> .BeginCall beginCall1 = (AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.requestResponseLink.BeginRequest(applicationProperty, t, c, s);
                yield return(getEventHubRuntimeInfoAsyncResult1.CallAsync(beginCall1, (AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult thisPtr, IAsyncResult r) => thisPtr.getRuntimeInfoResponse = thisPtr.requestResponseLink.EndRequest(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                int    item = (int)this.getRuntimeInfoResponse.ApplicationProperties.Map["status-code"];
                string str  = (string)this.getRuntimeInfoResponse.ApplicationProperties.Map["status-description"];

                if (item != 200)
                {
                    base.Complete(AmqpManagementLink.GetEventHubRuntimeInfoAsyncResult.ConvertToException(item, str));
                }
                else
                {
                    this.Result = MessageConverter.GetEventHubRuntimeInfo(this.getRuntimeInfoResponse);
                }
            }
Exemplo n.º 17
0
            protected override IEnumerator <IteratorAsyncResult <WebSocketRelayedConnectionListener.ConnectAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                Uri uri = ServiceBusUriHelper.CreateServiceUri(Uri.UriSchemeHttps, this.Request.HttpsEndpoint.ToString(), "/");
                ServiceBusClientWebSocket serviceBusClientWebSocket = new ServiceBusClientWebSocket("wsrelayedconnection");

                yield return(base.CallAsync((WebSocketRelayedConnectionListener.ConnectAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => serviceBusClientWebSocket.BeginConnect(uri.Host, uri.Port, ConnectConstants.ConnectionInitiateTimeout, c, s), (WebSocketRelayedConnectionListener.ConnectAsyncResult thisPtr, IAsyncResult r) => serviceBusClientWebSocket.EndConnect(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                this.connection         = new ClientWebSocketConnection(serviceBusClientWebSocket, this.relayedConnectionListener.bufferSize, this.relayedConnectionListener.uri, this.Activity);
                this.message            = Message.CreateMessage(this.relayedConnectionListener.messageHelper.MessageVersion, "RelayedAccept", new AcceptMessage(this.Request.Id));
                this.message.Headers.To = EndpointAddress.AnonymousUri;
                WebSocketRelayedConnectionListener.ConnectAsyncResult connectAsyncResult = this;
                IteratorAsyncResult <WebSocketRelayedConnectionListener.ConnectAsyncResult> .BeginCall beginCall = (WebSocketRelayedConnectionListener.ConnectAsyncResult thisRef, TimeSpan t, AsyncCallback c, object s) => thisRef.relayedConnectionListener.messageHelper.BeginSendMessage(thisRef.connection, thisRef.message, t, c, s);
                yield return(connectAsyncResult.CallAsync(beginCall, (WebSocketRelayedConnectionListener.ConnectAsyncResult thisRef, IAsyncResult r) => thisRef.relayedConnectionListener.messageHelper.EndSendMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                IOThreadScheduler.ScheduleCallbackNoFlow(new Action <object>(this.relayedConnectionListener.BeginConnectCallback), this.connection);
            }
Exemplo n.º 18
0
            protected override IEnumerator <IteratorAsyncResult <SbmpMessageSender.CancelScheduledMessageCommandAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                CancelScheduledMessageCommand cancelScheduledMessageCommand = new CancelScheduledMessageCommand()
                {
                    SequenceNumbers = this.sequenceNumbers,
                    Timeout         = base.RemainingTime(),
                    TransactionId   = null
                };
                CancelScheduledMessageCommand cancelScheduledMessageCommand1 = cancelScheduledMessageCommand;
                RequestInfo requestInfo1 = new RequestInfo()
                {
                    ServerTimeout = new TimeSpan?(cancelScheduledMessageCommand1.Timeout),
                    TransactionId = cancelScheduledMessageCommand1.TransactionId
                };
                RequestInfo nullable = requestInfo1;

                nullable.SequenceNumber = new long?(this.sequenceNumbers.First <long>());
                if (this.trackingContext != null)
                {
                    SbmpMessageSender.TraceCancel(this.relatedActivity, this.trackingContext, this.sequenceNumbers);
                }
                this.wcfMessage = this.messageSender.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageSender/CancelScheduledMessage", cancelScheduledMessageCommand1, null, this.messageSender.RetryPolicy, this.trackingContext, nullable);
                SbmpMessageSender.CancelScheduledMessageCommandAsyncResult cancelScheduledMessageCommandAsyncResult   = this;
                IteratorAsyncResult <SbmpMessageSender.CancelScheduledMessageCommandAsyncResult> .BeginCall beginCall = (SbmpMessageSender.CancelScheduledMessageCommandAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.messageSender.SbmpMessagingFactory.Channel.BeginRequest(thisPtr.wcfMessage, thisPtr.OriginalTimeout, c, s);
                yield return(cancelScheduledMessageCommandAsyncResult.CallAsync(beginCall, (SbmpMessageSender.CancelScheduledMessageCommandAsyncResult thisPtr, IAsyncResult r) => thisPtr.messageSender.SbmpMessagingFactory.Channel.EndRequest(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
            }
Exemplo n.º 19
0
 protected override IEnumerator <IteratorAsyncResult <SocketMessageHelper.ReceiveBytesAsyncResult> .AsyncStep> GetAsyncSteps()
 {
     SocketMessageHelper.ReceiveBytesAsyncResult receiveBytesAsyncResult = this;
     IteratorAsyncResult <SocketMessageHelper.ReceiveBytesAsyncResult> .BeginCall readBytesAsyncResult = (SocketMessageHelper.ReceiveBytesAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => new SocketMessageHelper.ReadBytesAsyncResult(thisPtr.connection, thisPtr.size, false, t, c, s);
     yield return(receiveBytesAsyncResult.CallAsync(readBytesAsyncResult, (SocketMessageHelper.ReceiveBytesAsyncResult thisPtr, IAsyncResult r) => thisPtr.Bytes = AsyncResult <SocketMessageHelper.ReadBytesAsyncResult> .End(r).Bytes, IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
 }
Exemplo n.º 20
0
            protected override IEnumerator <IteratorAsyncResult <SbmpMessageSender.ScheduleMessageCommandAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                ScheduleMessageCommand scheduleMessageCommand = new ScheduleMessageCommand()
                {
                    Messages      = MessageCollection.Wrap(this.messages),
                    Timeout       = base.RemainingTime(),
                    TransactionId = null
                };
                ScheduleMessageCommand scheduleMessageCommand1 = scheduleMessageCommand;
                RequestInfo            requestInfo1            = new RequestInfo()
                {
                    ServerTimeout = new TimeSpan?(scheduleMessageCommand1.Timeout),
                    TransactionId = scheduleMessageCommand1.TransactionId
                };
                RequestInfo requestInfo = requestInfo1;

                this.messageSender.AddRequestInfoHeader(requestInfo, this.messages);
                if (this.trackingContext != null)
                {
                    SbmpMessageSender.TraceSend(this.relatedActivity, this.trackingContext, this.messages);
                }
                this.wcfMessage = this.messageSender.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageSender/ScheduleMessage", scheduleMessageCommand1, null, this.messageSender.RetryPolicy, this.trackingContext, requestInfo);
                SbmpMessageSender.ScheduleMessageCommandAsyncResult scheduleMessageCommandAsyncResult          = this;
                IteratorAsyncResult <SbmpMessageSender.ScheduleMessageCommandAsyncResult> .BeginCall beginCall = (SbmpMessageSender.ScheduleMessageCommandAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.messageSender.SbmpMessagingFactory.Channel.BeginRequest(thisPtr.wcfMessage, thisPtr.OriginalTimeout, c, s);
                yield return(scheduleMessageCommandAsyncResult.CallAsync(beginCall, (SbmpMessageSender.ScheduleMessageCommandAsyncResult thisPtr, IAsyncResult a) => thisPtr.response = thisPtr.messageSender.SbmpMessagingFactory.Channel.EndRequest(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                ScheduleMessageResponseCommand body = this.response.GetBody <ScheduleMessageResponseCommand>();

                if (body.SequenceNumbers != null)
                {
                    foreach (long sequenceNumber in body.SequenceNumbers)
                    {
                        this.SequenceNumbers.Add(sequenceNumber);
                    }
                }
            }
Exemplo n.º 21
0
                    protected override IEnumerator <IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .AsyncStep> GetAsyncSteps()
                    {
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue;
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue1;
                        string str;
                        object obj;

                        this.ThrowIfNotSupportedClientSettings();
                        Message message = null;
                        int     num     = this.incomingMessage.Headers.FindHeader("Authorization", "http://schemas.microsoft.com/servicebus/2010/08/protocol/");
                        string  empty   = string.Empty;

                        if (this.incomingMessage.Properties != null && this.incomingMessage.Properties.TryGetValue("ParentLinkId", out obj))
                        {
                            empty = (string)obj;
                        }
                        LinkInfo header = LinkInfo.GetHeader(this.incomingMessage.Headers);
                        bool     flag   = !string.IsNullOrWhiteSpace(empty);

                        str = (flag ? empty : header.LinkId);
                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey entityLinkKey = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey(header.EntityName, str);

                        RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue entityLinkValue2 = null;
                        IRequestSessionChannel requestSessionChannel = null;

                        if (this.sessionChannel.containerNameResolutionMode != ContainerNameResolutionMode.DisableRedirect && !string.IsNullOrEmpty(entityLinkKey.EntityName) && !this.sessionChannel.entityMap.TryGetValue(entityLinkKey, out entityLinkValue2))
                        {
                            if (!this.sessionChannel.bindingElement.EnableRedirect)
                            {
                                RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult = this;
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.primaryChannel.BeginRequest(thisPtr.incomingMessage, t, c, s);
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .EndCall   endCall   = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => message = thisPtr.sessionChannel.primaryChannel.EndRequest(r);
                                yield return(requestAsyncResult.CallAsync(beginCall, endCall, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => message = thisPtr.sessionChannel.primaryChannel.Request(thisPtr.incomingMessage, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                            }
                            else
                            {
                                RedirectCommand redirectCommand = new RedirectCommand();
                                Message         to = Message.CreateMessage(this.incomingMessage.Version, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpRedirect/Redirect", redirectCommand);
                                to.Headers.To = this.incomingMessage.Headers.To;
                                header.AddTo(to.Headers);
                                if (num >= 0)
                                {
                                    to.Headers.CopyHeaderFrom(this.incomingMessage.Headers, num);
                                }
                                RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult1 = this;
                                IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall1 = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.primaryChannel.BeginRequest(to, t, c, s);
                                yield return(requestAsyncResult1.CallAsync(beginCall1, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => message = thisPtr.sessionChannel.primaryChannel.EndRequest(r), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => message = thisPtr.sessionChannel.primaryChannel.Request(to, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                            }
                            if (message == null || !string.Equals(message.Headers.Action, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpRedirect/RedirectResponse", StringComparison.OrdinalIgnoreCase))
                            {
                                if (base.LastAsyncStepException != null)
                                {
                                    goto Label1;
                                }
                                this.ResponseMessage = message;
                                if (!flag && string.Equals(this.incomingMessageAction, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CloseLink", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.sessionChannel.entityMap.TryRemove(entityLinkKey, out entityLinkValue);
                                    goto Label0;
                                }
                                else
                                {
                                    goto Label0;
                                }
                            }
                            else
                            {
                                LinkInfo linkInfo            = LinkInfo.GetHeader(message.Headers);
                                RedirectResponseCommand body = message.GetBody <RedirectResponseCommand>();
                                entityLinkValue2 = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue(body.RedirectTo, linkInfo);

                                this.sessionChannel.containerNameResolutionMode = body.ContainerNameResolutionMode;
                                this.ThrowIfNotSupportedClientSettings();
                                if (body.ContainerNameResolutionMode != ContainerNameResolutionMode.DisableRedirect)
                                {
                                    this.sessionChannel.entityMap.TryAdd(entityLinkKey, entityLinkValue2);
                                }
                            }
                        }
Label1:
                        if (entityLinkValue2 == null || this.sessionChannel.containerNameResolutionMode == ContainerNameResolutionMode.DisableRedirect || !this.sessionChannel.bindingElement.EnableRedirect && this.sessionChannel.containerNameResolutionMode == ContainerNameResolutionMode.AllowRedirect)
                        {
                            requestSessionChannel = this.sessionChannel.primaryChannel;
                        }
                        else
                        {
                            RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult requestAsyncResult2 = this;
                            IteratorAsyncResult <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult> .BeginCall beginCall2 = (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sessionChannel.correlatorManager.BeginGetCorrelator(entityLinkValue2.ContainerLocation, t, c, s);
                            yield return(requestAsyncResult2.CallAsync(beginCall2, (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult a) => requestSessionChannel = thisPtr.sessionChannel.correlatorManager.EndGetCorrelator(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                            this.incomingMessage.Headers.RemoveAll("LinkInfo", "http://schemas.microsoft.com/netservices/2011/06/servicebus");
                            header.TransferDestinationEntityAddress           = entityLinkValue2.UpdatedLinkInfo.TransferDestinationEntityAddress;
                            header.TransferDestinationMessagingInstanceHandle = entityLinkValue2.UpdatedLinkInfo.TransferDestinationMessagingInstanceHandle;
                            header.TransferDestinationResourceResourceId      = entityLinkValue2.UpdatedLinkInfo.TransferDestinationResourceResourceId;
                            header.EntityType = entityLinkValue2.UpdatedLinkInfo.EntityType;
                            header.EntityName = entityLinkValue2.UpdatedLinkInfo.EntityName;
                            header.AddTo(this.incomingMessage.Headers);
                        }
                        if (!flag && string.Equals(this.incomingMessageAction, "http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/CloseLink", StringComparison.OrdinalIgnoreCase))
                        {
                            this.sessionChannel.entityMap.TryRemove(entityLinkKey, out entityLinkValue1);
                        }
                        yield return(base.CallAsync((RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => requestSessionChannel.BeginRequest(thisPtr.incomingMessage, t, c, s), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, IAsyncResult r) => thisPtr.ResponseMessage = requestSessionChannel.EndRequest(r), (RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.RequestAsyncResult thisPtr, TimeSpan t) => thisPtr.ResponseMessage = requestSessionChannel.Request(thisPtr.incomingMessage, t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

Label0:
                        yield break;
                    }
Exemplo n.º 22
0
            protected override IEnumerator <IteratorAsyncResult <T> .AsyncStep> GetAsyncSteps()
            {
                bool     flag;
                TimeSpan timeSpan;

                while (true)
                {
                    bool flag1 = false;
                    if (!this.bypassCache)
                    {
                        lock (this.TokenProvider.mutex)
                        {
                            TokenProvider.TokenInfo tokenInfoFromCache = this.TokenProvider.GetTokenInfoFromCache(this.cacheKey);
                            flag = this.OnProcessCachedEntryFromTokenProvider(tokenInfoFromCache);
                        }
                        if (flag)
                        {
                            break;
                        }
                    }
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    try
                    {
                        TokenProvider.GetTokenAsyncResultBase <T> getTokenAsyncResultBase = this;
                        IteratorAsyncResult <T> .BeginCall        getTokenBeginCall       = this.GetTokenBeginCall;
                        yield return(getTokenAsyncResultBase.CallAsync(getTokenBeginCall, (T thisPtr, IAsyncResult r) => thisPtr.OnCompletion(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        if (base.LastAsyncStepException != null)
                        {
                            goto Label0;
                        }
                        stopwatch.Stop();
                        MessagingPerformanceCounters.IncrementTokenAcquisitionLatency(this.appliesToUri, stopwatch.ElapsedTicks);
                        MessagingPerformanceCounters.IncrementTokensAcquiredPerSec(this.appliesToUri, 1);
                        break;
                    }
                    finally
                    {
                        stopwatch.Stop();
                    }
Label0:
                    MessagingPerformanceCounters.IncrementTokenAcquisitionFailuresPerSec(this.appliesToUri, 1);
                    SecurityTokenException lastAsyncStepException = base.LastAsyncStepException as SecurityTokenException;
                    TokenProviderException tokenProviderException = base.LastAsyncStepException as TokenProviderException;
                    TimeoutException       timeoutException       = base.LastAsyncStepException as TimeoutException;
                    if (timeoutException != null && timeoutException.InnerException != null && timeoutException.InnerException is WebException)
                    {
                        flag1 = true;
                    }
                    else if (tokenProviderException != null && tokenProviderException.InnerException != null && tokenProviderException.InnerException is WebException)
                    {
                        flag1 = true;
                    }
                    else if (lastAsyncStepException != null)
                    {
                        TokenProviderHelper.InternalSecurityTokenException internalSecurityTokenException = lastAsyncStepException as TokenProviderHelper.InternalSecurityTokenException;
                        flag1 = true;
                        if (internalSecurityTokenException != null)
                        {
                            base.LastAsyncStepException = new SecurityTokenException(internalSecurityTokenException.Message, internalSecurityTokenException.InnerException);
                            switch (internalSecurityTokenException.StatusCode)
                            {
                            case HttpStatusCode.BadRequest:
                            case HttpStatusCode.Unauthorized:
                            {
                                flag1 = false;
                                break;
                            }
                            }
                        }
                    }
                    if (flag1)
                    {
                        TimeSpan timeSpan1 = base.RemainingTime();
                        if (timeSpan1 <= TimeSpan.Zero)
                        {
                            flag1 = false;
                        }
                        else
                        {
                            yield return(base.CallAsyncSleep(TimeoutHelper.Min(this.retrySleepTime, timeSpan1)));

                            TimeSpan timeSpan2 = this.retrySleepTime.Add(this.retrySleepTime);
                            TokenProvider.GetTokenAsyncResultBase <T> getTokenAsyncResultBase1 = this;
                            timeSpan = (timeSpan2 < TokenProvider.MaxRetrySleepTime ? timeSpan2 : TokenProvider.MaxRetrySleepTime);
                            getTokenAsyncResultBase1.retrySleepTime = timeSpan;
                        }
                    }
                    if (!flag1)
                    {
                        if (base.LastAsyncStepException == null)
                        {
                            break;
                        }
                        base.Complete(base.LastAsyncStepException);
                        break;
                    }
                }
            }
            protected override IEnumerator <IteratorAsyncResult <AmqpSubscriptionClient.RuleAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                if (!this.client.controlLink.TryGetOpenedObject(out this.amqpLink))
                {
                    AmqpSubscriptionClient.RuleAsyncResult ruleAsyncResult = this;
                    IteratorAsyncResult <AmqpSubscriptionClient.RuleAsyncResult> .BeginCall beginCall = (AmqpSubscriptionClient.RuleAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.client.controlLink.BeginGetInstance(t, c, s);
                    yield return(ruleAsyncResult.CallAsync(beginCall, (AmqpSubscriptionClient.RuleAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.client.controlLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                }
                AmqpValue amqpValue = new AmqpValue()
                {
                    Value = this.CreateCommand()
                };
                AmqpMessage amqpMessage = AmqpMessage.Create(amqpValue);

                amqpMessage.Batchable = false;
                AmqpSubscriptionClient.RuleAsyncResult ruleAsyncResult1 = this;
                IteratorAsyncResult <AmqpSubscriptionClient.RuleAsyncResult> .BeginCall beginCall1 = (AmqpSubscriptionClient.RuleAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.amqpLink.BeginSendMessage(amqpMessage, thisPtr.client.GetControlMessageDeliveryTag(), new ArraySegment <byte>(), t, c, s);
                yield return(ruleAsyncResult1.CallAsync(beginCall1, (AmqpSubscriptionClient.RuleAsyncResult thisPtr, IAsyncResult r) => thisPtr.outcome = thisPtr.amqpLink.EndSendMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));

                if (this.outcome.DescriptorCode == Rejected.Code)
                {
                    base.Complete(ExceptionHelper.ToMessagingContract(((Rejected)this.outcome).Error));
                }
            }
Exemplo n.º 24
0
 protected override IEnumerator <IteratorAsyncResult <ContainerChannelManager.OpenInstanceAsyncResult> .AsyncStep> GetAsyncSteps()
 {
     ContainerChannelManager.OpenInstanceAsyncResult openInstanceAsyncResult = this;
     IteratorAsyncResult <ContainerChannelManager.OpenInstanceAsyncResult> .BeginCall beginCall = (ContainerChannelManager.OpenInstanceAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginOpen(t, c, s);
     IteratorAsyncResult <ContainerChannelManager.OpenInstanceAsyncResult> .EndCall   endCall   = (ContainerChannelManager.OpenInstanceAsyncResult thisPtr, IAsyncResult r) => thisPtr.channel.EndOpen(r);
     yield return(openInstanceAsyncResult.CallAsync(beginCall, endCall, (ContainerChannelManager.OpenInstanceAsyncResult thisPtr, TimeSpan t) => thisPtr.channel.Open(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
 }
Exemplo n.º 25
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;
            }
 protected override IEnumerator <IteratorAsyncResult <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .AsyncStep> GetAsyncSteps()
 {
     if (this.channel != null)
     {
         if (!this.abort)
         {
             SharedChannel <TChannel> .CloseOrAbortAsyncResult closeOrAbortAsyncResult = this;
             IteratorAsyncResult <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .BeginCall beginCall = (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.channel.BeginClose(t, c, s);
             IteratorAsyncResult <SharedChannel <TChannel> .CloseOrAbortAsyncResult> .EndCall   endCall   = (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, IAsyncResult r) => thisPtr.channel.EndClose(r);
             yield return(closeOrAbortAsyncResult.CallAsync(beginCall, endCall, (SharedChannel <TChannel> .CloseOrAbortAsyncResult thisPtr, TimeSpan t) => thisPtr.channel.Close(t), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
         }
         else
         {
             this.channel.Abort();
         }
     }
 }
Exemplo n.º 27
0
            protected override IEnumerator <IteratorAsyncResult <AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                string str = "$cbs";

                if (base.RemainingTime() > TimeSpan.Zero)
                {
                    try
                    {
                        AmqpSessionSettings amqpSessionSetting = new AmqpSessionSettings()
                        {
                            Properties = new Fields()
                        };
                        this.session = new AmqpSession(this.connection, amqpSessionSetting, this);
                        this.connection.AddSession(this.session, null);
                    }
                    catch (InvalidOperationException invalidOperationException1)
                    {
                        InvalidOperationException invalidOperationException = invalidOperationException1;
                        base.Complete(new MessagingException(invalidOperationException.Message, false, invalidOperationException));
                        goto Label0;
                    }
                    AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult openCbsRequestResponseLinkAsyncResult      = this;
                    IteratorAsyncResult <AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult> .BeginCall beginCall = (AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.session.BeginOpen(t, c, s);
                    yield return(openCbsRequestResponseLinkAsyncResult.CallAsync(beginCall, (AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult thisPtr, IAsyncResult r) => thisPtr.session.EndOpen(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                    Exception lastAsyncStepException = base.LastAsyncStepException;
                    if (lastAsyncStepException == null)
                    {
                        AmqpLinkSettings amqpLinkSetting  = new AmqpLinkSettings();
                        AmqpLinkSettings amqpLinkSetting1 = amqpLinkSetting;
                        AmqpSymbol       timeoutName      = ClientConstants.TimeoutName;
                        TimeSpan         timeSpan         = base.RemainingTime();
                        amqpLinkSetting1.AddProperty(timeoutName, (uint)timeSpan.TotalMilliseconds);
                        amqpLinkSetting.Target = new Target()
                        {
                            Address = str
                        };
                        amqpLinkSetting.Source = new Source()
                        {
                            Address = str
                        };
                        amqpLinkSetting.InitialDeliveryCount = new uint?(0);
                        amqpLinkSetting.TotalLinkCredit      = 50;
                        amqpLinkSetting.AutoSendFlow         = true;
                        amqpLinkSetting.SettleType           = SettleMode.SettleOnSend;
                        this.Link = new RequestResponseAmqpLink(this.session, amqpLinkSetting);
                        AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult openCbsRequestResponseLinkAsyncResult1      = this;
                        IteratorAsyncResult <AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult> .BeginCall beginCall1 = (AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Link.BeginOpen(t, c, s);
                        yield return(openCbsRequestResponseLinkAsyncResult1.CallAsync(beginCall1, (AmqpCbsLink.OpenCbsRequestResponseLinkAsyncResult thisPtr, IAsyncResult r) => thisPtr.Link.EndOpen(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        lastAsyncStepException = base.LastAsyncStepException;
                        if (lastAsyncStepException == null)
                        {
                            MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpOpenEntitySucceeded(this.connection, this.Link, this.Link.Name, str));
                        }
                        else
                        {
                            this.Link = null;
                            MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpOpenEntityFailed(this.connection, this.Link, this.Link.Name, str, lastAsyncStepException.Message));
                            this.session.SafeClose();
                            base.Complete(Microsoft.ServiceBus.Messaging.Amqp.ExceptionHelper.ToMessagingContract(lastAsyncStepException, this.connection.RemoteEndpoint.ToString()));
                        }
                    }
                    else
                    {
                        MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteAmqpOpenEntityFailed(this.connection, this.session, string.Empty, str, lastAsyncStepException.Message));
                        this.session.Abort();
                        base.Complete(Microsoft.ServiceBus.Messaging.Amqp.ExceptionHelper.ToMessagingContract(lastAsyncStepException, this.connection.RemoteEndpoint.ToString()));
                    }
                }
                else
                {
                    if (this.session != null)
                    {
                        this.session.SafeClose();
                    }
                    base.Complete(new TimeoutException(SRAmqp.AmqpTimeout(base.OriginalTimeout, str)));
                }
Label0:
                yield break;
            }
            protected override IEnumerator <IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                ServiceBusUriManager serviceBusUriManager = new ServiceBusUriManager(this.sharedChannel.viaAddresses.ToList <Uri>(), false);

                while (true)
                {
                    if (serviceBusUriManager.MoveNextUri())
                    {
                        this.Channel = this.sharedChannel.innerFactory.CreateChannel(new EndpointAddress(serviceBusUriManager.Current, new AddressHeader[0]), serviceBusUriManager.Current);
                        SharedChannel <TChannel> .CreateChannelAsyncResult createChannelAsyncResult = this;
                        IteratorAsyncResult <SharedChannel <TChannel> .CreateChannelAsyncResult> .BeginCall beginCall = (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.Channel.BeginOpen(t, c, s);
                        yield return(createChannelAsyncResult.CallAsync(beginCall, (SharedChannel <TChannel> .CreateChannelAsyncResult thisPtr, IAsyncResult r) => thisPtr.Channel.EndOpen(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                        if (base.LastAsyncStepException == null)
                        {
                            break;
                        }
                        this.Channel.Abort();
                    }
                    else
                    {
                        if (base.LastAsyncStepException == null)
                        {
                            break;
                        }
                        if (!(base.LastAsyncStepException is TimeoutException))
                        {
                            throw base.LastAsyncStepException;
                        }
                        throw new CommunicationException(SRClient.OpenChannelFailed(base.OriginalTimeout), base.LastAsyncStepException);
                    }
                }
            }
Exemplo n.º 29
0
            protected override IEnumerator <IteratorAsyncResult <SbmpBrowsableMessageSession.PeekMessagesAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                object obj = null;

                if (this.sbmpMessageSession.InnerMessageReceiver == null)
                {
                    bool flag = false;
                    try
                    {
                        object thisLock = this.sbmpMessageSession.ThisLock;
                        object obj1     = thisLock;
                        obj = thisLock;
                        Monitor.Enter(obj1, ref flag);
                        this.sbmpMessageSession.resetEvent.WaitOne();
                    }
                    finally
                    {
                        if (flag)
                        {
                            Monitor.Exit(obj);
                        }
                    }
                    try
                    {
                        if (this.sbmpMessageSession.InnerMessageReceiver != null)
                        {
                            goto Label0;
                        }
                        SbmpBrowsableMessageSession.PeekMessagesAsyncResult peekMessagesAsyncResult = this;
                        IteratorAsyncResult <SbmpBrowsableMessageSession.PeekMessagesAsyncResult> .BeginCall beginCall = (SbmpBrowsableMessageSession.PeekMessagesAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.BeginAcceptMessageSessionBrowser(t, c, s);
                        yield return(peekMessagesAsyncResult.CallAsync(beginCall, (SbmpBrowsableMessageSession.PeekMessagesAsyncResult thisPtr, IAsyncResult r) => thisPtr.EndAcceptMessageSessionBrowser(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                    }
                    finally
                    {
                        this.sbmpMessageSession.resetEvent.Set();
                    }
                }
Label0:
                if (this.sbmpMessageSession.InnerMessageReceiver != null)
                {
                    SbmpBrowsableMessageSession.PeekMessagesAsyncResult peekMessagesAsyncResult1 = this;
                    IteratorAsyncResult <SbmpBrowsableMessageSession.PeekMessagesAsyncResult> .BeginCall beginCall1 = (SbmpBrowsableMessageSession.PeekMessagesAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.sbmpMessageSession.InnerMessageReceiver.BeginPeekBatch(thisPtr.trackingContext, thisPtr.fromSequenceNumber, thisPtr.messageCount, SbmpProtocolDefaults.BufferTimeout(t, thisPtr.sbmpMessageSession.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), c, s);
                    yield return(peekMessagesAsyncResult1.CallAsync(beginCall1, (SbmpBrowsableMessageSession.PeekMessagesAsyncResult thisPtr, IAsyncResult a) => thisPtr.Messages = thisPtr.sbmpMessageSession.InnerMessageReceiver.EndPeekBatch(a), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Transfer));
                }
            }
Exemplo n.º 30
0
            protected override IEnumerator <IteratorAsyncResult <ServiceBusInputSessionChannelListener.AcceptChannelAsyncResult> .AsyncStep> GetAsyncSteps()
            {
                if (!this.owner.DoneReceivingInCurrentState())
                {
                    Stopwatch stopwatch = Stopwatch.StartNew();
                    ServiceBusInputSessionChannelListener.AcceptChannelAsyncResult acceptChannelAsyncResult = this;
                    IteratorAsyncResult <ServiceBusInputSessionChannelListener.AcceptChannelAsyncResult> .BeginCall beginCall = (ServiceBusInputSessionChannelListener.AcceptChannelAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.owner.MessagingFactory.BeginAcceptMessageSession(this.owner.MessagingAddress.EntityName, null, this.owner.ReceiveMode, thisPtr.acceptMessageSessionTimeout, thisPtr.acceptMessageSessionTimeout, c, s);
                    yield return(acceptChannelAsyncResult.CallAsync(beginCall, (ServiceBusInputSessionChannelListener.AcceptChannelAsyncResult thisPtr, IAsyncResult r) => thisPtr.Channel = new ServiceBusInputSessionChannel(thisPtr.owner.MessagingFactory.EndAcceptMessageSession(r), thisPtr.owner), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue));

                    stopwatch.Stop();
                    if (base.LastAsyncStepException != null)
                    {
                        Exception lastAsyncStepException = this.owner.OnException(base.LastAsyncStepException);
                        if (lastAsyncStepException == null)
                        {
                            lastAsyncStepException = base.LastAsyncStepException;
                        }
                        Exception exception = lastAsyncStepException;
                        long      ticks     = base.RemainingTime().Ticks;
                        long      num       = this.retryTimeSpan.Ticks;
                        TimeSpan  elapsed   = stopwatch.Elapsed;
                        TimeSpan  timeSpan  = TimeSpan.FromTicks(Math.Min(ticks, num - elapsed.Ticks));
                        if (timeSpan > TimeSpan.Zero)
                        {
                            yield return(base.CallAsyncSleep(timeSpan));
                        }
                        this.owner.IncrementRetryTimeSpan(this.retryTimeSpan);
                        base.Complete(exception);
                    }
                    else
                    {
                        this.owner.ResetRetryTimeSpan();
                        base.Complete(null);
                    }
                }
                else
                {
                    base.Complete(null);
                }
            }