Interface IReceiverClient
- Namespace
- Microsoft.Azure.ServiceBus.Core
- Assembly
- Microsoft.Azure.ServiceBus.dll
An interface used to describe common functionality for receiving messages from IQueueClient and ISubscriptionClient.
public interface IReceiverClient : IClientEntity
- Inherited Members
Remarks
Use IMessageReceiver for advanced set of functionality.
Properties
PrefetchCount
Prefetch speeds up the message flow by aiming to have a message readily available for local retrieval when and before the application asks for one using Receive. Setting a non-zero value prefetches PrefetchCount number of messages. Setting the value to zero turns prefetch off. Defaults to 0.
int PrefetchCount { get; set; }
Property Value
Remarks
When Prefetch is enabled, the receiver will quietly acquire more messages, up to the PrefetchCount limit, than what the application immediately asks for. A single initial Receive/ReceiveAsync call will therefore acquire a message for immediate consumption that will be returned as soon as available, and the client will proceed to acquire further messages to fill the prefetch buffer in the background.
While messages are available in the prefetch buffer, any subsequent ReceiveAsync calls will be immediately satisfied from the buffer, and the buffer is replenished in the background as space becomes available.If there are no messages available for delivery, the receive operation will drain the buffer and then wait or block as expected.
Updates to this value take effect on the next receive call to the service.
ReceiveMode
Gets the ReceiveMode of the current receiver.
ReceiveMode ReceiveMode { get; }
Property Value
Methods
AbandonAsync(string, IDictionary<string, object>)
Abandons a Message using a lock token. This will make the message available again for processing.
Task AbandonAsync(string lockToken, IDictionary<string, object> propertiesToModify = null)
Parameters
lockToken
stringThe lock token of the corresponding message to abandon.
propertiesToModify
IDictionary<string, object>The properties of the message to modify while abandoning the message.
Returns
Remarks
A lock token can be found in LockToken, only when ReceiveMode is set to PeekLock. Abandoning a message will increase the delivery count on the message. This operation can only be performed on messages that were received by this receiver.
CompleteAsync(string)
Completes a Message using its lock token. This will delete the message from the queue.
Task CompleteAsync(string lockToken)
Parameters
lockToken
stringThe lock token of the corresponding message to complete.
Returns
Remarks
A lock token can be found in LockToken, only when ReceiveMode is set to PeekLock. This operation can only be performed on messages that were received by this receiver.
DeadLetterAsync(string, IDictionary<string, object>)
Moves a message to the deadletter sub-queue.
Task DeadLetterAsync(string lockToken, IDictionary<string, object> propertiesToModify = null)
Parameters
lockToken
stringThe lock token of the corresponding message to deadletter.
propertiesToModify
IDictionary<string, object>The properties of the message to modify while moving to sub-queue.
Returns
Remarks
A lock token can be found in LockToken, only when ReceiveMode is set to PeekLock. In order to receive a message from the deadletter queue, you will need a new IMessageReceiver, with the corresponding path. You can use FormatDeadLetterPath(string) to help with this. This operation can only be performed on messages that were received by this receiver.
DeadLetterAsync(string, string, string)
Moves a message to the deadletter sub-queue.
Task DeadLetterAsync(string lockToken, string deadLetterReason, string deadLetterErrorDescription = null)
Parameters
lockToken
stringThe lock token of the corresponding message to deadletter.
deadLetterReason
stringThe reason for deadlettering the message.
deadLetterErrorDescription
stringThe error description for deadlettering the message.
Returns
Remarks
A lock token can be found in LockToken, only when ReceiveMode is set to PeekLock. In order to receive a message from the deadletter queue, you will need a new IMessageReceiver, with the corresponding path. You can use FormatDeadLetterPath(string) to help with this. This operation can only be performed on messages that were received by this receiver.
RegisterMessageHandler(Func<Message, CancellationToken, Task>, MessageHandlerOptions)
Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. This handler(Func<T1, T2, TResult>) is awaited on every time a new message is received by the receiver.
void RegisterMessageHandler(Func<Message, CancellationToken, Task> handler, MessageHandlerOptions messageHandlerOptions)
Parameters
handler
Func<Message, CancellationToken, Task>A Func<T1, T2, TResult> that processes messages.
messageHandlerOptions
MessageHandlerOptionsThe MessageHandlerOptions options used to configure the settings of the pump.
Remarks
Enable prefetch to speed up the receive rate.
RegisterMessageHandler(Func<Message, CancellationToken, Task>, Func<ExceptionReceivedEventArgs, Task>)
Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. This handler(Func<T1, T2, TResult>) is awaited on every time a new message is received by the receiver.
void RegisterMessageHandler(Func<Message, CancellationToken, Task> handler, Func<ExceptionReceivedEventArgs, Task> exceptionReceivedHandler)
Parameters
handler
Func<Message, CancellationToken, Task>A Func<T1, T2, TResult> that processes messages.
exceptionReceivedHandler
Func<ExceptionReceivedEventArgs, Task>A Func<T, TResult> that is invoked during exceptions. ExceptionReceivedEventArgs contains contextual information regarding the exception.
Remarks
Enable prefetch to speed up the receive rate. Use RegisterMessageHandler(Func<Message, CancellationToken, Task>, MessageHandlerOptions) to configure the settings of the pump.