ServiceBusClient.AcceptNextSessionAsync Method

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.

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.

C#
public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusSessionReceiver> AcceptNextSessionAsync(string queueName, Azure.Messaging.ServiceBus.ServiceBusSessionReceiverOptions options = default, System.Threading.CancellationToken cancellationToken = default);

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

Azure SDK for .NET Preview and Azure SDK for .NET Latest
Product Versions
Azure SDK for .NET Latest, Preview

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.

C#
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);

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

Azure SDK for .NET Preview and Azure SDK for .NET Latest
Product Versions
Azure SDK for .NET Latest, Preview