Megosztás a következőn keresztül:


ServiceBusReceiver.ReceiveMessagesAsync Method

Definition

Overloads

ReceiveMessagesAsync(CancellationToken)

Receives messages as an asynchronous enumerable from the entity using ReceiveMode mode. ReceiveMode defaults to PeekLock mode. Messages will be received from the entity as the IAsyncEnumerable is iterated. If no messages are available, this method will continue polling until messages are available, i.e. it will never return null.

ReceiveMessagesAsync(Int32, Nullable<TimeSpan>, CancellationToken)

Receives a list of ServiceBusReceivedMessage from the entity using ReceiveMode mode. ReceiveMode defaults to PeekLock mode. This method doesn't guarantee to return exact maxMessages messages, even if there are maxMessages messages available in the queue or topic.

ReceiveMessagesAsync(CancellationToken)

Source:
ServiceBusReceiver.cs
Source:
ServiceBusReceiver.cs

Receives messages as an asynchronous enumerable from the entity using ReceiveMode mode. ReceiveMode defaults to PeekLock mode. Messages will be received from the entity as the IAsyncEnumerable is iterated. If no messages are available, this method will continue polling until messages are available, i.e. it will never return null.

public virtual System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage> ReceiveMessagesAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member ReceiveMessagesAsync : System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>
override this.ReceiveMessagesAsync : System.Threading.CancellationToken -> System.Collections.Generic.IAsyncEnumerable<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>
Public Overridable Function ReceiveMessagesAsync (Optional cancellationToken As CancellationToken = Nothing) As IAsyncEnumerable(Of ServiceBusReceivedMessage)

Parameters

cancellationToken
CancellationToken

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

Returns

The message received.

Applies to

ReceiveMessagesAsync(Int32, Nullable<TimeSpan>, CancellationToken)

Source:
ServiceBusReceiver.cs
Source:
ServiceBusReceiver.cs

Receives a list of ServiceBusReceivedMessage from the entity using ReceiveMode mode. ReceiveMode defaults to PeekLock mode. This method doesn't guarantee to return exact maxMessages messages, even if there are maxMessages messages available in the queue or topic.

public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>> ReceiveMessagesAsync (int maxMessages, TimeSpan? maxWaitTime = default, System.Threading.CancellationToken cancellationToken = default);
abstract member ReceiveMessagesAsync : int * Nullable<TimeSpan> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>>
override this.ReceiveMessagesAsync : int * Nullable<TimeSpan> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>>
Public Overridable Function ReceiveMessagesAsync (maxMessages As Integer, Optional maxWaitTime As Nullable(Of TimeSpan) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IReadOnlyList(Of ServiceBusReceivedMessage))

Parameters

maxMessages
Int32

The maximum number of messages that will be received.

maxWaitTime
Nullable<TimeSpan>

An optional TimeSpan specifying the maximum time to wait for the first message before returning an empty list if no messages are available. If not specified, the TryTimeout will be used.

cancellationToken
CancellationToken

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

Returns

List of messages received. Returns an empty list if no message is found.

Applies to