/// <summary>
        /// Initializes a new instance of the <see cref="ServiceBusReceiver"/> class.
        /// </summary>
        ///
        /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param>
        /// <param name="entityPath"></param>
        /// <param name="isSessionEntity"></param>
        /// <param name="options">A set of options to apply when configuring the consumer.</param>
        /// <param name="sessionId"></param>
        ///
        internal ServiceBusReceiver(
            ServiceBusConnection connection,
            string entityPath,
            bool isSessionEntity,
            ServiceBusReceiverOptions options,
            string sessionId = default)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions));
            Argument.AssertNotNull(options, nameof(options));
            Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath));
            connection.ThrowIfClosed();

            Identifier        = DiagnosticUtilities.GenerateIdentifier(entityPath);
            _connection       = connection;
            _retryPolicy      = connection.RetryOptions.ToRetryPolicy();
            ReceiveMode       = options.ReceiveMode;
            PrefetchCount     = options.PrefetchCount;
            EntityPath        = entityPath;
            IsSessionReceiver = isSessionEntity;
            _innerReceiver    = _connection.CreateTransportReceiver(
                entityPath: EntityPath,
                retryPolicy: _retryPolicy,
                receiveMode: ReceiveMode,
                prefetchCount: (uint)PrefetchCount,
                identifier: Identifier,
                sessionId: sessionId,
                isSessionReceiver: IsSessionReceiver);
            _sessionManager = new ServiceBusSessionManager(_innerReceiver, Identifier);
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref="ServiceBusReceiver"/> class.
        /// </summary>
        ///
        /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param>
        /// <param name="entityName"></param>
        /// <param name="isSessionEntity"></param>
        /// <param name="sessionId"></param>
        /// <param name="options">A set of options to apply when configuring the consumer.</param>
        ///
        private ServiceBusReceiver(
            ServiceBusConnection connection,
            string entityName,
            bool isSessionEntity,
            string sessionId = default,
            ServiceBusReceiverOptions options = default)
        {
            Argument.AssertNotNull(connection, nameof(connection));
            options ??= new ServiceBusReceiverOptions();

            IsSessionReceiver = isSessionEntity;
            _connection       = connection;
            RetryPolicy       = options.RetryOptions.ToRetryPolicy();
            ReceiveMode       = options.ReceiveMode;
            PrefetchCount     = options.PrefetchCount;
            EntityName        = entityName;
            _innerReceiver    = _connection.CreateTransportReceiver(
                entityName: EntityName,
                retryPolicy: RetryPolicy,
                receiveMode: ReceiveMode,
                prefetchCount: (uint)PrefetchCount,
                sessionId: sessionId,
                isSessionReceiver: IsSessionReceiver);
            SessionManager = new ServiceBusSessionManager(_innerReceiver);
        }