Show / Hide Table of Contents

Class ServiceBusReceiveActions

Represents the set of receive actions that can be taken from within a function invocation.

Inheritance
System.Object
ServiceBusReceiveActions
Namespace: System.Dynamic.ExpandoObject
Assembly: Microsoft.Azure.WebJobs.Extensions.ServiceBus.dll
Syntax
public class ServiceBusReceiveActions

Constructors

ServiceBusReceiveActions()

Initializes a new instance of the ServiceBusReceiveActions class for mocking use in testing.

Declaration
protected ServiceBusReceiveActions ();
Remarks

This constructor exists only to support mocking. When used, class state is not fully initialized, and

will not function correctly; virtual members are meant to be mocked.

Methods

PeekMessagesAsync(Int32, Nullable<Int64>, CancellationToken)

Fetches a list of active messages without changing the state of the receiver or the message source.

Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>> PeekMessagesAsync (int maxMessages, Nullable<long> fromSequenceNumber = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.Int32 maxMessages

The maximum number of messages that will be fetched.

System.Nullable<System.Int64> fromSequenceNumber

An optional sequence number from where to peek the message. This corresponds to the Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.SequenceNumber.

System.Threading.CancellationToken cancellationToken

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

Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>>

An System.Collections.Generic.IReadOnlyList of messages that were peeked.

Remarks

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 Azure.Messaging.ServiceBus.ServiceBusReceiver.ReceiveMessageAsync(System.Nullable{System.TimeSpan},System.Threading.CancellationToken), this method will fetch even Deferred messages (but not Deadlettered messages).

ReceiveDeferredMessagesAsync(IEnumerable<Int64>, CancellationToken)

Receives a list of deferred Azure.Messaging.ServiceBus.ServiceBusReceivedMessage identified by sequenceNumbers. 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.

Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>> ReceiveDeferredMessagesAsync (System.Collections.Generic.IEnumerable<long> sequenceNumbers, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.Collections.Generic.IEnumerable<System.Int64> sequenceNumbers

An System.Collections.Generic.IEnumerable containing the sequence numbers to receive.

System.Threading.CancellationToken cancellationToken

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

Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>>

Messages identified by sequence number are returned. Throws if the messages have not been deferred.

Exceptions
Azure.Messaging.ServiceBus.ServiceBusException

The specified sequence number does not correspond to a message that has been deferred. The Azure.Messaging.ServiceBus.ServiceBusException.Reason will be set to Azure.Messaging.ServiceBus.ServiceBusFailureReason.MessageNotFound in this case.

ReceiveMessagesAsync(Int32, Nullable<TimeSpan>, CancellationToken)

Receives a list of Azure.Messaging.ServiceBus.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.

Declaration
[System.Diagnostics.DebuggerStepThrough]
public virtual System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>> ReceiveMessagesAsync (int maxMessages, Nullable<TimeSpan> maxWaitTime = null, System.Threading.CancellationToken cancellationToken = null);
Parameters
System.Int32 maxMessages

The maximum number of messages that will be received.

System.Nullable<System.TimeSpan> maxWaitTime

An optional System.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 Azure.Messaging.ServiceBus.ServiceBusRetryOptions.TryTimeout will be used.

System.Threading.CancellationToken cancellationToken

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

Returns
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Azure.Messaging.ServiceBus.ServiceBusReceivedMessage>>

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

Back to top Azure SDK for .NET