Ejemplo n.º 1
0
            public EnlistAsyncResult(SbmpResourceManager resourceManager, Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action <RequestInfo> partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
            {
                if (transaction.IsolationLevel != IsolationLevel.Serializable)
                {
                    throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(new InvalidOperationException(SRClient.IsolationLevelNotSupported), null);
                }
                string localIdentifier = transaction.TransactionInformation.LocalIdentifier;

                lock (resourceManager.syncRoot)
                {
                    if (!resourceManager.enlistmentMap.TryGetValue(localIdentifier, out this.transactionEnlistment))
                    {
                        this.transactionEnlistment = new SbmpResourceManager.TransactionEnlistment(transaction, resourceManager, channel, messageCreator, partitionInfoSetter);
                        resourceManager.enlistmentMap.Add(localIdentifier, this.transactionEnlistment);
                        if (!transaction.EnlistPromotableSinglePhase(this.transactionEnlistment))
                        {
                            resourceManager.enlistmentMap.Remove(localIdentifier);
                            throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(new InvalidOperationException(SRClient.MultipleResourceManagersNotSupported), null);
                        }
                    }
                }
                this.sequenceNumber = this.transactionEnlistment.GetNextSequenceNumber();
                if (base.SyncContinue(this.transactionEnlistment.BeginGetInstance(timeout, base.PrepareAsyncCompletion(SbmpResourceManager.EnlistAsyncResult.getInstanceComplete), this)))
                {
                    base.Complete(true);
                }
            }
        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));
        }
Ejemplo n.º 3
0
 public TransactionEnlistment(Transaction transaction, SbmpResourceManager resourceManager, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action <RequestInfo> partitionInfoSetter) : base(new object())
 {
     this.transaction     = transaction;
     this.transactionId   = this.transaction.TransactionInformation.LocalIdentifier;
     this.resourceManager = resourceManager;
     this.channel         = channel;
     this.messageCreator  = messageCreator;
     this.sequenceNumber  = -1;
     this.RequestInfo     = new RequestInfo();
     partitionInfoSetter(this.RequestInfo);
 }
Ejemplo n.º 4
0
 static SbmpResourceManager()
 {
     SbmpResourceManager.singletonInstance = new SbmpResourceManager();
 }