/// <summary> /// Gets a particular session object identified by <paramref name="sessionId"/> that can be used to receive messages for that sessionId. /// </summary> /// <param name="sessionId">The sessionId present in all its messages.</param> /// <param name="serverWaitTime">Amount of time for which the call should wait to fetch the next session.</param> /// <remarks>All plugins registered on <see cref="SessionClient"/> will be applied to each <see cref="MessageSession"/> that is accepted. /// Individual sessions can further register additional plugins.</remarks> /// <returns>A session object.</returns> public async Task <IMessageSession> AcceptMessageSessionAsync(string sessionId, TimeSpan serverWaitTime) { MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionStart( this.ClientId, this.EntityPath, this.ReceiveMode, this.PrefetchCount, sessionId); var session = new MessageSession( this.EntityPath, this.EntityType, this.ReceiveMode, this.ServiceBusConnection, this.CbsTokenProvider, this.RetryPolicy, this.PrefetchCount, sessionId, true); try { await this.RetryPolicy.RunOperation( async() => { await session.GetSessionReceiverLinkAsync(serverWaitTime).ConfigureAwait(false); }, serverWaitTime) .ConfigureAwait(false); } catch (Exception exception) { MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionException( this.ClientId, this.EntityPath, exception); await session.CloseAsync().ConfigureAwait(false); throw AmqpExceptionHelper.GetClientException(exception); } MessagingEventSource.Log.AmqpSessionClientAcceptMessageSessionStop( this.ClientId, this.EntityPath, session.SessionIdInternal); session.UpdateClientId(ClientEntity.GenerateClientId(nameof(MessageSession), $"{this.EntityPath}_{session.SessionId}")); // Register plugins on the message session. foreach (var serviceBusPlugin in this.RegisteredPlugins) { session.RegisterPlugin(serviceBusPlugin); } return(session); }
public async Task <MessageSession> AcceptMessageSessionAsync(string sessionId) { MessageSession session = null; try { session = await this.OnAcceptMessageSessionAsync(sessionId).ConfigureAwait(false); } catch (Exception) { // TODO: Log Complete Exception throw; } return(session); }
public async Task <MessageSession> AcceptMessageSessionAsync(string sessionId) { MessageSession session = null; MessagingEventSource.Log.AcceptMessageSessionStart(this.ClientId, sessionId); try { session = await this.OnAcceptMessageSessionAsync(sessionId).ConfigureAwait(false); } catch (Exception exception) { MessagingEventSource.Log.AcceptMessageSessionException(this.ClientId, exception); throw; } MessagingEventSource.Log.AcceptMessageSessionStop(this.ClientId); return(session); }