private static bool OperationComplete(IAsyncResult asyncResult) { AcceptMessageSessionForNamespaceAsyncResult asyncState = (AcceptMessageSessionForNamespaceAsyncResult)asyncResult.AsyncState; Message message = asyncState.MessagingFactory.Channel.EndRequest(asyncResult); AcceptMessageSessionForNamespaceResponseCommand body = message.GetBody <AcceptMessageSessionForNamespaceResponseCommand>(); SessionState sessionState = body.SessionState; MessageCollection messages = body.Messages; DateTime lockedUntilUtc = body.LockedUntilUtc; LinkInfo linkInfo = new LinkInfo() { ConnectionId = asyncState.MessagingFactory.ConnectionId, EntityName = body.EntityPath, IsSessionReceiver = true, LinkId = body.LinkId, ReceiveMode = asyncState.receiveMode, LinkType = LinkType.Receive, SessionId = body.SessionId }; LinkInfo linkInfo1 = linkInfo; CreateLinkSettings createLinkSetting = new CreateLinkSettings(asyncState.MessagingFactory, body.EntityPath, body.EntityPath, linkInfo1, null); SbmpMessageReceiver sbmpMessageReceiver = new SbmpMessageReceiver(createLinkSetting.EntityName, false, createLinkSetting.MessagingFactory, createLinkSetting.MessageCreator, createLinkSetting.ControlMessageCreator, createLinkSetting.LinkInfo, false, asyncState.MessagingFactory.RetryPolicy.Clone(), messages); sbmpMessageReceiver.Open(); asyncState.result = new SbmpMessageSession(body.SessionId, lockedUntilUtc, sessionState, sbmpMessageReceiver); return(true); }
protected override MessageSession OnEndAcceptMessageSession(IAsyncResult result) { MessageSession messageSession; try { messageSession = AcceptMessageSessionForNamespaceAsyncResult.End(result); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(MessagingExceptionHelper.Unwrap(communicationException), null); } return(messageSession); }
protected override IAsyncResult OnBeginAcceptMessageSession(ReceiveMode receiveMode, TimeSpan serverWaitTime, TimeSpan timeout, AsyncCallback callback, object state) { IAsyncResult acceptMessageSessionForNamespaceAsyncResult; if (this.Settings.EnableRedirect) { throw new NotSupportedException(Microsoft.ServiceBus.SR.GetString(Resources.AcceptMessageSessionRedirectNotSupported, new object[0])); } try { acceptMessageSessionForNamespaceAsyncResult = new AcceptMessageSessionForNamespaceAsyncResult(this, receiveMode, this.PrefetchCount, this.acceptMessageSessionForNamespaceLinkSettings, serverWaitTime, timeout, callback, state); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(MessagingExceptionHelper.Unwrap(communicationException), null); } return(acceptMessageSessionForNamespaceAsyncResult); }