ServiceBusReceiver Class

Definition

The ServiceBusReceiver is responsible for receiving ServiceBusReceivedMessage and settling messages from Queues and Subscriptions. It is constructed by calling CreateReceiver(String, ServiceBusReceiverOptions).

public class ServiceBusReceiver : IAsyncDisposable
type ServiceBusReceiver = class
    interface IAsyncDisposable
Public Class ServiceBusReceiver
Implements IAsyncDisposable
Inheritance
ServiceBusReceiver
Derived
Implements

Constructors

ServiceBusReceiver()

Initializes a new instance of the ServiceBusReceiver class for mocking.

Properties

EntityPath

The path of the Service Bus entity that the receiver is connected to, specific to the Service Bus namespace that contains it.

FullyQualifiedNamespace

The fully qualified Service Bus namespace that the receiver is associated with. This is likely to be similar to {yournamespace}.servicebus.windows.net.

IsClosed

Indicates whether or not this ServiceBusReceiver has been closed.

PrefetchCount

The number of messages that will be eagerly requested from Queues or Subscriptions and queued locally without regard to whether a processing is currently active, intended to help maximize throughput by allowing the receiver to receive from a local cache rather than waiting on a service request.

ReceiveMode

The ReceiveMode used to specify how messages are received. Defaults to PeekLock mode.

TransactionGroup

Gets the transaction group associated with the receiver. This is an arbitrary string that is used to all senders, receivers, and processors that you wish to use in a transaction that spans multiple different queues, topics, or subscriptions.

Methods

AbandonMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)

Abandons a ServiceBusReceivedMessage.This will make the message available again for immediate processing as the lock on the message held by the receiver will be released.

CloseAsync(CancellationToken)

Performs the task needed to clean up resources used by the ServiceBusReceiver.

CompleteMessageAsync(ServiceBusReceivedMessage, CancellationToken)

Completes a ServiceBusReceivedMessage. This will delete the message from the service.

DeadLetterMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)

Moves a message to the dead-letter subqueue.

DeadLetterMessageAsync(ServiceBusReceivedMessage, String, String, CancellationToken)

Moves a message to the dead-letter subqueue.

DeferMessageAsync(ServiceBusReceivedMessage, IDictionary<String,Object>, CancellationToken)

Indicates that the receiver wants to defer the processing for the message.

DisposeAsync()

Performs the task needed to clean up resources used by the ServiceBusReceiver. This is equivalent to calling CloseAsync(CancellationToken) with the default Azure.Messaging.ServiceBus.LinkCloseMode.

PeekMessageAsync(Nullable<Int64>, CancellationToken)

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

PeekMessagesAsync(Int32, Nullable<Int64>, CancellationToken)
ReceiveDeferredMessageAsync(Int64, CancellationToken)

Receives a deferred message identified by sequenceNumber.

ReceiveDeferredMessagesAsync(IEnumerable<Int64>, CancellationToken)

Receives a IList<T> of deferred messages identified by sequenceNumbers.

ReceiveMessageAsync(Nullable<TimeSpan>, CancellationToken)

Receives a ServiceBusReceivedMessage from the entity using ReceiveMode mode. ReceiveMode defaults to PeekLock mode.

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.

RenewMessageLockAsync(ServiceBusReceivedMessage, CancellationToken)

Renews the lock on the message. The lock will be renewed based on the setting specified on the queue.

Applies to