共用方式為


ServiceBusReceiver.PeekMessageAsync Method

Definition

Fetches the next active ServiceBusReceivedMessage without changing the state of the receiver or the message source.

public virtual System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage> PeekMessageAsync (long? fromSequenceNumber = default, System.Threading.CancellationToken cancellationToken = default);
abstract member PeekMessageAsync : Nullable<int64> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>
override this.PeekMessageAsync : Nullable<int64> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>
Public Overridable Function PeekMessageAsync (Optional fromSequenceNumber As Nullable(Of Long) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ServiceBusReceivedMessage)

Parameters

fromSequenceNumber
Nullable<Int64>

An optional sequence number from where to peek the message. This corresponds to the SequenceNumber.

cancellationToken
CancellationToken

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

Returns

The ServiceBusReceivedMessage that represents the next message to be read. Returns null when nothing to peek.

Remarks

The first call to PeekMessageAsync(Nullable<Int64>, CancellationToken) fetches the first active message for this receiver. Each subsequent call fetches the subsequent message in the entity. Unlike a received message, a peeked message will not have a lock token associated with it, and hence it cannot be Completed/Abandoned/Deferred/Deadlettered/Renewed. Also, unlike ReceiveMessageAsync(Nullable<TimeSpan>, CancellationToken), this method will fetch even Deferred messages (but not Deadlettered message).

Applies to