Table of Contents

Class MessageReceiver

Namespace
Microsoft.ServiceBus.Messaging
Assembly
Microsoft.ServiceBus.dll

Receives messages from the message container and acknowledges them.

public abstract class MessageReceiver : ClientEntity
Inheritance
MessageReceiver
Derived
Inherited Members

Properties

BatchFlushInterval

Gets the batch flush interval.

public virtual TimeSpan BatchFlushInterval { get; }

Property Value

TimeSpan

The batch flush interval. The default value is 20 ms.

BatchingEnabled

Gets a value indicating whether the batching is enabled.

protected bool BatchingEnabled { get; }

Property Value

bool

true if batching is enabled; otherwise, false.

LastPeekedSequenceNumber

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

public virtual long LastPeekedSequenceNumber { get; }

Property Value

long

The sequence number of the message last peeked.

Mode

Gets the message receive mode.

public ReceiveMode Mode { get; protected set; }

Property Value

ReceiveMode

The message receive mode.

OffsetInclusive

protected virtual bool OffsetInclusive { get; set; }

Property Value

bool

Path

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

public abstract string Path { get; }

Property Value

string

A string representing the path of the queue or topic.

PrefetchCount

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

public virtual int PrefetchCount { get; set; }

Property Value

int

The number of messages that the message receiver can simultaneously request.

ReceiverStartTime

Gets or sets the start time of the receiver.

protected virtual DateTime? ReceiverStartTime { get; set; }

Property Value

DateTime?

The start time of the receiver.

StartOffset

Gets or sets the starting point of the offset.

protected virtual string StartOffset { get; set; }

Property Value

string

The starting point of the offset.

SupportsGetRuntimeEntityDescription

protected abstract bool SupportsGetRuntimeEntityDescription { get; }

Property Value

bool

Methods

Abandon(Guid)

Discards the message and relinquishes the message lock ownership.

public void Abandon(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance to abandon.

Abandon(Guid, IDictionary<string, object>)

Discards the message and relinquishes the message lock ownership.

public void Abandon(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token.

propertiesToModify IDictionary<string, object>

The properties to modify.

AbandonAsync(Guid)

Asynchronously discards the message and relinquishes the message lock ownership.

public Task AbandonAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance to abandon.

Returns

Task

The asynchronous operation.

AbandonAsync(Guid, IDictionary<string, object>)

Asynchronously discards the message and relinquishes the message lock ownership.

public Task AbandonAsync(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token.

propertiesToModify IDictionary<string, object>

The properties to modify.

Returns

Task

The asynchronous operation.

Complete(Guid)

Completes the receive operation on a message.

public void Complete(Guid lockToken)

Parameters

lockToken Guid

The lock token of the BrokeredMessage. This is only available when a message is received in peek-lock mode. The lock token is used internally to complete or abandon a message.

CompleteAsync(Guid)

Asynchronously completes the receive operation on a message.

public Task CompleteAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token.

Returns

Task

The asynchronous operation.

CompleteBatch(IEnumerable<Guid>)

Completes the receive operation on a batch of message.

public void CompleteBatch(IEnumerable<Guid> lockTokens)

Parameters

lockTokens IEnumerable<Guid>

The lock tokens.

CompleteBatchAsync(IEnumerable<Guid>)

Asynchronously completes the receive operation on a batch of message.

public Task CompleteBatchAsync(IEnumerable<Guid> lockTokens)

Parameters

lockTokens IEnumerable<Guid>

The lock tokens.

Returns

Task

The asynchronous operation.

DeadLetter(Guid)

Moves the undelivered message to the dead letter queue.

public void DeadLetter(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

DeadLetter(Guid, IDictionary<string, object>)

Moves the undelivered message to the dead letter queue.

public void DeadLetter(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

propertiesToModify IDictionary<string, object>

The properties to modify.

DeadLetter(Guid, string, string)

Moves the undelivered message to the dead letter queue.

public void DeadLetter(Guid lockToken, string deadLetterReason, string deadLetterErrorDescription)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

deadLetterReason string

The reason for deadlettering the message.

deadLetterErrorDescription string

The error description for deadlettering the message.

DeadLetterAsync(Guid)

Asynchronously moves the undelivered message to the dead letter queue.

public Task DeadLetterAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

Returns

Task

The asynchronous operation.

DeadLetterAsync(Guid, IDictionary<string, object>)

Asynchronously moves the undelivered message to the dead letter queue.

public Task DeadLetterAsync(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

propertiesToModify IDictionary<string, object>

The properties to modify.

Returns

Task

The asynchronous operation.

DeadLetterAsync(Guid, string, string)

Asynchronously moves the undelivered message to the dead letter queue.

public Task DeadLetterAsync(Guid lockToken, string deadLetterReason, string deadLetterErrorDescription)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

deadLetterReason string

The reason for deadlettering the message.

deadLetterErrorDescription string

The error description for deadlettering the message.

Returns

Task

The asynchronous operation.

Defer(Guid)

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

public void Defer(Guid lockToken)

Parameters

lockToken Guid

The lock token of the BrokeredMessage. This is only available when a message is received in peek-lock mode. The lock token is used internally to complete or abandon a message.

Defer(Guid, IDictionary<string, object>)

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

public void Defer(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token.

propertiesToModify IDictionary<string, object>

The properties to modify.

DeferAsync(Guid)

Asynchronously defer the processing of the message.

public Task DeferAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token.

Returns

Task

The asynchronous operation.

DeferAsync(Guid, IDictionary<string, object>)

Asynchronously defer the processing of the message.

public Task DeferAsync(Guid lockToken, IDictionary<string, object> propertiesToModify)

Parameters

lockToken Guid

The lock token.

propertiesToModify IDictionary<string, object>

The properties to modify.

Returns

Task

The asynchronous operation.

GetLockToken(BrokeredMessage)

Gets the lock token bound to the message.

protected static Guid GetLockToken(BrokeredMessage message)

Parameters

message BrokeredMessage

The BrokeredMessage from which to get the lock token.

Returns

Guid

The lock token of the message.

GetLockTokens(IEnumerable<BrokeredMessage>)

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

protected static IEnumerable<Guid> GetLockTokens(IEnumerable<BrokeredMessage> messages)

Parameters

messages IEnumerable<BrokeredMessage>

The collection of messages from which to get the lock tokens.

Returns

IEnumerable<Guid>

The collection of lock tokens from the specified messages.

GetProperty<T>()

protected virtual T GetProperty<T>()

Returns

T

Type Parameters

T

OnAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, TimeSpan)

Executes upon calling the Abandon operation.

protected virtual void OnAbandon(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

timeout TimeSpan

The time span the operation waits before it times out.

OnBeginAbandon(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnAbandon or BeginAbandon operation.

protected abstract IAsyncResult OnBeginAbandon(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

fromSync bool

The start of the synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to abandon the messages and relinquish its lock.

OnBeginComplete(TrackingContext, IEnumerable<ArraySegment<byte>>, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnComplete or BeginComplete operation.

protected abstract IAsyncResult OnBeginComplete(TrackingContext trackingContext, IEnumerable<ArraySegment<byte>> deliveryTags, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

deliveryTags IEnumerable<ArraySegment<byte>>

A collection of delivery tags.

fromSync bool

The start of the synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to complete receiving of messages.

OnBeginComplete(TrackingContext, IEnumerable<Guid>, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnComplete or BeginComplete operation.

protected abstract IAsyncResult OnBeginComplete(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

fromSync bool

The start of the synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to complete receiving of messages.

OnBeginDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, string, string, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnDeadLetter or BeginDeadLetter operation.

protected abstract IAsyncResult OnBeginDeadLetter(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

deadLetterReason string

The reason for deadlettering the messages.

deadLetterErrorDescription string

The error description for deadlettering the messages.

fromSync bool

The start of the synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to move undelivered of messages to the deadletter queue.

OnBeginDefer(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnDefer or BeginDefer operation.

protected abstract IAsyncResult OnBeginDefer(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

fromSync bool

The start of synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to suspend processing of messages.

OnBeginPeek(TrackingContext, long, int, TimeSpan, AsyncCallback, object)

Executes upon calling the BeginPeek operation.

protected abstract IAsyncResult OnBeginPeek(TrackingContext trackingContext, long fromSequenceNumber, int messageCount, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

fromSequenceNumber long

The sequence number from where to begin the operation.

messageCount int

The number of message.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

The result of the operation.

OnBeginRenewMessageLocks(TrackingContext, IEnumerable<Guid>, bool, TimeSpan, AsyncCallback, object)

Executes upon calling the OnBegin operation for lock messages.

protected abstract IAsyncResult OnBeginRenewMessageLocks(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, bool fromSync, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

fromSync bool

The start of the synchronization.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to renew processing of lock messages.

OnBeginTryReceive(TrackingContext, IEnumerable<long>, TimeSpan, AsyncCallback, object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

protected abstract IAsyncResult OnBeginTryReceive(TrackingContext trackingContext, IEnumerable<long> sequenceNumbers, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

sequenceNumbers IEnumerable<long>

The collection of unique numbers assigned to messages, by the Service Bus.

timeout TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to try to receive messages.

OnBeginTryReceive(TrackingContext, int, TimeSpan, AsyncCallback, object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

protected abstract IAsyncResult OnBeginTryReceive(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

messageCount int

The number of messages to try receiving.

serverWaitTime TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to try to receive messages.

OnBeginTryReceive2(TrackingContext, int, TimeSpan, AsyncCallback, object)

Executes upon calling the OnTryReceive or BeginTryReceive operation.

protected abstract IAsyncResult OnBeginTryReceive2(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

messageCount int

The number of messages to try receiving.

serverWaitTime TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to try to receive messages.

OnBeginTryReceiveEventData(TrackingContext, int, TimeSpan, AsyncCallback, object)

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

protected virtual IAsyncResult OnBeginTryReceiveEventData(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, AsyncCallback callback, object state)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

messageCount int

The number of messages to try receiving.

serverWaitTime TimeSpan

The time span the operation waits before it times out.

callback AsyncCallback

An AsyncCallback delegate that references the method to invoke when the operation is complete.

state object

A user-defined object that contains state information about the asynchronous operation.

Returns

IAsyncResult

An IAsyncResult that references the asynchronous operation to try to receive event data.

OnComplete(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes upon calling the Complete operation.

protected virtual void OnComplete(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

timeout TimeSpan

The time span the operation waits before it times out.

OnDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, string, string, TimeSpan)

Executes upon calling the DeadLetter operation.

protected virtual void OnDeadLetter(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

deadLetterReason string

The reason for deadlettering the message.

deadLetterErrorDescription string

The error description for deadlettering the message.

timeout TimeSpan

The time span the operation waits before it times out.

OnDefer(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, TimeSpan)

Executes upon calling the Defer operation.

protected virtual void OnDefer(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

lockTokens IEnumerable<Guid>

The collection of lock tokens bound to the locked message instances.

propertiesToModify IDictionary<string, object>

The properties to modify.

timeout TimeSpan

The time span the operation waits before it times out.

OnEndAbandon(IAsyncResult)

Executes the end abandon action.

protected abstract void OnEndAbandon(IAsyncResult result)

Parameters

result IAsyncResult

The result.

OnEndComplete(IAsyncResult)

Executes the end complete action.

protected abstract void OnEndComplete(IAsyncResult result)

Parameters

result IAsyncResult

The result.

OnEndDeadLetter(IAsyncResult)

Executes the end move to dead letter queue action.

protected abstract void OnEndDeadLetter(IAsyncResult result)

Parameters

result IAsyncResult

An IAsyncResult object that references the asynchronously completed operation.

OnEndDefer(IAsyncResult)

Executes the end defer action.

protected abstract void OnEndDefer(IAsyncResult result)

Parameters

result IAsyncResult

The result.

OnEndPeek(IAsyncResult)

Executes the EndPeek operation.

protected abstract IEnumerable<BrokeredMessage> OnEndPeek(IAsyncResult result)

Parameters

result IAsyncResult

The result of the operation.

Returns

IEnumerable<BrokeredMessage>

A list of messages.

OnEndRenewMessageLocks(IAsyncResult)

Executes the EndRenew action for message locks.

protected abstract IEnumerable<DateTime> OnEndRenewMessageLocks(IAsyncResult result)

Parameters

result IAsyncResult

The result of the operation.

Returns

IEnumerable<DateTime>

A IEnumerable<T> of lock messages.

OnEndTryReceive(IAsyncResult, out IEnumerable<BrokeredMessage>)

Executes the end try receive action.

protected abstract bool OnEndTryReceive(IAsyncResult result, out IEnumerable<BrokeredMessage> messages)

Parameters

result IAsyncResult

The result.

messages IEnumerable<BrokeredMessage>

The received message collection.

Returns

bool

true if it succeeds; false if it fails.

OnEndTryReceive2(IAsyncResult, out IEnumerable<BrokeredMessage>)

Executes the end try receive action.

protected abstract bool OnEndTryReceive2(IAsyncResult result, out IEnumerable<BrokeredMessage> messages)

Parameters

result IAsyncResult

The result.

messages IEnumerable<BrokeredMessage>

The received message collection.

Returns

bool

true if it succeeds; false if it fails.

OnEndTryReceiveEventData(IAsyncResult, out IEnumerable<EventData>)

Executes the EndTryReceive action for the event data.

protected virtual bool OnEndTryReceiveEventData(IAsyncResult result, out IEnumerable<EventData> messages)

Parameters

result IAsyncResult

The result.

messages IEnumerable<EventData>

The received message collection.

Returns

bool

true if it succeeds; false if it fails.

OnMessage(Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump.

public void OnMessage(Action<BrokeredMessage> callback, OnMessageOptions options)

Parameters

callback Action<BrokeredMessage>

The method to invoke when the operation is complete.

options OnMessageOptions

Specifies the OnMessageOptionsoptions with which to instantiate the message pump.

OnMessageAsync(Func<BrokeredMessage, Task>, OnMessageOptions)

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

public void OnMessageAsync(Func<BrokeredMessage, Task> callback, OnMessageOptions options)

Parameters

callback Func<BrokeredMessage, Task>

The method to invoke when the operation is complete.

options OnMessageOptions

Specifies the OnMessageOptionsoptions with which to instantiate the message pump.

OnPeek(TrackingContext, long, int, TimeSpan)

Executes upon calling the Peek operation.

protected virtual IEnumerable<BrokeredMessage> OnPeek(TrackingContext trackingContext, long fromSequenceNumber, int messageCount, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The tracking context.

fromSequenceNumber long

The sequence number from where to peek.

messageCount int

The number of message.

timeout TimeSpan

The time span the operation waits before it times out.

Returns

IEnumerable<BrokeredMessage>

The messages peeked.

OnRenewMessageLocks(TrackingContext, IEnumerable<Guid>, TimeSpan)

Executes the Renew action for lock messages.

protected virtual IEnumerable<DateTime> OnRenewMessageLocks(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, TimeSpan timeout)

Parameters

trackingContext TrackingContext

The tracking context.

lockTokens IEnumerable<Guid>

The lock tokens.

timeout TimeSpan

The time span the operation waits before it times out.

Returns

IEnumerable<DateTime>

The renewed lock messages.

OnTryReceive(TrackingContext, IEnumerable<long>, TimeSpan, out IEnumerable<BrokeredMessage>)

Executes upon calling the TryReceive operation.

protected virtual bool OnTryReceive(TrackingContext trackingContext, IEnumerable<long> sequenceNumbers, TimeSpan timeout, out IEnumerable<BrokeredMessage> messages)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

sequenceNumbers IEnumerable<long>

The collection of unique numbers assigned to messages, by the Service Bus.

timeout TimeSpan

The time span the operation waits before it times out.

messages IEnumerable<BrokeredMessage>

When this method returns, contains the collection of messages received.

Returns

bool

true indicating that this method operation succeeded; otherwise, false.

OnTryReceive(TrackingContext, int, TimeSpan, out IEnumerable<BrokeredMessage>)

Executes upon calling the TryReceive operation.

protected virtual bool OnTryReceive(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, out IEnumerable<BrokeredMessage> messages)

Parameters

trackingContext TrackingContext

The context information associated by a transaction tracking this operation.

messageCount int

The number of messages to try receiving.

serverWaitTime TimeSpan

The time span the operation waits before it times out.

messages IEnumerable<BrokeredMessage>

When this method returns, contains the collection of messages received.

Returns

bool

true indicating that this method operation succeeded; otherwise, false.

Peek()

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

public BrokeredMessage Peek()

Returns

BrokeredMessage

The BrokeredMessage that represents the next message to be read.

Peek(long)

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

public BrokeredMessage Peek(long fromSequenceNumber)

Parameters

fromSequenceNumber long

The sequence number from where to read the message.

Returns

BrokeredMessage

The BrokeredMessage that represents the next message to be read.

PeekAsync()

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

public Task<BrokeredMessage> PeekAsync()

Returns

Task<BrokeredMessage>

The asynchronous operation.

PeekAsync(long)

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

public Task<BrokeredMessage> PeekAsync(long fromSequenceNumber)

Parameters

fromSequenceNumber long

The sequence number from where to read the message.

Returns

Task<BrokeredMessage>

The asynchronous operation.

PeekBatch(int)

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

public IEnumerable<BrokeredMessage> PeekBatch(int messageCount)

Parameters

messageCount int

The number of message.

Returns

IEnumerable<BrokeredMessage>

The batch of message to be read.

PeekBatch(long, int)

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

public IEnumerable<BrokeredMessage> PeekBatch(long fromSequenceNumber, int messageCount)

Parameters

fromSequenceNumber long

The sequence number from where to read a batch message.

messageCount int

The number of message.

Returns

IEnumerable<BrokeredMessage>

The batch of message to be read.

PeekBatchAsync(int)

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

public Task<IEnumerable<BrokeredMessage>> PeekBatchAsync(int messageCount)

Parameters

messageCount int

The number of message.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

PeekBatchAsync(long, int)

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

public Task<IEnumerable<BrokeredMessage>> PeekBatchAsync(long fromSequenceNumber, int messageCount)

Parameters

fromSequenceNumber long

The sequence number from where to read a batch message.

messageCount int

The number of message.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

Receive()

Receives a BrokeredMessage from the current queue or topic.

public BrokeredMessage Receive()

Returns

BrokeredMessage

The BrokeredMessage that represents the received message.

Receive(long)

Receives a message from the current queue or topic.

public BrokeredMessage Receive(long sequenceNumber)

Parameters

sequenceNumber long

The sequence number of the message to receive.

Returns

BrokeredMessage

The BrokeredMessage that represents the received message.

Receive(TimeSpan)

Receives a BrokeredMessage from the current queue or topic.

public BrokeredMessage Receive(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits before the operation times out.

Returns

BrokeredMessage

The BrokeredMessage that represents the received message.

ReceiveAsync()

Asynchronously receives a message from the current queue or topic.

public Task<BrokeredMessage> ReceiveAsync()

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveAsync(long)

Asynchronously receives a message from the current queue or topic.

public Task<BrokeredMessage> ReceiveAsync(long sequenceNumber)

Parameters

sequenceNumber long

The sequence number of the message to receive.

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveAsync(TimeSpan)

Asynchronously receives a message from the current queue or topic.

public Task<BrokeredMessage> ReceiveAsync(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits before the operation times out.

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveBatch(IEnumerable<long>)

Receives a batch of messages.

public IEnumerable<BrokeredMessage> ReceiveBatch(IEnumerable<long> sequenceNumbers)

Parameters

sequenceNumbers IEnumerable<long>

The sequence numbers.

Returns

IEnumerable<BrokeredMessage>

A batch of messages.

ReceiveBatch(int)

Receives a batch of messages.

public IEnumerable<BrokeredMessage> ReceiveBatch(int messageCount)

Parameters

messageCount int

The maximum number of messages to return in the batch. As this is an approximation, fewer messages may be returned even if the number of messages is higher than messageCount.

Returns

IEnumerable<BrokeredMessage>

A batch of messages.

ReceiveBatch(int, TimeSpan)

Receives a batch of messages.

public IEnumerable<BrokeredMessage> ReceiveBatch(int messageCount, TimeSpan serverWaitTime)

Parameters

messageCount int

The maximum number of messages to receive.

serverWaitTime TimeSpan

The server wait time.

Returns

IEnumerable<BrokeredMessage>

A batch of messages.

ReceiveBatchAsync(IEnumerable<long>)

Asynchronously receives a batch of messages.

public Task<IEnumerable<BrokeredMessage>> ReceiveBatchAsync(IEnumerable<long> sequenceNumbers)

Parameters

sequenceNumbers IEnumerable<long>

The sequence numbers.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

ReceiveBatchAsync(int)

Asynchronously receives a batch of messages.

public Task<IEnumerable<BrokeredMessage>> ReceiveBatchAsync(int messageCount)

Parameters

messageCount int

The maximum number of messages to return in the batch. As this is an approximation, fewer messages may be returned even if the number of messages is higher than messageCount.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

ReceiveBatchAsync(int, TimeSpan)

Asynchronously receives a batch of messages.

public Task<IEnumerable<BrokeredMessage>> ReceiveBatchAsync(int messageCount, TimeSpan serverWaitTime)

Parameters

messageCount int

The maximum number of messages to receive.

serverWaitTime TimeSpan

The server wait time.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.