ServiceBusReceiveActions.ReceiveMessagesAsync 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.
Receives a list of ServiceBusReceivedMessage from the entity.
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.
When this method is used in a single-dispatch functions, messages received are subject to MaxAutoLockRenewalDuration.
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.
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
Azure SDK for .NET