Condividi tramite


ProcessorReceiveActions.ReceiveMessagesAsync Method

Definition

Receives a list of ServiceBusReceivedMessage from the entity using ServiceBusReceiveMode mode configured in ReceiveMode, which 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. Messages received using this method are subject to the behavior defined in the AutoCompleteMessages and MaxAutoLockRenewalDuration properties.

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