MessageReceiver Class

Definition

The MessageReceiver class is used to receive messages from the message container and acknowledge them.

public abstract class MessageReceiver : Microsoft.ServiceBus.Messaging.ClientEntity
Inheritance
MessageReceiver
Derived
Microsoft.ServiceBus.Messaging.MessageSession

Inherited Members

Microsoft.ServiceBus.Messaging.ClientEntity

Remarks

Please note that message delivery mechanism does not provide by default all time reliable message receiving. Service Bus deletes the message once it goes out of the system. For a guaranteed delivery, you can use the PeekLock delivery mode.


             //********************************************************************************
             //                             Sending messages to a Queue
             //********************************************************************************

         // Create a sender
         MessageSender myMessageSender = myQueueClient.CreateSender(SendMode.Default);

         // Send messages
         List<string> Issues = new List<string>();
         foreach (var issue in Issues)
         {
         myMessageSender.Send(new BrokeredMessage(issue));
         }
         </code></pre></example><example><pre><code>
         //********************************************************************************
         //                           Recieving messages from a Queue
         //********************************************************************************

         // Create a receiver
         MessageReceiver myMessageReceiver = 
         myQueueClient.CreateReceiver(ReceiveMode.PeekLock);

         // Receive messages
         for (int count = 0; count < Issues.Count; count++)
         {
         var message = myMessageReceiver.Receive();
         message.Complete();
         }
         </code></pre></example><example><pre><code>
         //********************************************************************************
         //                    Receiving messages from a particular session
         //********************************************************************************

         // Create subscription client
         SubscriptionClient mySubscriptionClient = factory.CreateSubscriptionClient(mySubscription);

         // Create a receiver
         MessageReceiver myMessageReceiver = mySubscriptionClient.AcceptMessageSession(ReceiveMode.PeekLock);

         // Receive messages
         for (int count = 0; count *lt; Issues.Count; count++)
         {
         var message = myMessageReceiver.Receive();
         message.Complete();
         }
         </code></pre></example>

Properties

BatchFlushInterval

Gets the batch flush interval.

BatchingEnabled

Gets a value indicating whether the batching is enabled.

LastPeekedSequenceNumber

Gets or sets the sequence number of the message last peeked.

Mode

Gets the message receive mode.

OffsetInclusive
Path

Gets the path of the queue or topic, relative to the MessagingFactory base address.

PrefetchCount

Gets or sets the number of messages that the message receiver can simultaneously request.

ReceiverStartTime

Gets or sets the start time of the receiver.

StartOffset

Gets or sets the starting point of the offset.

SupportsGetRuntimeEntityDescription

Methods

Abandon(Guid)

Discards the message and relinquishes the message lock ownership.

Abandon(Guid, IDictionary<String,Object>)

Discards the message and relinquishes the message lock ownership.

AbandonAsync(Guid)

Asynchronously discards the message and relinquishes the message lock ownership.

AbandonAsync(Guid, IDictionary<String,Object>)

Asynchronously discards the message and relinquishes the message lock ownership.

Complete(Guid)

Completes the receive operation on a message. If using AMQP, this operation can only be performed on messages that were received by this receiver.

CompleteAsync(Guid)

Asynchronously completes the receive operation on a message. If using AMQP, this operation can only be performed on messages that were received by this receiver.

CompleteBatch(IEnumerable<Guid>)

Completes the receive operation on a batch of message. If using AMQP, this operation can only be performed on messages that were received by this receiver.

CompleteBatchAsync(IEnumerable<Guid>)

Asynchronously completes the receive operation on a batch of message. If using AMQP, this operation can only be performed on messages that were received by this receiver.

DeadLetter(Guid)

Moves the undelivered message to the dead letter queue.

DeadLetter(Guid, IDictionary<String,Object>)

Moves the undelivered message to the dead letter queue.

DeadLetter(Guid, String, String)

Moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid)

Asynchronously moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid, IDictionary<String,Object>)

Asynchronously moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid, String, String)

Asynchronously moves the undelivered message to the dead letter queue.

Defer(Guid)

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

Defer(Guid, IDictionary<String,Object>)

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

DeferAsync(Guid, IDictionary<String,Object>)

Asynchronously defer the processing of the message.

DeferAsync(Guid)

Asynchronously defer the processing of the message.

GetLockToken(BrokeredMessage)

Gets the lock token bound to the message.

GetLockTokens(IEnumerable<BrokeredMessage>)

Gets the collection of lock tokens from the specified collection of messages.

GetProperty<T>()
OnAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, TimeSpan)

Executes the abandon action.

OnBeginAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnAbandon or BeginAbandon operation.

OnBeginComplete(TrackingContext, IEnumerable<Guid>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnComplete or BeginComplete operation.

OnBeginComplete(TrackingContext, IEnumerable<ArraySegment<Byte>>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnComplete or BeginComplete operation.

OnBeginDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, String, String, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnDeadLetter or BeginDeadLetter operation.

OnBeginDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnDefer or BeginDefer operation.

OnBeginPeek(TrackingContext, Int64, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the BeginPeek operation.

OnBeginRenewMessageLocks(TrackingContext, IEnumerable<Guid>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnBegin operation for lock messages.

OnBeginTryReceive(TrackingContext, IEnumerable<Int64>, TimeSpan, AsyncCallback, Object)

Executes the begin try receive action.

OnBeginTryReceive(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes the begin try receive action.

OnBeginTryReceive2(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes the begin try receive action.

OnBeginTryReceiveEventData(TrackingContext, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnTryReceive or BeginTryReceive operation for the event data.

OnComplete(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the complete action.

OnDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, String, String, TimeSpan)

Executes the move to dead letter queue action.

OnDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, TimeSpan)

Executes the defer action.

OnEndAbandon(IAsyncResult)

Executes the end abandon action.

OnEndComplete(IAsyncResult)

Executes the end complete action.

OnEndDeadLetter(IAsyncResult)

Executes the end move to dead letter queue action.

OnEndDefer(IAsyncResult)

Executes the end defer action.

OnEndPeek(IAsyncResult)

Executes the EndPeek operation.

OnEndRenewMessageLocks(IAsyncResult)

Executes the EndRenew action for message locks.

OnEndTryReceive(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

OnEndTryReceive2(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

OnEndTryReceiveEventData(IAsyncResult, IEnumerable<EventData>)

Executes the EndTryReceive action for the event data.

OnMessage(Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump.

OnMessageAsync(Func<BrokeredMessage,Task>, OnMessageOptions)

Asynchronously processes a message in an event-driven message pump.

OnPeek(TrackingContext, Int64, Int32, TimeSpan)

Executes upon calling the Peek operation.

OnRenewMessageLocks(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the Renew action for lock messages.

OnTryReceive(TrackingContext, IEnumerable<Int64>, TimeSpan, IEnumerable<BrokeredMessage>)

Executes the try receive action.

OnTryReceive(TrackingContext, Int32, TimeSpan, IEnumerable<BrokeredMessage>)

Executes the try receive action.

Peek()

Reads the next message without changing the state of the receiver or the message source.

Peek(Int64)

Reads the next message without changing the state of the receiver or the message source.

PeekAsync(Int64)

Asynchronously reads the next message without changing the state of the receiver or the message source.

PeekAsync()

Asynchronously reads the next message without changing the state of the receiver or the message source.

PeekBatch(Int32)

Reads the next batch of message without changing the state of the receiver or the message source.

PeekBatch(Int64, Int32)

Reads the next batch of message without changing the state of the receiver or the message source.

PeekBatchAsync(Int32)

Asynchronously reads the next batch of message without changing the state of the receiver or the message source.

PeekBatchAsync(Int64, Int32)

Asynchronously reads the next batch of message without changing the state of the receiver or the message source.

Receive()

Receives a BrokeredMessage from the current queue or topic.

Receive(Int64)

Receives a message from the current queue or topic.

Receive(TimeSpan)

Receives a BrokeredMessage from the current queue or topic.

ReceiveAsync(Int64)

Asynchronously receives a message from the current queue or topic.

ReceiveAsync(TimeSpan)

Asynchronously receives a message from the current queue or topic.

ReceiveAsync()

Asynchronously receives a message from the current queue or topic.

ReceiveBatch(IEnumerable<Int64>)

Receives a batch of messages.

ReceiveBatch(Int32)

Receives a batch of messages.

ReceiveBatch(Int32, TimeSpan)

Receives a batch of messages.

ReceiveBatchAsync(IEnumerable<Int64>)

Asynchronously receives a batch of messages.

ReceiveBatchAsync(Int32)

Asynchronously receives a batch of messages.

ReceiveBatchAsync(Int32, TimeSpan)

Asynchronously receives a batch of messages.

Extension Methods

IsDefined(Object)
IsNull(Object)
IsPrimitive(Object)