MessageReceiver 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
Public MustInherit Class MessageReceiver
Inherits ClientEntity
Inheritance
MessageReceiverMessageReceiver
Derived

Remarks

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 Issues = new List(); foreach (var issue in Issues) { myMessageSender.Send(new BrokeredMessage(issue)); }


 //********************************************************************************
 //                           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(); }


 //********************************************************************************
 //                    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(); }

Properties

BatchFlushInterval BatchFlushInterval

Gets the batch flush interval.

BatchingEnabled BatchingEnabled

Gets a value indicating whether the batching is enabled.

IsClosed IsClosed Inherited from ClientEntity
LastPeekedSequenceNumber LastPeekedSequenceNumber

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

Mode Mode

Gets the message receive mode.

OffsetInclusive OffsetInclusive
Path Path

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

PrefetchCount PrefetchCount

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

ReceiverStartTime ReceiverStartTime

Gets or sets the start time of the receiver.

RetryPolicy RetryPolicy Inherited from ClientEntity
StartOffset StartOffset

Gets or sets the starting point of the offset.

SupportsGetRuntimeEntityDescription SupportsGetRuntimeEntityDescription
ThisLock ThisLock Inherited from ClientEntity

Methods

Abandon(Guid) Abandon(Guid)

Discards the message and relinquishes the message lock ownership.

Abandon(Guid, IDictionary<String,Object>) Abandon(Guid, IDictionary<String,Object>)

Discards the message and relinquishes the message lock ownership.

AbandonAsync(Guid) AbandonAsync(Guid)

Asynchronously discards the message and relinquishes the message lock ownership.

AbandonAsync(Guid, IDictionary<String,Object>) AbandonAsync(Guid, IDictionary<String,Object>)

Asynchronously discards the message and relinquishes the message lock ownership.

Abort() Abort() Inherited from ClientEntity
Close() Close() Inherited from ClientEntity
CloseAsync() CloseAsync() Inherited from ClientEntity
Complete(Guid) Complete(Guid)

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

CompleteAsync(Guid) CompleteAsync(Guid)

ly 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>) CompleteBatch(IEnumerable<Guid>)

e 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>) CompleteBatchAsync(IEnumerable<Guid>)

ly 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) DeadLetter(Guid)

Moves the undelivered message to the dead letter queue.

DeadLetter(Guid, IDictionary<String,Object>) DeadLetter(Guid, IDictionary<String,Object>)

Moves the undelivered message to the dead letter queue.

DeadLetter(Guid, String, String) DeadLetter(Guid, String, String)

Moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid) DeadLetterAsync(Guid)

Asynchronously moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid, IDictionary<String,Object>) DeadLetterAsync(Guid, IDictionary<String,Object>)

Asynchronously moves the undelivered message to the dead letter queue.

DeadLetterAsync(Guid, String, String) DeadLetterAsync(Guid, String, String)

Asynchronously moves the undelivered message to the dead letter queue.

Defer(Guid) Defer(Guid)

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

Defer(Guid, IDictionary<String,Object>) Defer(Guid, IDictionary<String,Object>)

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

DeferAsync(Guid) DeferAsync(Guid)

Asynchronously defer the processing of the message.

DeferAsync(Guid, IDictionary<String,Object>) DeferAsync(Guid, IDictionary<String,Object>)

Asynchronously defer the processing of the message.

Fault() Fault() Inherited from ClientEntity
GetLockToken(BrokeredMessage) GetLockToken(BrokeredMessage)

Gets the lock token bound to the message.

GetLockTokens(IEnumerable<BrokeredMessage>) GetLockTokens(IEnumerable<BrokeredMessage>)

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

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

Executes the abandon action.

OnAbort() OnAbort() Inherited from ClientEntity
OnBeginAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, Boolean, TimeSpan, AsyncCallback, Object) OnBeginAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnAbandon or BeginAbandon operation.

OnBeginClose(TimeSpan, AsyncCallback, Object) OnBeginClose(TimeSpan, AsyncCallback, Object) Inherited from ClientEntity
OnBeginComplete(TrackingContext, IEnumerable<ArraySegment<Byte>>, Boolean, TimeSpan, AsyncCallback, Object) OnBeginComplete(TrackingContext, IEnumerable<ArraySegment<Byte>>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnComplete or BeginComplete operation.

OnBeginComplete(TrackingContext, IEnumerable<Guid>, Boolean, TimeSpan, AsyncCallback, Object) OnBeginComplete(TrackingContext, IEnumerable<Guid>, 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) 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) OnBeginDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, Boolean, TimeSpan, AsyncCallback, Object)

Executes upon calling the OnDefer or BeginDefer operation.

OnBeginOpen(TimeSpan, AsyncCallback, Object) OnBeginOpen(TimeSpan, AsyncCallback, Object) Inherited from ClientEntity
OnBeginPeek(TrackingContext, Int64, Int32, TimeSpan, AsyncCallback, Object) OnBeginPeek(TrackingContext, Int64, Int32, TimeSpan, AsyncCallback, Object)

Executes upon calling the BeginPeek operation.

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

Executes upon calling the OnBegin operation for lock messages.

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

Executes the begin try receive action.

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

Executes the begin try receive action.

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

Executes the begin try receive action.

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

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

OnClose(TimeSpan) OnClose(TimeSpan) Inherited from ClientEntity
OnClosed() OnClosed() Inherited from ClientEntity
OnComplete(TrackingContext, IEnumerable<Guid>, TimeSpan) OnComplete(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the complete action.

OnDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, String, String, TimeSpan) 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) OnDefer(TrackingContext, IEnumerable<Guid>, IDictionary<String,Object>, TimeSpan)

Executes the defer action.

OnEndAbandon(IAsyncResult) OnEndAbandon(IAsyncResult)

Executes the end abandon action.

OnEndClose(IAsyncResult) OnEndClose(IAsyncResult) Inherited from ClientEntity
OnEndComplete(IAsyncResult) OnEndComplete(IAsyncResult)

Executes the end complete action.

OnEndDeadLetter(IAsyncResult) OnEndDeadLetter(IAsyncResult)

Executes the end move to dead letter queue action.

OnEndDefer(IAsyncResult) OnEndDefer(IAsyncResult)

Executes the end defer action.

OnEndOpen(IAsyncResult) OnEndOpen(IAsyncResult) Inherited from ClientEntity
OnEndPeek(IAsyncResult) OnEndPeek(IAsyncResult)

Executes the EndPeek operation.

OnEndRenewMessageLocks(IAsyncResult) OnEndRenewMessageLocks(IAsyncResult)

Executes the EndRenew action for message locks.

OnEndTryReceive(IAsyncResult, IEnumerable<BrokeredMessage>) OnEndTryReceive(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

OnEndTryReceive2(IAsyncResult, IEnumerable<BrokeredMessage>) OnEndTryReceive2(IAsyncResult, IEnumerable<BrokeredMessage>)

Executes the end try receive action.

OnEndTryReceiveEventData(IAsyncResult, IEnumerable<EventData>) OnEndTryReceiveEventData(IAsyncResult, IEnumerable<EventData>)

Executes the EndTryReceive action for the event data.

OnFaulted() OnFaulted() Inherited from ClientEntity
OnMessage(Action<BrokeredMessage>, OnMessageOptions) OnMessage(Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump.

OnMessageAsync(Func<BrokeredMessage,Task>, OnMessageOptions) OnMessageAsync(Func<BrokeredMessage,Task>, OnMessageOptions)

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

OnOpen(TimeSpan) OnOpen(TimeSpan) Inherited from ClientEntity
OnOpened() OnOpened() Inherited from ClientEntity
OnPeek(TrackingContext, Int64, Int32, TimeSpan) OnPeek(TrackingContext, Int64, Int32, TimeSpan)

Executes upon calling the Peek operation.

OnRenewMessageLocks(TrackingContext, IEnumerable<Guid>, TimeSpan) OnRenewMessageLocks(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the Renew action for lock messages.

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

Executes the try receive action.

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

Executes the try receive action.

Peek() Peek()

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

Peek(Int64) Peek(Int64)

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

PeekAsync() PeekAsync()

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

PeekAsync(Int64) PeekAsync(Int64)

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

PeekBatch(Int32) PeekBatch(Int32)

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

PeekBatch(Int64, Int32) PeekBatch(Int64, Int32)

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

PeekBatchAsync(Int32) PeekBatchAsync(Int32)

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

PeekBatchAsync(Int64, Int32) PeekBatchAsync(Int64, Int32)

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

Receive() Receive()

Receives a BrokeredMessage from the current queue or topic.

Receive(Int64) Receive(Int64)

Receives a message from the current queue or topic.

Receive(TimeSpan) Receive(TimeSpan)

Receives a BrokeredMessage from the current queue or topic.

ReceiveAsync() ReceiveAsync()

Asynchronously receives a message from the current queue or topic.

ReceiveAsync(Int64) ReceiveAsync(Int64)

Asynchronously receives a message from the current queue or topic.

ReceiveAsync(TimeSpan) ReceiveAsync(TimeSpan)

Asynchronously receives a message from the current queue or topic.

ReceiveBatch(IEnumerable<Int64>) ReceiveBatch(IEnumerable<Int64>)

Receives a batch of messages.

ReceiveBatch(Int32) ReceiveBatch(Int32)

Receives a batch of messages.

ReceiveBatch(Int32, TimeSpan) ReceiveBatch(Int32, TimeSpan)

Receives a batch of messages.

ReceiveBatchAsync(IEnumerable<Int64>) ReceiveBatchAsync(IEnumerable<Int64>)

Asynchronously receives a batch of messages.

ReceiveBatchAsync(Int32) ReceiveBatchAsync(Int32)

Asynchronously receives a batch of messages.

ReceiveBatchAsync(Int32, TimeSpan) ReceiveBatchAsync(Int32, TimeSpan)

Asynchronously receives a batch of messages.

ThrowIfClosed() ThrowIfClosed() Inherited from ClientEntity
ThrowIfDisposed() ThrowIfDisposed() Inherited from ClientEntity
ThrowIfDisposedOrImmutable() ThrowIfDisposedOrImmutable() Inherited from ClientEntity
ThrowIfDisposedOrNotOpen() ThrowIfDisposedOrNotOpen() Inherited from ClientEntity
ThrowIfFaulted() ThrowIfFaulted() Inherited from ClientEntity

Extension Methods

IsDefined(Object) IsDefined(Object)

Determines if a certain property is defined or not.

IsNull(Object) IsNull(Object)

Determines if a certain property is null or not.

IsPrimitive(Object) IsPrimitive(Object)

Determines if a certain property is of premitive JSON type.

Applies to