protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { IAsyncResult asyncResult; ICommunicationObject batchManager; try { SbmpMessageCreator messageCreator = this.MessageCreator; IRequestSessionChannel channel = this.SbmpMessagingFactory.Channel; if (base.BatchingEnabled) { batchManager = this.BatchManager; } else { batchManager = null; } asyncResult = (new CloseOrAbortLinkAsyncResult(messageCreator, channel, batchManager, timeout, false, callback, state)).Start(); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(MessagingExceptionHelper.Unwrap(communicationException, false), null); } return(asyncResult); }
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)); }
public CloseOrAbortLinkAsyncResult(SbmpMessageCreator linkMessageCreator, IRequestSessionChannel channel, ICommunicationObject batchManager, string parentLinkId, TimeSpan closeTimeout, bool aborting, AsyncCallback callback, object state) : base(closeTimeout, callback, state) { this.linkMessageCreator = linkMessageCreator; this.channel = channel; this.batchManager = batchManager; this.aborting = aborting; this.parentLinkId = parentLinkId; }
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); }
public GetRuntimeEntityDescriptionAsyncResult(TrackingContext trackingContext, MessageClientEntity clientEntity, string entityAddress, SbmpMessagingFactory factory, SbmpMessageCreator messageCreator, bool executeOnce, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.clientEntity = clientEntity; this.entityAddress = entityAddress; this.factory = factory; this.messageCreator = messageCreator; this.trackingContext = trackingContext ?? TrackingContext.GetInstance(Guid.NewGuid()); this.executeOnce = executeOnce; GetRuntimeEntityDescriptionAsyncResult getRuntimeEntityDescriptionAsyncResult = this; getRuntimeEntityDescriptionAsyncResult.OnCompleting = (Action <AsyncResult, Exception>)Delegate.Combine(getRuntimeEntityDescriptionAsyncResult.OnCompleting, GetRuntimeEntityDescriptionAsyncResult.onFinally); }
public GetMessageSessionsAsyncResult(SbmpMessagingFactory messagingFactory, string entityName, DateTime lastUpdatedTime, SbmpMessageCreator messageCreator, RetryPolicy retryPolicy, MessagingEntityType entityType, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.lastUpdatedTime = lastUpdatedTime; this.MessagingFactory = messagingFactory; this.messageCreator = messageCreator; this.entityName = entityName; this.messageSessions = new List <MessageSession>(); this.entityType = entityType; this.sessionsPageSize = 100; this.retryPolicy = retryPolicy; base.Start(); }
protected override void OnAbort() { ICommunicationObject batchManager; SbmpMessageCreator messageCreator = this.MessageCreator; IRequestSessionChannel channel = this.SbmpMessagingFactory.Channel; if (base.BatchingEnabled) { batchManager = this.BatchManager; } else { batchManager = null; } CloseOrAbortLinkAsyncResult closeOrAbortLinkAsyncResult = new CloseOrAbortLinkAsyncResult(messageCreator, channel, batchManager, this.OperationTimeout, true, new AsyncCallback(SbmpMessageSender.AbortCallback), null); closeOrAbortLinkAsyncResult.Schedule(); }
public SbmpMessageSender(string path, Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory messagingFactory, SbmpMessageCreator messageCreator, Microsoft.ServiceBus.RetryPolicy retryPolicy) : base(messagingFactory, retryPolicy) { this.SbmpMessagingFactory = messagingFactory; this.path = path; this.MessageCreator = messageCreator; this.ViaSender = !string.IsNullOrWhiteSpace(messageCreator.LinkInfo.TransferDestinationEntityAddress); this.BatchManager = new BatchManager <BrokeredMessage>((TrackingContext trackingContext, IEnumerable <BrokeredMessage> messages, string transactionId, TimeSpan timeout, AsyncCallback callback, object state) => this.BeginSendCommand(trackingContext, messages, timeout, callback, state), (IAsyncResult result, bool forceCleanUp) => this.EndSendCommand(result), null, new OnRetryDelegate <BrokeredMessage>(SbmpMessageSender.IsSendCommandRetryable), null, null, (long)204800, (long)225280, this.GetOverheadSize()) { FlushInterval = this.SbmpMessagingFactory.Settings.BatchFlushInterval }; if (!this.SbmpMessagingFactory.Settings.GatewayMode && (this.SbmpMessagingFactory.Settings.GatewayMode || !this.SbmpMessagingFactory.Settings.EnableRedirect)) { this.ShouldAddPartitioningHeaders = true; return; } this.BatchManager.CalculateBatchSize = new CalculateBatchSizeDelegate <BrokeredMessage>(SbmpMessageSender.DefaultCalculateSizeOfMessages); this.SbmpSenderBatchingEnabled = true; this.ShouldAddPartitioningHeaders = false; }
public void ScheduleGetRuntimeEntityDescription(TrackingContext trackingContext, MessageClientEntity clientEntity, string entityName, SbmpMessageCreator messageCreator) { Microsoft.ServiceBus.Messaging.RuntimeEntityDescription runtimeEntityDescription; if (!this.Settings.GatewayMode && clientEntity.RuntimeEntityDescription == null && !this.Settings.EnableRedirect && base.IsOpened) { string str = string.Concat(this.BaseAddress.AbsoluteUri, entityName); if (RuntimeEntityDescriptionCache.TryGet(str, out runtimeEntityDescription)) { clientEntity.RuntimeEntityDescription = runtimeEntityDescription; return; } IOThreadScheduler.ScheduleCallbackNoFlow((object s) => (new GetRuntimeEntityDescriptionAsyncResult(trackingContext, clientEntity, str, this, messageCreator, false, Constants.GetRuntimeEntityDescriptionTimeout, null, null)).Start(), null); } }
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); } }
public IAsyncResult BeginEnlist(Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action <RequestInfo> partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, object state) { return(new SbmpResourceManager.EnlistAsyncResult(this, transaction, channel, messageCreator, partitionInfoSetter, timeout, callback, state)); }
protected SbmpTransactionalAsyncResult(SbmpMessagingFactory messagingFactory, SbmpMessageCreator messageCreator, Lazy <SbmpMessageCreator> controlMessageCreator, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.messagingFactory = messagingFactory; this.MessageCreator = messageCreator; this.channel = this.messagingFactory.Channel; this.controlMessageCreator = controlMessageCreator; this.Transaction = System.Transactions.Transaction.Current; }
public SbmpMessageBrowser(string path, Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory messagingFactory, SbmpMessageCreator messageCreator, Lazy <SbmpMessageCreator> controlMessageCreator, Microsoft.ServiceBus.RetryPolicy retryPolicy, bool embedParentLinkId) : base(messagingFactory, retryPolicy) { this.SbmpMessagingFactory = messagingFactory; this.path = path; this.MessageCreator = messageCreator; this.ControlMessageCreator = controlMessageCreator; base.InstanceTrackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.path); }
public CloseOrAbortLinkAsyncResult(SbmpMessageCreator linkMessageCreator, IRequestSessionChannel channel, ICommunicationObject batchManager, TimeSpan closeTimeout, bool aborting, AsyncCallback callback, object state) : this(linkMessageCreator, channel, batchManager, string.Empty, closeTimeout, aborting, callback, state) { }