Class MessageReceiver
- Namespace
- Microsoft.ServiceBus.Messaging
- Assembly
- Microsoft.ServiceBus.dll
The MessageReceiver class is used to receive messages from the message container and acknowledge them.
public abstract class MessageReceiver : ClientEntity
- Inheritance
-
MessageReceiver
- Derived
- Inherited Members
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 class="lang-csharp">//********************************************************************************
// 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 class="lang-csharp">//********************************************************************************
// 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.
public virtual TimeSpan BatchFlushInterval { get; }
Property Value
- TimeSpan
The batch flush interval. The default value is 20 ms.
Remarks
You can set the value of it via SbmpTransportSetting.BatchFlushInterval
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
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.
Remarks
Takes effect on the next receive call to the server.
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
Methods
Abandon(Guid)
Discards the message and relinquishes the message lock ownership.
public void Abandon(Guid lockToken)
Parameters
lockToken
GuidThe lock token bound to the locked message instance to abandon.
Remarks
When the message receiver fails to get the message from the queue/topic, this method should be called. The Service Bus will increment the delivery count of the message. The message receiver now can either attempt to receive the message again or move it to the dead-letter queue.
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
GuidThe 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
GuidThe 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
GuidThe lock token.
propertiesToModify
IDictionary<string, object>The properties to modify.
Returns
- Task
The asynchronous operation.
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.
public void Complete(Guid lockToken)
Parameters
lockToken
GuidThe 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.
Remarks
This method is used as a handshake between the receiver and Service Bus for a guaranteed delivery of the message. If the receiver failed before calling this method, the message will be kept in the queue.
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.
public Task CompleteAsync(Guid lockToken)
Parameters
lockToken
GuidThe lock token.
Returns
- Task
The asynchronous operation.
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.
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. If using AMQP, this operation can only be performed on messages that were received by this receiver.
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
GuidThe 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
GuidThe 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
GuidThe lock token bound to the locked message instance.
deadLetterReason
stringThe reason for deadlettering the message.
deadLetterErrorDescription
stringThe 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
GuidThe 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
GuidThe 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
GuidThe lock token bound to the locked message instance.
deadLetterReason
stringThe reason for deadlettering the message.
deadLetterErrorDescription
stringThe 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
GuidThe 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.
Remarks
Before deferring user should set aside the message receipt for later retrieval.
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
GuidThe 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
GuidThe 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
GuidThe 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
BrokeredMessageThe 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 the abandon action.
protected virtual void OnAbandon(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, TimeSpan timeout)
Parameters
trackingContext
TrackingContextTrackingContext to use.
lockTokens
IEnumerable<Guid>The lock tokens.
propertiesToModify
IDictionary<string, object>timeout
TimeSpanThe timeout.
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
TrackingContextThe 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
boolThe start of the synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult 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
TrackingContextThe context information associated by a transaction tracking this operation.
deliveryTags
IEnumerable<ArraySegment<byte>>A collection of delivery tags.
fromSync
boolThe start of the synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult 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
TrackingContextThe context information associated by a transaction tracking this operation.
lockTokens
IEnumerable<Guid>The collection of lock tokens bound to the locked message instances.
fromSync
boolThe start of the synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult 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
TrackingContextThe 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
stringThe reason for deadlettering the messages.
deadLetterErrorDescription
stringThe error description for deadlettering the messages.
fromSync
boolThe start of the synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult 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
TrackingContextThe 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
boolThe start of synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult 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
TrackingContextThe context information associated by a transaction tracking this operation.
fromSequenceNumber
longThe sequence number from where to begin the operation.
messageCount
intThe number of message.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA 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
TrackingContextThe context information associated by a transaction tracking this operation.
lockTokens
IEnumerable<Guid>The collection of lock tokens bound to the locked message instances.
fromSync
boolThe start of the synchronization.
timeout
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA user-defined object that contains state information about the asynchronous operation.
Returns
- IAsyncResult
AnIAsyncResult that references the asynchronous operation to renew processing of lock messages.
OnBeginTryReceive(TrackingContext, IEnumerable<long>, TimeSpan, AsyncCallback, object)
Executes the begin try receive action.
protected abstract IAsyncResult OnBeginTryReceive(TrackingContext trackingContext, IEnumerable<long> sequenceNumbers, TimeSpan timeout, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextTrackingContext to use.
sequenceNumbers
IEnumerable<long>The sequenceNumbers.
timeout
TimeSpanThe timeout.
callback
AsyncCallbackThe callback.
state
objectThe state.
Returns
OnBeginTryReceive(TrackingContext, int, TimeSpan, AsyncCallback, object)
Executes the begin try receive action.
protected abstract IAsyncResult OnBeginTryReceive(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextTrackingContext to use.
messageCount
intNumber of messages.
serverWaitTime
TimeSpanThe server wait time before it times out.
callback
AsyncCallbackThe callback.
state
objectThe state.
Returns
OnBeginTryReceive2(TrackingContext, int, TimeSpan, AsyncCallback, object)
Executes the begin try receive action.
protected abstract IAsyncResult OnBeginTryReceive2(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, AsyncCallback callback, object state)
Parameters
trackingContext
TrackingContextTrackingContext to use.
messageCount
intNumber of messages.
serverWaitTime
TimeSpanThe server wait time before it times out.
callback
AsyncCallbackThe callback.
state
objectThe state.
Returns
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
TrackingContextThe context information associated by a transaction tracking this operation.
messageCount
intThe number of messages to try receiving.
serverWaitTime
TimeSpanThe time span the operation waits before it times out.
callback
AsyncCallbackAn AsyncCallback delegate that references the method to invoke when the operation is complete.
state
objectA 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 the complete action.
protected virtual void OnComplete(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, TimeSpan timeout)
Parameters
trackingContext
TrackingContextTrackingContext to use.
lockTokens
IEnumerable<Guid>The lock tokens.
timeout
TimeSpanThe timeout.
OnDeadLetter(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, string, string, TimeSpan)
Executes the move to dead letter queue action.
protected virtual void OnDeadLetter(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription, TimeSpan timeout)
Parameters
trackingContext
TrackingContextTrackingContext to use.
lockTokens
IEnumerable<Guid>The lock tokens.
propertiesToModify
IDictionary<string, object>deadLetterReason
stringThe reason for deadlettering the message.
deadLetterErrorDescription
stringThe description information for deadlettering the message.
timeout
TimeSpanThe timeout.
OnDefer(TrackingContext, IEnumerable<Guid>, IDictionary<string, object>, TimeSpan)
Executes the defer action.
protected virtual void OnDefer(TrackingContext trackingContext, IEnumerable<Guid> lockTokens, IDictionary<string, object> propertiesToModify, TimeSpan timeout)
Parameters
trackingContext
TrackingContextTrackingContext to use.
lockTokens
IEnumerable<Guid>The lock tokens.
propertiesToModify
IDictionary<string, object>timeout
TimeSpanThe timeout.
OnEndAbandon(IAsyncResult)
Executes the end abandon action.
protected abstract void OnEndAbandon(IAsyncResult result)
Parameters
result
IAsyncResultThe result.
OnEndComplete(IAsyncResult)
Executes the end complete action.
protected abstract void OnEndComplete(IAsyncResult result)
Parameters
result
IAsyncResultThe result.
OnEndDeadLetter(IAsyncResult)
Executes the end move to dead letter queue action.
protected abstract void OnEndDeadLetter(IAsyncResult result)
Parameters
result
IAsyncResultAn IAsyncResult object that references the asynchronously completed operation.
OnEndDefer(IAsyncResult)
Executes the end defer action.
protected abstract void OnEndDefer(IAsyncResult result)
Parameters
result
IAsyncResultThe result.
OnEndPeek(IAsyncResult)
Executes the EndPeek operation.
protected abstract IEnumerable<BrokeredMessage> OnEndPeek(IAsyncResult result)
Parameters
result
IAsyncResultThe 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
IAsyncResultThe 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
IAsyncResultThe 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
IAsyncResultThe 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
IAsyncResultThe 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
OnMessageOptionsSpecifies 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
OnMessageOptionsSpecifies 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
TrackingContextThe tracking context.
fromSequenceNumber
longThe sequence number from where to peek.
messageCount
intThe number of message.
timeout
TimeSpanThe 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
TrackingContextThe tracking context.
lockTokens
IEnumerable<Guid>The lock tokens.
timeout
TimeSpanThe 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 the try receive action.
protected virtual bool OnTryReceive(TrackingContext trackingContext, IEnumerable<long> sequenceNumbers, TimeSpan timeout, out IEnumerable<BrokeredMessage> messages)
Parameters
trackingContext
TrackingContextTrackingContext to use.
sequenceNumbers
IEnumerable<long>The receipts.
timeout
TimeSpanThe timeout.
messages
IEnumerable<BrokeredMessage>[out] The messages.
Returns
- bool
true if it succeeds, false if it fails.
OnTryReceive(TrackingContext, int, TimeSpan, out IEnumerable<BrokeredMessage>)
Executes the try receive action.
protected virtual bool OnTryReceive(TrackingContext trackingContext, int messageCount, TimeSpan serverWaitTime, out IEnumerable<BrokeredMessage> messages)
Parameters
trackingContext
TrackingContextTrackingContext to use.
messageCount
intNumber of messages.
serverWaitTime
TimeSpanThe server wait time before it times out.
messages
IEnumerable<BrokeredMessage>[out] The messages.
Returns
- bool
true if it succeeds, false if it fails.
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
longThe 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
longThe 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
intThe 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
longThe sequence number from where to read a batch message.
messageCount
intThe 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
intThe 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
longThe sequence number from where to read a batch message.
messageCount
intThe 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.
Remarks
A Null can be returned by this API if operation exceeded the timeout specified, or the operations succeeded but there are no more messages to be received.
Receive(long)
Receives a message from the current queue or topic.
public BrokeredMessage Receive(long sequenceNumber)
Parameters
sequenceNumber
longThe sequence number of the message to receive.
Returns
- BrokeredMessage
The BrokeredMessage that represents the received message.
Remarks
A Null can be returned by this API if operation exceeded the timeout specified, or the operations succeeded but the message with the requested sequenceNumber cannot be located.
Receive(TimeSpan)
Receives a BrokeredMessage from the current queue or topic.
public BrokeredMessage Receive(TimeSpan serverWaitTime)
Parameters
serverWaitTime
TimeSpanThe time span the server waits before the operation times out.
Returns
- BrokeredMessage
The BrokeredMessage that represents the received message.
Remarks
A Null can be returned by this API if operation exceeded the timeout specified, or the operations succeeded but there are no more messages to be received.
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
longThe 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
TimeSpanThe 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.
Remarks
A Null can be returned by this API if operation exceeded the timeout specified, or the operations succeeded but the message with the requested sequenceNumber cannot be located.
ReceiveBatch(int)
Receives a batch of messages.
public IEnumerable<BrokeredMessage> ReceiveBatch(int messageCount)
Parameters
messageCount
intThe number of messages to return in the batch. As this is an approximation, fewer or more messages than
messageCount
may be returned.
Returns
- IEnumerable<BrokeredMessage>
A batch of messages.
Remarks
A Null can be return by this API if operation exceeded the timeout specified, or the operations succeeded but there are no more messages to be received.
ReceiveBatch(int, TimeSpan)
Receives a batch of messages.
public IEnumerable<BrokeredMessage> ReceiveBatch(int messageCount, TimeSpan serverWaitTime)
Parameters
messageCount
intThe number of messages to return in the batch. As this is an approximation, fewer or more messages than
messageCount
may be returned.serverWaitTime
TimeSpanThe server wait time.
Returns
- IEnumerable<BrokeredMessage>
A batch of messages.
Remarks
A Null can be returned by this API if operation exceeded the timeout specified, or the operations succeeded but there are no more messages to be received.
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
intThe number of messages to return in the batch. As this is an approximation, fewer or more messages than
messageCount
may be returned.
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
intThe number of messages to return in the batch. As this is an approximation, fewer or more messages than
messageCount
may be returned.serverWaitTime
TimeSpanThe server wait time.
Returns
- Task<IEnumerable<BrokeredMessage>>
The asynchronous operation.