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; }
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 WrappedRequestSessionChannel(IRequestSessionChannel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } this.channel = channel; this.readerSession = new ContainerChannelManager.WrappedXmlBinaryReaderSession(); }
public DurableInstanceContextRequestSessionChannel(ChannelManagerBase channelManager, ContextType contextType, IRequestSessionChannel innerChannel, string contextStoreLocation) : base(channelManager, innerChannel) { this.contextType = contextType; this.innerRequestSessionChannel = innerChannel; this.contextStoreLocation = contextStoreLocation; this.endpointAddress = innerChannel.RemoteAddress; this.stateLock = new object(); this.isFirstMessage = true; }
protected override void OnAbort() { base.OnAbort(); IRequestSessionChannel channel = this.Channel; if (channel != null) { channel.Abort(); } if (this.ChannelFactory != null) { this.ChannelFactory.Abort(); } }
public RedirectContainerSessionChannel(RedirectBindingElement.RedirectContainerChannelFactory <IRequestSessionChannel> factory, EndpointAddress address, Uri via) : base(factory) { this.innerFactory = factory.innerFactory; this.bindingElement = factory.BindingElement; this.RemoteAddress = address; this.Via = via; this.entityMap = new ConcurrentDictionary <RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkKey, RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.EntityLinkValue>(); this.primaryChannel = this.innerFactory.CreateChannel(address, via); RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession outputSession = new RedirectBindingElement.RedirectContainerChannelFactory <TChannel> .RedirectContainerSessionChannel.OutputSession() { Id = this.primaryChannel.Session.Id }; this.Session = outputSession; this.onCorrelatorNotifyCleanup = new EventHandler(this.OnCorrelatorNotifyCleanup); this.correlatorManager = new ContainerChannelManager(true, this.bindingElement.UseSslStreamSecurity, this.bindingElement.IncludeExceptionDetails, this.bindingElement.EndpointIdentity); this.correlatorManager.NotifyCleanup += new EventHandler(this.OnCorrelatorNotifyCleanup); }
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 InterceptingRequestSessionChannel( InterceptingChannelFactory <TChannel> factory, IRequestSessionChannel innerChannel) : base(factory, innerChannel) { this.innerSessionChannel = innerChannel; }
public InterceptorRequestSessionChannel(ChannelManagerBase manager, IRequestSessionChannel innerChannel, IChannelInterceptor channelInterceptor) : base(manager, innerChannel, channelInterceptor) { _innerChannel = innerChannel; }
protected override bool HasSecuritySession(IRequestSessionChannel channel) { return(channel.Session is ISecuritySession); }
public SecurityRequestSessionChannel(IRequestSessionChannel innerChannel, SecurityChannelFactory <IRequestSessionChannel> source) : base(innerChannel) { this.source = source; InitializeSecurityFunctionality(source.SecuritySupport); }
public OpenInstanceAsyncResult(string key, IRequestSessionChannel channel, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.channel = channel; }
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)); }
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 SecurityRequestSessionChannel (IRequestSessionChannel innerChannel, SecurityChannelFactory<IRequestSessionChannel> source) : base (innerChannel) { this.source = source; InitializeSecurityFunctionality (source.SecuritySupport); }
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; }
public CloseAsyncResult(SbmpMessagingFactory factory, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.factory = factory; this.channel = factory.Channel; }
public SecurityRequestSessionChannel(ChannelManagerBase factory, SecurityProtocolFactory securityProtocolFactory, IRequestSessionChannel innerChannel, EndpointAddress to, Uri via) : base(factory, securityProtocolFactory, innerChannel, to, via) { }
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) { }