/// <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.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath)); connection.ThrowIfClosed(); options = options?.Clone() ?? new ServiceBusReceiverOptions(); 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); }
/// <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); }
/// <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="plugins">The plugins to apply to incoming messages.</param> /// <param name="options">A set of options to apply when configuring the consumer.</param> /// <param name="sessionId">An optional session Id to scope the receiver to. If not specified, /// the next available session returned from the service will be used.</param> /// internal ServiceBusReceiver( ServiceBusConnection connection, string entityPath, bool isSessionEntity, IList <ServiceBusPlugin> plugins, ServiceBusReceiverOptions options, string sessionId = default) { Type type = GetType(); Logger.ClientCreateStart(type, connection?.FullyQualifiedNamespace, entityPath); try { Argument.AssertNotNull(connection, nameof(connection)); Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions)); Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath)); connection.ThrowIfClosed(); options = options?.Clone() ?? new ServiceBusReceiverOptions(); 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); _scopeFactory = new EntityScopeFactory(EntityPath, FullyQualifiedNamespace); _plugins = plugins; if (!isSessionEntity) { // don't log client completion for session receiver here as it is not complete until // the link is opened. Logger.ClientCreateComplete(type, Identifier); } } catch (Exception ex) { Logger.ClientCreateException(type, connection?.FullyQualifiedNamespace, entityPath, ex); throw; } }