IMessageReceiver Interface
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.
The MessageReceiver can be used to receive messages from Queues and Subscriptions and acknowledge them.
public interface IMessageReceiver : Microsoft.Azure.ServiceBus.Core.IReceiverClient
type IMessageReceiver = interface
interface IReceiverClient
interface IClientEntity
Public Interface IMessageReceiver
Implements IReceiverClient
- Derived
- Implements
Examples
Create a new MessageReceiver to receive a message from a Subscription
IMessageReceiver messageReceiver = new MessageReceiver(
namespaceConnectionString,
EntityNameHelper.FormatSubscriptionPath(topicName, subscriptionName),
ReceiveMode.PeekLock);
Receive a message from the Subscription.
var message = await messageReceiver.ReceiveAsync();
await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
Remarks
The MessageReceiver provides advanced functionality that is not found in the QueueClient or SubscriptionClient. For instance, ReceiveAsync(), which allows you to receive messages on demand, but also requires you to manually renew locks using RenewLockAsync(Message).
Properties
ClientId |
Gets the ID to identify this client. This can be used to correlate logs and exceptions. (Inherited from IClientEntity) |
IsClosedOrClosing |
Returns true if the client is closed or closing. (Inherited from IClientEntity) |
LastPeekedSequenceNumber |
Gets the sequence number of the last peeked message. |
OperationTimeout |
Duration after which individual operations will timeout. (Inherited from IClientEntity) |
OwnsConnection |
Returns true if connection is owned and false if connection is shared. (Inherited from IClientEntity) |
Path |
Gets the entity path. (Inherited from IClientEntity) |
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. (Inherited from IReceiverClient) |
ReceiveMode |
Gets the ReceiveMode of the current receiver. (Inherited from IReceiverClient) |
RegisteredPlugins |
Gets a list of currently registered plugins for this client. (Inherited from IClientEntity) |
ServiceBusConnection |
Connection object to the service bus namespace. (Inherited from IClientEntity) |
Methods
AbandonAsync(String, IDictionary<String,Object>) |
Abandons a Message using a lock token. This will make the message available again for processing. (Inherited from IReceiverClient) |
CloseAsync() |
Closes the Client. Closes the connections opened by it. (Inherited from IClientEntity) |
CompleteAsync(IEnumerable<String>) |
Completes a series of Message using a list of lock tokens. This will delete the message from the service. |
CompleteAsync(String) |
Completes a Message using its lock token. This will delete the message from the queue. (Inherited from IReceiverClient) |
DeadLetterAsync(String, IDictionary<String,Object>) |
Moves a message to the deadletter sub-queue. (Inherited from IReceiverClient) |
DeadLetterAsync(String, String, String) |
Moves a message to the deadletter sub-queue. (Inherited from IReceiverClient) |
DeferAsync(String, IDictionary<String,Object>) |
Indicates that the receiver wants to defer the processing for the message. |
PeekAsync() |
Fetches the next active message without changing the state of the receiver or the message source. |
PeekAsync(Int32) |
Fetches the next batch of active messages without changing the state of the receiver or the message source. |
PeekBySequenceNumberAsync(Int64, Int32) |
Peeks a batch of messages. |
PeekBySequenceNumberAsync(Int64) |
Asynchronously reads the next message without changing the state of the receiver or the message source. |
ReceiveAsync() |
Receive a message from the entity defined by Path using ReceiveMode mode. |
ReceiveAsync(Int32, TimeSpan) |
Receives a maximum of |
ReceiveAsync(Int32) |
Receives a maximum of |
ReceiveAsync(TimeSpan) |
Receive a message from the entity defined by Path using ReceiveMode mode. |
ReceiveDeferredMessageAsync(IEnumerable<Int64>) |
Receives a IList<T> of deferred messages identified by |
ReceiveDeferredMessageAsync(Int64) |
Receives a specific deferred message identified by |
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. (Inherited from IReceiverClient) |
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. (Inherited from IReceiverClient) |
RegisterPlugin(ServiceBusPlugin) |
Registers a ServiceBusPlugin to be used with this client. (Inherited from IClientEntity) |
RenewLockAsync(Message) |
Renews the lock on the message. The lock will be renewed based on the setting specified on the queue. |
RenewLockAsync(String) |
Renews the lock on the message. The lock will be renewed based on the setting specified on the queue. New lock token expiry date and time in UTC format. |
UnregisterMessageHandlerAsync(TimeSpan) |
Unregister message handler from the receiver if there is an active message handler registered. This operation waits for the completion of inflight receive and message handling operations to finish and unregisters future receives on the message handler which previously registered. (Inherited from IReceiverClient) |
UnregisterPlugin(String) |
Unregisters a ServiceBusPlugin. (Inherited from IClientEntity) |