public SessionReceiverManager( ServiceBusConnection connection, string fullyQualifiedNamespace, string entityPath, string identifier, string sessionId, ServiceBusProcessorOptions processorOptions, Func <ProcessSessionEventArgs, Task> sessionInitHandler, Func <ProcessSessionEventArgs, Task> sessionCloseHandler, Func <ProcessSessionMessageEventArgs, Task> messageHandler, Func <ProcessErrorEventArgs, Task> errorHandler, SemaphoreSlim concurrentAcceptSessionsSemaphore, EntityScopeFactory scopeFactory, IList <ServiceBusPlugin> plugins) : base(connection, fullyQualifiedNamespace, entityPath, identifier, processorOptions, default, errorHandler, scopeFactory, plugins) { _sessionInitHandler = sessionInitHandler; _sessionCloseHandler = sessionCloseHandler; _messageHandler = messageHandler; _concurrentAcceptSessionsSemaphore = concurrentAcceptSessionsSemaphore; _sessionReceiverOptions = new ServiceBusSessionReceiverOptions { ReceiveMode = _processorOptions.ReceiveMode, PrefetchCount = _processorOptions.PrefetchCount, SessionId = sessionId }; }
/// <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="options">A set of options to apply when configuring the consumer.</param> internal ServiceBusSessionReceiver( ServiceBusConnection connection, string entityPath, ServiceBusSessionReceiverOptions options) : base(connection, entityPath, true, options?.ToReceiverOptions(), options?.SessionId) { }
public ReceiverManager( ServiceBusConnection connection, string fullyQualifiedNamespace, string entityPath, string identifier, ServiceBusProcessorOptions processorOptions, Func <ProcessMessageEventArgs, Task> messageHandler, Func <ProcessErrorEventArgs, Task> errorHandler, EntityScopeFactory scopeFactory, IList <ServiceBusPlugin> plugins) { _connection = connection; _fullyQualifiedNamespace = fullyQualifiedNamespace; _entityPath = entityPath; _processorOptions = processorOptions; _receiverOptions = new ServiceBusReceiverOptions { ReceiveMode = _processorOptions.ReceiveMode, PrefetchCount = _processorOptions.PrefetchCount }; _maxReceiveWaitTime = _processorOptions.MaxReceiveWaitTime; _identifier = identifier; _plugins = plugins; Receiver = new ServiceBusReceiver( connection: _connection, entityPath: _entityPath, isSessionEntity: false, plugins: _plugins, options: _receiverOptions); _errorHandler = errorHandler; _messageHandler = messageHandler; _scopeFactory = scopeFactory; }
/// <summary> /// /// </summary> /// <param name="fullyQualifiedNamespace"></param> /// <param name="credential"></param> /// <param name="options"></param> public ServiceBusClient(string fullyQualifiedNamespace, TokenCredential credential, ServiceBusClientOptions options) { Connection = new ServiceBusConnection( fullyQualifiedNamespace, credential, options); }
/// <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> /// 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="plugins">The set of plugins to apply to incoming messages.</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="ServiceBusSessionReceiver"/> class.</returns> internal static async Task <ServiceBusSessionReceiver> CreateSessionReceiverAsync( string entityPath, ServiceBusConnection connection, IList <ServiceBusPlugin> plugins, ServiceBusSessionReceiverOptions options = default, CancellationToken cancellationToken = default) { var receiver = new ServiceBusSessionReceiver( connection: connection, entityPath: entityPath, plugins: plugins, options: options); try { await receiver.OpenLinkAsync(cancellationToken).ConfigureAwait(false); } catch (Exception ex) { receiver.Logger.ClientCreateException(typeof(ServiceBusSessionReceiver), receiver.FullyQualifiedNamespace, entityPath, ex); throw; } receiver.Logger.ClientCreateComplete(typeof(ServiceBusSessionReceiver), receiver.Identifier); return(receiver); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusSender"/> class. /// </summary> /// <param name="entityPath">The entity path to send the message to.</param> /// <param name="options">The set of <see cref="ServiceBusSenderOptions"/> to use for configuring /// this <see cref="ServiceBusSender"/>.</param> /// <param name="connection">The connection for the sender.</param> /// internal ServiceBusSender( string entityPath, ServiceBusSenderOptions options, ServiceBusConnection connection) { Logger.ClientCreateStart(typeof(ServiceBusSender), 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 ServiceBusSenderOptions(); EntityPath = entityPath; ViaEntityPath = options.ViaQueueOrTopicName; Identifier = DiagnosticUtilities.GenerateIdentifier(EntityPath); _connection = connection; _retryPolicy = _connection.RetryOptions.ToRetryPolicy(); _innerSender = _connection.CreateTransportSender( entityPath, ViaEntityPath, _retryPolicy, Identifier); _scopeFactory = new EntityScopeFactory(EntityPath, FullyQualifiedNamespace); } catch (Exception ex) { Logger.ClientCreateException(typeof(ServiceBusSender), connection?.FullyQualifiedNamespace, entityPath, ex); throw; } Logger.ClientCreateComplete(typeof(ServiceBusSender), Identifier); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusClient"/> class. /// </summary> /// /// <param name="connectionString">The connection string to use for connecting to the /// Service Bus namespace.</param> /// <param name="options">The set of <see cref="ServiceBusClientOptions"/> to use for /// configuring this <see cref="ServiceBusClient"/>.</param> /// /// <remarks> /// If the connection string specifies a specific entity name, any subsequent calls to /// <see cref="CreateSender(string)"/>, <see cref="CreateReceiver(string)"/>, /// <see cref="CreateProcessor(string)"/> etc. must still specify the same entity name. /// </remarks> public ServiceBusClient(string connectionString, ServiceBusClientOptions options) { Connection = new ServiceBusConnection(connectionString, options); Logger.ClientCreateStart(typeof(ServiceBusClient), FullyQualifiedNamespace); Options = Connection.Options; Identifier = DiagnosticUtilities.GenerateIdentifier(FullyQualifiedNamespace); Logger.ClientCreateComplete(typeof(ServiceBusClient), 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="entityPath"></param> /// <param name="options">A set of options to apply when configuring the consumer.</param> /// <param name="sessionId"></param> /// internal ServiceBusSessionReceiver( ServiceBusConnection connection, string entityPath, ServiceBusReceiverOptions options, string sessionId = default) : base(connection, entityPath, true, options, sessionId) { }
/// <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="plugins">The set of 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 receive from.</param> internal ServiceBusSessionReceiver( ServiceBusConnection connection, string entityPath, IList <ServiceBusPlugin> plugins, ServiceBusSessionReceiverOptions options, string sessionId = default) : base(connection, entityPath, true, plugins, options?.ToReceiverOptions(), sessionId) { }
/// <summary> /// /// </summary> /// <param name="fullyQualifiedNamespace"></param> /// <param name="credential"></param> /// <param name="options"></param> public ServiceBusClient(string fullyQualifiedNamespace, TokenCredential credential, ServiceBusClientOptions options) { Identifier = DiagnosticUtilities.GenerateIdentifier(fullyQualifiedNamespace); Connection = new ServiceBusConnection( fullyQualifiedNamespace, credential, options); Options = Connection.Options; }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusClient"/> class. /// </summary> /// /// <param name="connectionString">The connection string to use for connecting to the /// Service Bus namespace.</param> /// <param name="options">The set of <see cref="ServiceBusClientOptions"/> to use for /// configuring this <see cref="ServiceBusClient"/>.</param> /// /// <remarks> /// If the connection string specifies a specific entity name, any subsequent calls to /// <see cref="CreateSender(string)"/>, <see cref="CreateReceiver(string)"/>, /// <see cref="CreateProcessor(string)"/> etc. must still specify the same entity name. /// </remarks> public ServiceBusClient(string connectionString, ServiceBusClientOptions options) { _options = options?.Clone() ?? new ServiceBusClientOptions(); Connection = new ServiceBusConnection(connectionString, _options); Logger.ClientCreateStart(typeof(ServiceBusClient), FullyQualifiedNamespace); Identifier = DiagnosticUtilities.GenerateIdentifier(FullyQualifiedNamespace); Plugins = _options.Plugins; Logger.ClientCreateComplete(typeof(ServiceBusClient), 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="entityPath"></param> /// <param name="plugins">The set of plugins to apply to incoming messages.</param> /// <param name="options">A set of options to apply when configuring the consumer.</param> /// <param name="cancellationToken">The cancellation token to use when opening the receiver link.</param> /// <param name="sessionId">An optional session Id to receive from.</param> internal ServiceBusSessionReceiver( ServiceBusConnection connection, string entityPath, IList <ServiceBusPlugin> plugins, ServiceBusSessionReceiverOptions options, CancellationToken cancellationToken, string sessionId = default) : base(connection, entityPath, true, plugins, options?.ToReceiverOptions(), sessionId, cancellationToken) { _connection = connection; }
/// <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="options">A set of options to apply when configuring the consumer.</param> /// <param name="cancellationToken">The cancellation token to use when opening the receiver link.</param> /// <param name="sessionId">An optional session Id to receive from.</param> /// <param name="isProcessor"></param> internal ServiceBusSessionReceiver( ServiceBusConnection connection, string entityPath, ServiceBusSessionReceiverOptions options, CancellationToken cancellationToken, string sessionId = default, bool isProcessor = false) : base(connection, entityPath, true, options?.ToReceiverOptions(), sessionId, isProcessor, cancellationToken) { _connection = connection; }
/// <summary> /// /// </summary> /// <returns></returns> internal static ServiceBusReceiver CreateReceiver( string queueName, ServiceBusConnection connection, ServiceBusReceiverOptions options = default) { options = options?.Clone() ?? new ServiceBusReceiverOptions(); return(new ServiceBusReceiver( connection: connection, entityName: queueName, isSessionEntity: false, options: options)); }
internal ServiceBusSessionProcessor( ServiceBusConnection connection, string entityPath, ServiceBusSessionProcessorOptions options) { _innerProcessor = new ServiceBusProcessor( connection, entityPath, true, options.ToProcessorOptions(), options.SessionIds); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusSenderClient"/> class. /// </summary> /// /// <param name="connectionString">The connection string to use for connecting to the Service Bus namespace; it is expected that the shared key properties are contained in this connection string, but not the Service Bus entity name.</param> /// <param name="entityName">The name of the specific Service Bus entity to associate the producer with.</param> /// <param name="clientOptions">A set of options to apply when configuring the producer.</param> /// /// <remarks> /// If the connection string is copied from the Service Bus entity itself, it will contain the name of the desired Service Bus entity, /// and can be used directly without passing the <paramref name="entityName" />. The name of the Service Bus entity should be /// passed only once, either as part of the connection string or separately. /// </remarks> /// public ServiceBusSenderClient( string connectionString, string entityName, ServiceBusSenderClientOptions clientOptions) { Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString)); clientOptions = clientOptions?.Clone() ?? new ServiceBusSenderClientOptions(); ClientDiagnostics = new ClientDiagnostics(clientOptions); OwnsConnection = true; Connection = new ServiceBusConnection(connectionString, entityName, clientOptions.ConnectionOptions); RetryPolicy = clientOptions.RetryOptions.ToRetryPolicy(); InnerSender = Connection.CreateTransportProducer(RetryPolicy); }
internal ServiceBusSessionProcessor( ServiceBusConnection connection, string entityPath, ServiceBusProcessorOptions options, string sessionId = default) { _innerProcessor = new ServiceBusProcessor( connection, entityPath, true, options, sessionId); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusSenderClient"/> class. /// </summary> /// /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param> /// <param name="clientOptions">A set of options to apply when configuring the producer.</param> /// internal ServiceBusSenderClient( ServiceBusConnection connection, ServiceBusSenderClientOptions clientOptions = default) { Argument.AssertNotNull(connection, nameof(connection)); clientOptions = clientOptions?.Clone() ?? new ServiceBusSenderClientOptions(); ClientDiagnostics = new ClientDiagnostics(clientOptions); OwnsConnection = false; Connection = connection; RetryPolicy = clientOptions.RetryOptions.ToRetryPolicy(); InnerSender = Connection.CreateTransportProducer(RetryPolicy); }
internal ServiceBusSessionProcessor( ServiceBusConnection connection, string entityPath, ServiceBusProcessorOptions options, params string[] sessionIds) { _innerProcessor = new ServiceBusProcessor( connection, entityPath, true, options, sessionIds); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusProcessor"/> class. /// </summary> /// /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param> /// <param name="entityPath">The queue name or subscription path to process messages from.</param> /// <param name="isSessionEntity">Whether or not the processor is associated with a session entity.</param> /// <param name="plugins">The set of plugins to apply to incoming messages.</param> /// <param name="options">The set of options to use when configuring the processor.</param> /// <param name="sessionIds">An optional set of session Ids to limit processing to. /// Only applies if isSessionEntity is true.</param> /// <param name="maxConcurrentSessions">The max number of sessions that can be processed concurrently. /// Only applies if isSessionEntity is true.</param> /// <param name="maxConcurrentCallsPerSession">The max number of concurrent calls per session. /// Only applies if isSessionEntity is true.</param> internal ServiceBusProcessor( ServiceBusConnection connection, string entityPath, bool isSessionEntity, IList <ServiceBusPlugin> plugins, ServiceBusProcessorOptions options, string[] sessionIds = default, int maxConcurrentSessions = default, int maxConcurrentCallsPerSession = default) { Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath)); Argument.AssertNotNull(connection, nameof(connection)); Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions)); connection.ThrowIfClosed(); _options = options?.Clone() ?? new ServiceBusProcessorOptions(); _connection = connection; EntityPath = entityPath; Identifier = DiagnosticUtilities.GenerateIdentifier(EntityPath); ReceiveMode = _options.ReceiveMode; PrefetchCount = _options.PrefetchCount; MaxAutoLockRenewalDuration = _options.MaxAutoLockRenewalDuration; MaxConcurrentCalls = _options.MaxConcurrentCalls; MaxConcurrentSessions = maxConcurrentSessions; MaxConcurrentCallsPerSession = maxConcurrentCallsPerSession; _sessionIds = sessionIds ?? Array.Empty <string>(); int maxCalls = isSessionEntity ? (_sessionIds.Length > 0 ? Math.Min(_sessionIds.Length, MaxConcurrentSessions) : MaxConcurrentSessions) * MaxConcurrentCallsPerSession : MaxConcurrentCalls; MessageHandlerSemaphore = new SemaphoreSlim( maxCalls, maxCalls); var maxAcceptSessions = Math.Min(maxCalls, 2 * Environment.ProcessorCount); MaxConcurrentAcceptSessionsSemaphore = new SemaphoreSlim( maxAcceptSessions, maxAcceptSessions); MaxReceiveWaitTime = _options.MaxReceiveWaitTime; AutoComplete = _options.AutoComplete; EntityPath = entityPath; IsSessionProcessor = isSessionEntity; _scopeFactory = new EntityScopeFactory(EntityPath, FullyQualifiedNamespace); _plugins = plugins; }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusClient"/> class. /// </summary> /// /// <param name="fullyQualifiedNamespace">The fully qualified Service Bus namespace to connect to. /// This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param> /// <param name="credential">The Azure managed identity credential to use for authorization. Access controls may be specified by the Service Bus namespace.</param> /// <param name="options">The set of <see cref="ServiceBusClientOptions"/> to use for configuring this <see cref="ServiceBusClient"/>.</param> public ServiceBusClient( string fullyQualifiedNamespace, TokenCredential credential, ServiceBusClientOptions options) { Logger.ClientCreateStart(typeof(ServiceBusClient), fullyQualifiedNamespace); Identifier = DiagnosticUtilities.GenerateIdentifier(fullyQualifiedNamespace); Connection = new ServiceBusConnection( fullyQualifiedNamespace, credential, options); Options = Connection.Options; Logger.ClientCreateComplete(typeof(ServiceBusClient), Identifier); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusClient"/> class. /// </summary> /// /// <param name="fullyQualifiedNamespace">The fully qualified Service Bus namespace to connect to. /// This is likely to be similar to <c>{yournamespace}.servicebus.windows.net</c>.</param> /// <param name="credential">The <see cref="ServiceBusSharedAccessKeyCredential"/> to use for authorization. Access controls may be specified by the Service Bus namespace.</param> /// <param name="options">The set of <see cref="ServiceBusClientOptions"/> to use for configuring this <see cref="ServiceBusClient"/>.</param> internal ServiceBusClient( string fullyQualifiedNamespace, ServiceBusSharedAccessKeyCredential credential, ServiceBusClientOptions options) { _options = options?.Clone() ?? new ServiceBusClientOptions(); Logger.ClientCreateStart(typeof(ServiceBusClient), fullyQualifiedNamespace); Identifier = DiagnosticUtilities.GenerateIdentifier(fullyQualifiedNamespace); Connection = new ServiceBusConnection( fullyQualifiedNamespace, credential, _options); Plugins = _options.Plugins; Logger.ClientCreateComplete(typeof(ServiceBusClient), 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="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; } }
internal ServiceBusSessionProcessor( ServiceBusConnection connection, string entityPath, IList <ServiceBusPlugin> plugins, ServiceBusSessionProcessorOptions options) { InnerProcessor = new ServiceBusProcessor( connection, entityPath, true, plugins, options.ToProcessorOptions(), options.SessionIds.ToArray(), options.MaxConcurrentSessions, options.MaxConcurrentCallsPerSession); }
internal ServiceBusSessionProcessor( ServiceBusConnection connection, string entityPath, ServiceBusSessionProcessorOptions options) { options ??= new ServiceBusSessionProcessorOptions(); InnerProcessor = new ServiceBusProcessor( connection, entityPath, true, options.ToProcessorOptions(), options.SessionIds.ToArray(), options.MaxConcurrentSessions, options.MaxConcurrentCallsPerSession, this); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusRuleManager"/> class. /// </summary> /// /// <param name="connection">The <see cref="ServiceBusConnection" /> connection to use for communication with the Service Bus service.</param> /// <param name="subscriptionPath">The path of the Service Bus subscription to which the rule manager is bound.</param> /// internal ServiceBusRuleManager( ServiceBusConnection connection, string subscriptionPath) { Argument.AssertNotNull(connection, nameof(connection)); Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions)); Argument.AssertNotNullOrWhiteSpace(subscriptionPath, nameof(subscriptionPath)); connection.ThrowIfClosed(); Identifier = DiagnosticUtilities.GenerateIdentifier(subscriptionPath); _connection = connection; SubscriptionPath = subscriptionPath; InnerRuleManager = _connection.CreateTransportRuleManager( subscriptionPath: SubscriptionPath, retryPolicy: connection.RetryOptions.ToRetryPolicy()); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusSender"/> class. /// </summary> /// <param name="entityPath">The entity path to send the message to.</param> /// <param name="connection">The connection for the sender.</param> /// internal ServiceBusSender( string entityPath, ServiceBusConnection connection) { Argument.AssertNotNull(connection, nameof(connection)); Argument.AssertNotNull(connection.RetryOptions, nameof(connection.RetryOptions)); Argument.AssertNotNullOrWhiteSpace(entityPath, nameof(entityPath)); connection.ThrowIfClosed(); EntityPath = entityPath; Identifier = DiagnosticUtilities.GenerateIdentifier(EntityPath); _connection = connection; _retryPolicy = _connection.RetryOptions.ToRetryPolicy(); _innerSender = _connection.CreateTransportSender( entityPath, _retryPolicy); }
/// <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="ServiceBusSessionReceiver"/> class.</returns> internal static async Task <ServiceBusSessionReceiver> CreateSessionReceiverAsync( string entityPath, ServiceBusConnection connection, string sessionId = default, ServiceBusReceiverOptions options = default, CancellationToken cancellationToken = default) { var receiver = new ServiceBusSessionReceiver( connection: connection, entityPath: entityPath, options: options, sessionId: sessionId); await receiver.OpenLinkAsync(cancellationToken).ConfigureAwait(false); return(receiver); }