Delen via


ServiceBusClient.AcceptNextSessionAsync Method

Definition

Overloads

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.

AcceptNextSessionAsync(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 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.

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

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 Active 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)

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 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.

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

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