ServiceBusClient Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The ServiceBusClient is the top-level client through which all Service Bus entities can be interacted with. Any lower level types retrieved from here, such as ServiceBusSender and ServiceBusReceiver will share the same AMQP connection. Disposing the ServiceBusClient will cause the AMQP connection to close.
public class ServiceBusClient : IAsyncDisposable
type ServiceBusClient = class
interface IAsyncDisposable
Public Class ServiceBusClient
Implements IAsyncDisposable
- Inheritance
-
ServiceBusClient
- Implements
Remarks
The ServiceBusClient is safe to cache and use for the lifetime of an application, which is the best practice when the application is making use of Service Bus regularly or semi-regularly. The client is responsible for ensuring efficient network, CPU, and memory use. Calling DisposeAsync() as the application is shutting down will ensure that network resources and other unmanaged objects are properly cleaned up.
Constructors
ServiceBusClient() |
Can be used for mocking. |
ServiceBusClient(String, AzureNamedKeyCredential, ServiceBusClientOptions) |
Initializes a new instance of the ServiceBusClient class. |
ServiceBusClient(String, AzureSasCredential, ServiceBusClientOptions) |
Initializes a new instance of the ServiceBusClient class. |
ServiceBusClient(String, ServiceBusClientOptions) |
Initializes a new instance of the ServiceBusClient class. |
ServiceBusClient(String, TokenCredential, ServiceBusClientOptions) |
Initializes a new instance of the ServiceBusClient class. |
ServiceBusClient(String, TokenCredential) |
Initializes a new instance of the ServiceBusClient class. |
ServiceBusClient(String) |
Initializes a new instance of the ServiceBusClient class. |
Properties
FullyQualifiedNamespace |
The fully qualified Service Bus namespace that the connection is associated with. This is likely
to be similar to |
Identifier |
The name used to identify this ServiceBusClient. |
IsClosed |
Indicates whether or not this ServiceBusClient has been closed. |
TransportType |
The transport type used for this ServiceBusClient. |
Methods
AcceptNextSessionAsync(String, ServiceBusSessionReceiverOptions, CancellationToken) |
Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a session-enabled queue by accepting the next unlocked session that contains Active messages. If there are no unlocked sessions with Active messages, then the call will timeout after the configured TryTimeout value and throw a ServiceBusException with Reason set to ServiceTimeout. The ServiceBusReceiveMode can be specified in the ServiceBusReceiverOptions to configure how messages are received. The default value is PeekLock. |
AcceptNextSessionAsync(String, String, ServiceBusSessionReceiverOptions, CancellationToken) |
Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a session-enabled subscription by accepting the next unlocked session that contains Active messages. If there are no unlocked sessions with Active messages, then the call will timeout after the configured TryTimeout value and throw a ServiceBusException with Reason set to ServiceTimeout. The ServiceBusReceiveMode can be specified in the ServiceBusReceiverOptions to configure how messages are received. The default value is PeekLock. |
AcceptSessionAsync(String, String, ServiceBusSessionReceiverOptions, CancellationToken) |
Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a session-enabled queue by accepting a specific session. The ServiceBusReceiveMode can be specified in the ServiceBusReceiverOptions to configure how messages are received. The default value is PeekLock. |
AcceptSessionAsync(String, String, String, ServiceBusSessionReceiverOptions, CancellationToken) |
Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a session-enabled subscription by accepting a specific session. The ServiceBusReceiveMode can be specified in the ServiceBusReceiverOptions to configure how messages are received. The default value is PeekLock. |
CreateProcessor(String, ServiceBusProcessorOptions) |
Creates a ServiceBusProcessor instance that can be used to process messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
CreateProcessor(String, String, ServiceBusProcessorOptions) |
Creates a ServiceBusProcessor instance that can be used to process messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
CreateProcessor(String, String) |
Creates a ServiceBusProcessor instance that can be used to process messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. If you want to change the ServiceBusReceiveMode, use CreateProcessor(String, String, ServiceBusProcessorOptions) method. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
CreateProcessor(String) |
Creates a ServiceBusProcessor instance that can be used to process messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. If you want to change the ServiceBusReceiveMode, use CreateProcessor(String, ServiceBusProcessorOptions) method. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
CreateReceiver(String, ServiceBusReceiverOptions) |
Creates a ServiceBusReceiver instance that can be used for receiving and settling messages from a specific queue. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions. |
CreateReceiver(String, String, ServiceBusReceiverOptions) |
Creates a ServiceBusReceiver instance that can be used for receiving and settling messages from a specific subscription. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions. |
CreateReceiver(String, String) |
Creates a ServiceBusReceiver instance that can be used for receiving and settling messages from a specific subscription. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. If you want to change the ServiceBusReceiveMode, use CreateReceiver(String, String, ServiceBusReceiverOptions) method. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions. |
CreateReceiver(String) |
Creates a ServiceBusReceiver instance that can be used for receiving and settling messages from a specific queue. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. If you want to change the ServiceBusReceiveMode, use CreateReceiver(String, ServiceBusReceiverOptions) method. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions. |
CreateRuleManager(String, String) |
The ServiceBusRuleManager is used to manage the rules for a subscription. |
CreateSender(String, ServiceBusSenderOptions) |
Creates a ServiceBusSender instance that can be used for sending messages to a specific queue or topic. |
CreateSender(String) |
Creates a ServiceBusSender instance that can be used for sending messages to a specific queue or topic. |
CreateSessionProcessor(String, ServiceBusSessionProcessorOptions) |
Creates a ServiceBusSessionProcessor instance that can be used to process session messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
CreateSessionProcessor(String, String, ServiceBusSessionProcessorOptions) |
Creates a ServiceBusSessionProcessor instance that can be used to process messages using event handlers that are set on the processor. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusProcessorOptions type. |
DisposeAsync() |
Performs the task needed to clean up resources used by the ServiceBusClient, including ensuring that the client itself has been closed. |
Applies to
Azure SDK for .NET