Condividi tramite


ServiceBusClient.AcceptSessionAsync Method

Definition

Overloads

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.

AcceptSessionAsync(String, String, ServiceBusSessionReceiverOptions, CancellationToken)

Source:
ServiceBusClient.cs
Source:
ServiceBusClient.cs

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.

public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver> AcceptSessionAsync (string queueName, string sessionId, Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AcceptSessionAsync : string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
override this.AcceptSessionAsync : string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
Public Overridable Function AcceptSessionAsync (queueName As String, sessionId As String, Optional options As ServiceBusSessionReceiverOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ServiceBusSessionReceiver)

Parameters

queueName
String

The session-enabled queue to create a ServiceBusSessionReceiver for.

sessionId
String

Gets or sets a session ID to scope the ServiceBusSessionReceiver to.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

A ServiceBusSessionReceiver scoped to the specified queue and a specific session.

Exceptions

The sessionId corresponds to a session that is currently locked by another receiver. The Reason will be set to SessionCannotBeLocked in this case.

Remarks

Because this is establishing a session lock, this method performs a service call. If the sessionId parameter is null, and there are no available messages in the queue, this will throw a ServiceBusException with Reason of ServiceTimeout.

Applies to

AcceptSessionAsync(String, String, String, ServiceBusSessionReceiverOptions, CancellationToken)

Source:
ServiceBusClient.cs
Source:
ServiceBusClient.cs

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.

public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver> AcceptSessionAsync (string topicName, string subscriptionName, string sessionId, Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AcceptSessionAsync : string * string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
override this.AcceptSessionAsync : string * string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
Public Overridable Function AcceptSessionAsync (topicName As String, subscriptionName As String, sessionId As String, Optional options As ServiceBusSessionReceiverOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ServiceBusSessionReceiver)

Parameters

topicName
String

The topic to create a ServiceBusSessionReceiver for.

subscriptionName
String

The session-enabled subscription to create a ServiceBusSessionReceiver for.

sessionId
String

Gets or sets a session ID to scope the ServiceBusSessionReceiver to.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

A ServiceBusSessionReceiver scoped to the specified queue and a specific session.

Exceptions

The sessionId corresponds to a session that is currently locked by another receiver. The Reason will be set to SessionCannotBeLocked in this case.

Remarks

Because this is establishing a session lock, this method performs a service call. If the sessionId parameter is null, and there are no available messages in the queue, this will throw a ServiceBusException with Reason of ServiceTimeout.

Applies to