ServiceBusClient.AcceptNextSessionAsync Method

Definition

Overloads

AcceptNextSessionAsync(String, ServiceBusSessionReceiverOptions, CancellationToken)

Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a specific session-enabled queue. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions.

AcceptNextSessionAsync(String, String, ServiceBusSessionReceiverOptions, CancellationToken)

Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a specific session-enabled subscription. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions.

AcceptNextSessionAsync(String, ServiceBusSessionReceiverOptions, CancellationToken)

Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a specific session-enabled queue. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions.

public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver> AcceptNextSessionAsync (string queueName, Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AcceptNextSessionAsync : string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
override this.AcceptNextSessionAsync : string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
Public Overridable Function AcceptNextSessionAsync (queueName 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.

cancellationToken
CancellationToken

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

Returns

Task<ServiceBusSessionReceiver>

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

Exceptions

There are no unlocked sessions in the entity. This can occur if the entity has no messages, or if all of the messages belong to sessions that are locked by other receivers. The Reason will be set to ServiceTimeout in this case.

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 ServiceBusException with Reason of ServiceTimeout.

Applies to

AcceptNextSessionAsync(String, String, ServiceBusSessionReceiverOptions, CancellationToken)

Creates a ServiceBusSessionReceiver instance that can be used for receiving and settling messages from a specific session-enabled subscription. It uses ServiceBusReceiveMode to specify how messages are received. Defaults to PeekLock mode. The ServiceBusReceiveMode is set in ServiceBusReceiverOptions.

public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver> AcceptNextSessionAsync (string topicName, string subscriptionName, Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member AcceptNextSessionAsync : string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
override this.AcceptNextSessionAsync : string * string * Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver>
Public Overridable Function AcceptNextSessionAsync (topicName As String, subscriptionName 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.

cancellationToken
CancellationToken

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

Returns

Task<ServiceBusSessionReceiver>

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

Exceptions

There are no unlocked sessions in the entity. This can occur if the entity has no messages, or if all of the messages belong to sessions that are locked by other receivers. The Reason will be set to ServiceTimeout in this case.

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 ServiceBusException with Reason of ServiceTimeout.

Applies to