/// <summary> /// Initializes a new instance of the <see cref="ServiceBusProcessorClient"/> 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="topicName"></param> /// <param name="subscriptionName"></param> /// <param name="clientOptions"></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="topicName" />. The name of the Service Bus entity should be /// passed only once, either as part of the connection string or separately. /// </remarks> /// public ServiceBusProcessorClient( string connectionString, string topicName, string subscriptionName, ServiceBusProcessorClientOptions clientOptions = default) : this(new ServiceBusConnection(connectionString, EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), clientOptions?.ConnectionOptions), clientOptions?.Clone() ?? new ServiceBusProcessorClientOptions()) { }
/// <summary> /// The <see cref="ServiceBusRuleManager"/> is used to manage the rules for a subscription. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusRuleManager"/> for.</param> /// <param name="subscriptionName">The subscription specific to the specified topic to create /// a <see cref="ServiceBusRuleManager"/> for.</param> /// /// <returns>A <see cref="ServiceBusRuleManager"/> scoped to the specified subscription and topic.</returns> public ServiceBusRuleManager CreateRuleManager(string topicName, string subscriptionName) { ValidateEntityName(topicName); return(new ServiceBusRuleManager( connection: Connection, subscriptionPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName))); }
/// <summary> /// /// </summary> /// <param name="topicName"></param> /// <param name="subscriptionName"></param> /// <param name="options"></param> /// <returns></returns> public ServiceBusProcessor GetProcessor( string topicName, string subscriptionName, ServiceBusProcessorOptions options) => new ServiceBusProcessor( entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection: Connection, isSessionEntity: false, options: options);
/// <summary> /// /// </summary> /// <param name="topicName"></param> /// <param name="subscriptionName"></param> /// <param name="options"></param> /// <returns></returns> public ServiceBusReceiver GetReceiver( string topicName, string subscriptionName, ServiceBusReceiverOptions options) => new ServiceBusReceiver( connection: Connection, entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), isSessionEntity: false, options: options);
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusProcessorClient"/> 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="topicName"></param> /// <param name="subscriptionName"></param> /// <param name="credential">The Azure managed identity credential to use for authorization. Access controls may be specified by the Service Bus namespace or the requested Service Bus entity, depending on Azure configuration.</param> /// <param name="clientOptions">A set of options to apply when configuring the consumer.</param> /// public ServiceBusProcessorClient( string fullyQualifiedNamespace, string topicName, string subscriptionName, TokenCredential credential, ServiceBusProcessorClientOptions clientOptions = default) : this(new ServiceBusConnection(fullyQualifiedNamespace, EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), credential, clientOptions?.ConnectionOptions), clientOptions?.Clone() ?? new ServiceBusProcessorClientOptions()) { }
/// <summary> /// Creates a <see cref="ServiceBusProcessor"/> instance that can be used to process messages using /// event handlers that are set on the processor. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusProcessor"/> for.</param> /// <param name="subscriptionName">The subcription to create a <see cref="ServiceBusProcessor"/> for.</param> /// /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns> public ServiceBusProcessor CreateProcessor( string topicName, string subscriptionName) { ValidateEntityName(topicName); return(new ServiceBusProcessor( entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection: Connection, isSessionEntity: false, options: new ServiceBusProcessorOptions())); }
/// <summary> /// /// </summary> /// <param name="topicName"></param> /// <param name="subscriptionName"></param> /// <param name="options"></param> /// <returns></returns> public ServiceBusReceiver GetSubscriptionReceiver( string topicName, string subscriptionName, ServiceBusReceiverOptions options) { return(ServiceBusReceiver.CreateReceiver( EntityNameFormatter.FormatSubscriptionPath( topicName, subscriptionName), Connection, options)); }
/// <summary> /// Creates a <see cref="ServiceBusSessionProcessor"/> instance that can be used to process /// messages using event handlers that are set on the processor. It uses <see cref="ReceiveMode"/> to specify /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusProcessorOptions"/> type. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusSessionProcessor"/> for.</param> /// <param name="subscriptionName">The subcription to create a <see cref="ServiceBusSessionProcessor"/> for.</param> /// <param name="options">The set of <see cref="ServiceBusSessionProcessor"/> to use for configuring the /// <see cref="ServiceBusSessionProcessor"/>.</param> /// /// <returns>A <see cref="ServiceBusProcessor"/> scoped to the specified topic and subscription.</returns> public ServiceBusSessionProcessor CreateSessionProcessor( string topicName, string subscriptionName, ServiceBusSessionProcessorOptions options = default) { ValidateEntityName(topicName); return(new ServiceBusSessionProcessor( entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection: Connection, options: options ?? new ServiceBusSessionProcessorOptions())); }
/// <summary> /// /// </summary> /// <param name="topicName"></param> /// <param name="subscriptionName"></param> /// <returns></returns> public ServiceBusReceiver GetReceiver( string topicName, string subscriptionName) { ValidateEntityName(topicName); return(new ServiceBusReceiver( connection: Connection, entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), isSessionEntity: false, options: new ServiceBusReceiverOptions())); }
/// <summary> /// /// </summary> /// <returns></returns> public ServiceBusProcessor GetSessionProcessor( string topicName, string subscriptionName, ServiceBusProcessorOptions options = default, string sessionId = default, CancellationToken cancellationToken = default) => new ServiceBusProcessor( entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection: Connection, isSessionEntity: true, sessionId: sessionId, options: options ?? new ServiceBusProcessorOptions());
/// <summary> /// /// </summary> /// <returns></returns> public virtual async Task <ServiceBusReceiver> GetSessionReceiverAsync( string topicName, string subscriptionName, ServiceBusReceiverOptions options = default, string sessionId = default, CancellationToken cancellationToken = default) => await ServiceBusReceiver.CreateSessionReceiverAsync( entityPath : EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection : Connection, sessionId : sessionId, options : options, cancellationToken : cancellationToken).ConfigureAwait(false);
/// <summary> /// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for /// receiving and settling messages from a specific subscription. It uses <see cref="ReceiveMode"/> to specify /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusReceiver"/> for.</param> /// <param name="subscriptionName">The subscription specific to the specified topic to create /// a <see cref="ServiceBusReceiver"/> for.</param> /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the /// <see cref="ServiceBusReceiver"/>.</param> /// /// <returns>A <see cref="ServiceBusReceiver"/> scoped to the specified subscription and topic.</returns> public virtual ServiceBusReceiver CreateReceiver( string topicName, string subscriptionName, ServiceBusReceiverOptions options) { ValidateEntityName(topicName); return(new ServiceBusReceiver( connection: Connection, entityPath: EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), isSessionEntity: false, plugins: Plugins, options: options)); }
/// <summary> /// Creates a <see cref="ServiceBusSessionReceiver"/> instance that can be used for receiving /// and settling messages from a specific session-enabled subscription. It uses <see cref="ReceiveMode"/> to specify /// how messages are received. Defaults to PeekLock mode. The <see cref="ReceiveMode"/> is set in <see cref="ServiceBusReceiverOptions"/>. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusSessionReceiver"/> for.</param> /// <param name="subscriptionName">The session-enabled subscription to create a <see cref="ServiceBusSessionReceiver"/> for.</param> /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the /// <see cref="ServiceBusSessionReceiver"/>.</param> /// <param name="cancellationToken">An optional <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param> /// /// <remarks>Because this is establishing a session lock, this method performs a service call. If there are no available messages in the queue, /// this will throw a <see cref="ServiceBusException"/> with <see cref="ServiceBusException.Reason"/> of <see cref="ServiceBusFailureReason.ServiceTimeout"/>. /// </remarks> /// /// <returns>A <see cref="ServiceBusSessionReceiver"/> scoped to the specified queue and a specific session.</returns> public virtual async Task <ServiceBusSessionReceiver> AcceptNextSessionAsync( string topicName, string subscriptionName, ServiceBusSessionReceiverOptions options = default, CancellationToken cancellationToken = default) { ValidateEntityName(topicName); return(await ServiceBusSessionReceiver.CreateSessionReceiverAsync( entityPath : EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), connection : Connection, plugins : Plugins, options : options, cancellationToken : cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Creates a <see cref="ServiceBusReceiver"/> instance that can be used for receiving from the /// dead letter queue for the specified subscription. /// </summary> /// /// <param name="topicName">The topic to create a <see cref="ServiceBusReceiver"/> for.</param> /// <param name="subscriptionName">The subscription to create a <see cref="ServiceBusReceiver"/> for.</param> /// <param name="options">The set of <see cref="ServiceBusReceiverOptions"/> to use for configuring the /// <see cref="ServiceBusReceiver"/>.</param> /// /// <returns>A <see cref="ServiceBusReceiver"/> scoped to the dead letter queue of the specified /// queue.</returns> public ServiceBusReceiver CreateDeadLetterReceiver( string topicName, string subscriptionName, ServiceBusReceiverOptions options = default) { ValidateEntityName(topicName); return(new ServiceBusReceiver( connection: Connection, entityPath: EntityNameFormatter.FormatDeadLetterPath( EntityNameFormatter.FormatSubscriptionPath( topicName, subscriptionName)), isSessionEntity: false, options: options)); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusSessionProcessor"/> class for use with derived types. /// </summary> /// <param name="client">The client instance to use for the processor.</param> /// <param name="topicName">The topic to create a processor for.</param> /// <param name="subscriptionName">The subscription to create a processor for.</param> /// <param name="options">The set of options to use when configuring the processor.</param> protected ServiceBusSessionProcessor(ServiceBusClient client, string topicName, string subscriptionName, ServiceBusSessionProcessorOptions options) : this(client?.Connection, EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName), options) { }
/// <summary> /// /// </summary> /// <param name="topicName"></param> /// <param name="subscriptionName"></param> /// <returns></returns> public ServiceBusProcessor GetSubscriptionProcessor(string topicName, string subscriptionName) { return(new ServiceBusProcessor( Connection, EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName))); }