/// <summary> /// Creates a session receiver which can be used to interact with all messages with the same sessionId. /// </summary> /// /// <param name="entityPath">The name of the specific queue to associate the receiver with.</param> /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param> /// <param name="sessionId">The sessionId for this receiver</param> /// <param name="options">A set of options to apply when configuring the receiver.</param> /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param> /// ///<returns>Returns a new instance of the <see cref="ServiceBusReceiver"/> class.</returns> internal static async Task <ServiceBusReceiver> CreateSessionReceiverAsync( string entityPath, ServiceBusConnection connection, string sessionId = default, ServiceBusReceiverOptions options = default, CancellationToken cancellationToken = default) { options = options?.Clone() ?? new ServiceBusReceiverOptions(); var receiver = new ServiceBusReceiver( connection: connection, entityPath: entityPath, isSessionEntity: true, options: options, sessionId: sessionId); await receiver.OpenLinkAsync(cancellationToken).ConfigureAwait(false); return(receiver); }