Table of Contents

Class QueueClient

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

Represents the queue client object.

public abstract class QueueClient : ClientEntity
Inheritance
QueueClient
Inherited Members

Properties

MessagingFactory

Gets or sets the messaging factory.

public MessagingFactory MessagingFactory { get; }

Property Value

MessagingFactory

The messaging factory.

Mode

Gets the message receive mode when processing the received message.

public ReceiveMode Mode { get; }

Property Value

ReceiveMode

The message ReceiveMode when processing the received message.

Path

Gets or sets the full path name of the queue.

public string Path { get; }

Property Value

string

The queue path relative to the MessagingFactory base address.

PrefetchCount

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

public int PrefetchCount { get; set; }

Property Value

int

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

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.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by Microsoft.ServiceBus.Messaging.ServiceBusMessagingFactorySettings.OperationTimeout.

OperationCanceledException

Thrown if the client entity has been closed or aborted.

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 bound to the locked message instance to abandon.

propertiesToModify IDictionary<string, object>

The properties of the message 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 discarded message.

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 bound to the locked message instance to abandon.

propertiesToModify IDictionary<string, object>

The properties of the message to modify.

Returns

Task

The discarded message.

AcceptMessageSession()

Accepts a message session that allows grouping of related messages for processing in a single transaction.

public MessageSession AcceptMessageSession()

Returns

MessageSession

A MessageSession that allows grouping of related messages for processing in a single transaction.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by Microsoft.ServiceBus.Messaging.ServiceBusMessagingFactorySettings.OperationTimeout.

OperationCanceledException

Thrown if the client is already closed, aborted, or disposed.

AcceptMessageSession(string)

Accepts a message session that allows grouping of related messages for processing in a single transaction using the given session identifier.

public MessageSession AcceptMessageSession(string sessionId)

Parameters

sessionId string

The session identifier of the message session.

Returns

MessageSession

A MessageSession that allows grouping of related messages for processing in a single transaction.

Exceptions

ArgumentException

Thrown if sessionId is null, empty, or white spaces.

TimeoutException

Thrown if the operation exceeded the timeout value set by Microsoft.ServiceBus.Messaging.ServiceBusMessagingFactorySettings.OperationTimeout.

OperationCanceledException

Thrown if the client is already closed, aborted, or disposed.

AcceptMessageSession(string, TimeSpan)

Accepts a message session that allows grouping of related messages for processing in a single transaction using the given session identifier and wait time.

public MessageSession AcceptMessageSession(string sessionId, TimeSpan serverWaitTime)

Parameters

sessionId string

The session identifier of the message session.

serverWaitTime TimeSpan

The time span the server waits for processing messages before it times out.

Returns

MessageSession

A MessageSession that allows grouping of related messages for processing in a single transaction.

Exceptions

ArgumentException

Thrown if sessionId is null, empty, or white spaces.

ArgumentOutOfRangeException

Thrown if serverWaitTime is not a positive TimeSpan value.

TimeoutException

Thrown if the operation exceeded the timeout value set by Microsoft.ServiceBus.Messaging.ServiceBusMessagingFactorySettings.OperationTimeout.

OperationCanceledException

Thrown if the client is already closed, aborted, or disposed.

AcceptMessageSession(TimeSpan)

Accepts a message session that allows grouping of related messages for processing in a single transaction using the specified server wait time.

public MessageSession AcceptMessageSession(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits for processing messages before it times out.

Returns

MessageSession

A MessageSession that allows grouping of related messages for processing in a single transaction.

Exceptions

ArgumentOutOfRangeException

Thrown if serverWaitTime is not a positive TimeSpan value.

TimeoutException

Thrown if the operation exceeded the timeout value set by serverWaitTime.

OperationCanceledException

Thrown if the client is already closed, aborted, or disposed.

AcceptMessageSessionAsync()

Asynchronously accepts a message session that allows grouping of related messages for processing in a single transaction.

public Task<MessageSession> AcceptMessageSessionAsync()

Returns

Task<MessageSession>

The result of an asynchronous operation.

AcceptMessageSessionAsync(string)

Asynchronously accepts a message session that allows grouping of related messages for processing in a single transaction using the given session identifier.

public Task<MessageSession> AcceptMessageSessionAsync(string sessionId)

Parameters

sessionId string

The session identifier of the message session.

Returns

Task<MessageSession>

The result of an asynchronous operation.

AcceptMessageSessionAsync(string, TimeSpan)

Asynchronously accepts a message session that allows grouping of related messages for processing in a single transaction using the given session identifier and wait time.

public Task<MessageSession> AcceptMessageSessionAsync(string sessionId, TimeSpan serverWaitTime)

Parameters

sessionId string

The session identifier of the message session.

serverWaitTime TimeSpan

The time span the server waits for processing messages before it times out.

Returns

Task<MessageSession>

The result of an asynchronous operation.

AcceptMessageSessionAsync(TimeSpan)

Asynchronously accepts a message session that allows grouping of related messages for processing in a single transaction using the specified server wait time.

public Task<MessageSession> AcceptMessageSessionAsync(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits for processing messages before it times out.

Returns

Task<MessageSession>

The result of an asynchronous operation.

Complete(Guid)

Completes processing of a message.

public void Complete(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by OperationTimeout

OperationCanceledException

Thrown if the client entity has been closed or aborted.

MessageLockLostException

Thrown if the message represented by the lockToken has lost the message lock.

CompleteAsync(Guid)

Asynchronously completes processing of a message.

public Task CompleteAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

Returns

Task

The asynchronous operation.

CompleteBatch(IEnumerable<Guid>)

Completes processing of a message batch.

public void CompleteBatch(IEnumerable<Guid> lockTokens)

Parameters

lockTokens IEnumerable<Guid>

The lock tokens associated with locked messages in the batch.

CompleteBatchAsync(IEnumerable<Guid>)

Asynchronously completes processing of a message batch.

public Task CompleteBatchAsync(IEnumerable<Guid> lockTokens)

Parameters

lockTokens IEnumerable<Guid>

The lock tokens associated with locked messages in the batch.

Returns

Task

The asynchronous operation.

Create(string)

Creates a new copy of QueueClient with specified path.

public static QueueClient Create(string path)

Parameters

path string

The path.

Returns

QueueClient

The created QueueClient.

Create(string, ReceiveMode)

Creates a new copy of QueueClient with specified path and mode.

public static QueueClient Create(string path, ReceiveMode mode)

Parameters

path string

The path.

mode ReceiveMode

The mode.

Returns

QueueClient

The created QueueClient.

CreateFromConnectionString(string)

public static QueueClient CreateFromConnectionString(string connectionString)

Parameters

connectionString string

Returns

QueueClient

CreateFromConnectionString(string, ReceiveMode)

public static QueueClient CreateFromConnectionString(string connectionString, ReceiveMode mode)

Parameters

connectionString string
mode ReceiveMode

Returns

QueueClient

CreateFromConnectionString(string, string)

Creates a new copy of QueueClient from connection string with specified path.

public static QueueClient CreateFromConnectionString(string connectionString, string path)

Parameters

connectionString string

The connection string used.

path string

The path.

Returns

QueueClient

The created QueueClient.

CreateFromConnectionString(string, string, ReceiveMode)

Creates a new copy of QueueClient from connection string with specified path and mode.

public static QueueClient CreateFromConnectionString(string connectionString, string path, ReceiveMode mode)

Parameters

connectionString string

The connection string.

path string

The path.

mode ReceiveMode

The mode.

Returns

QueueClient

The created QueueClient.

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.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by OperationTimeout

OperationCanceledException

Thrown if the client entity has been closed or aborted.

MessageLockLostException

Thrown if the message represented by the lockToken has lost the message lock.

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 of the message 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.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by OperationTimeout

OperationCanceledException

Thrown if the client entity has been closed or aborted.

MessageLockLostException

Thrown if the message represented by the lockToken has lost the message lock.

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 of the message 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)

Suspends the processing of a message.

public void Defer(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

Exceptions

TimeoutException

Thrown if the operation exceeded the timeout value set by OperationTimeout

OperationCanceledException

Thrown if the client entity has been closed or aborted.

MessageLockLostException

Thrown if the message represented by the lockToken has lost the message lock.

Defer(Guid, IDictionary<string, object>)

Suspends the processing of a message.

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

Parameters

lockToken Guid

The lock token bound to the locked message instance.

propertiesToModify IDictionary<string, object>

The properties of the message to modify.

DeferAsync(Guid)

Asynchronously suspends the processing of a message.

public Task DeferAsync(Guid lockToken)

Parameters

lockToken Guid

The lock token bound to the locked message instance.

Returns

Task

The asynchronous operation.

DeferAsync(Guid, IDictionary<string, object>)

Asynchronously suspends the processing of a message.

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

Parameters

lockToken Guid

The lock token bound to the locked message instance.

propertiesToModify IDictionary<string, object>

The properties of the message to modify.

Returns

Task

The asynchronous operation.

FormatDeadLetterPath(string)

Builds a format name from the specified dead letter queue path.

public static string FormatDeadLetterPath(string queuePath)

Parameters

queuePath string

The path to the dead letter queue.

Returns

string

The string resulted from building the format name for the specified dead letter queue path.

FormatTransferDeadLetterPath(string)

public static string FormatTransferDeadLetterPath(string queuePath)

Parameters

queuePath string

Returns

string

GetMessageSessions()

Gets the message sessions, enabling you to browse sessions on queues.

public IEnumerable<MessageSession> GetMessageSessions()

Returns

IEnumerable<MessageSession>

The message session.

GetMessageSessions(DateTime)

Retrieves all message sessions whose session state was updated since lastUpdatedTime.

public IEnumerable<MessageSession> GetMessageSessions(DateTime lastUpdatedTime)

Parameters

lastUpdatedTime DateTime

The time the session was last updated.

Returns

IEnumerable<MessageSession>

The message sessions.

GetMessageSessionsAsync()

Asynchronously gets the message sessions, enabling you to browse sessions on queues.

public Task<IEnumerable<MessageSession>> GetMessageSessionsAsync()

Returns

Task<IEnumerable<MessageSession>>

The asynchronous operation.

GetMessageSessionsAsync(DateTime)

Asynchronously retrieves all message sessions whose session state was updated since lastUpdatedTime.

public Task<IEnumerable<MessageSession>> GetMessageSessionsAsync(DateTime lastUpdatedTime)

Parameters

lastUpdatedTime DateTime

The time the session was last updated.

Returns

Task<IEnumerable<MessageSession>>

The asynchronous operation.

OnAbort()

Executes upon calling the Abort event.

protected override void OnAbort()

OnBeginAcceptMessageSession(string, ReceiveMode, int, TimeSpan, TimeSpan, AsyncCallback, object)

protected abstract IAsyncResult OnBeginAcceptMessageSession(string sessionId, ReceiveMode receiveMode, int prefetchCount, TimeSpan serverWaitTime, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

sessionId string
receiveMode ReceiveMode
prefetchCount int
serverWaitTime TimeSpan
timeout TimeSpan
callback AsyncCallback
state object

Returns

IAsyncResult

OnBeginClose(TimeSpan, AsyncCallback, object)

Executes when the Close operation is called.

protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state)

Parameters

timeout TimeSpan

The maximum time before the close operation 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 information about the receive operation. This object is passed to the EndClose delegate when the operation is complete.

Returns

IAsyncResult

An IAsyncResult object that references the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.AcceptSessionReceiver.

OnBeginCreateReceiver(ReceiveMode, TimeSpan, AsyncCallback, object)

Executes the begin create receiver action.

protected abstract IAsyncResult OnBeginCreateReceiver(ReceiveMode receiveMode, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

receiveMode ReceiveMode

The message ReceiveMode receive mode.

timeout TimeSpan

The maximum time before this operation 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 information about the receive operation. This object is passed to the Microsoft.ServiceBus.Messaging.QueueClient.EndCreateReceiver(System.IAsyncResult) delegate when the operation is complete.

Returns

IAsyncResult

An IAsyncResult object that references the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.CreateReceiver.

OnBeginCreateReceiver(string, ReceiveMode, TimeSpan, AsyncCallback, object)

Executes the begin create receiver action.

protected abstract IAsyncResult OnBeginCreateReceiver(string subQueueName, ReceiveMode receiveMode, TimeSpan timeout, AsyncCallback callback, object state)

Parameters

subQueueName string

Name of the sub-queue.

receiveMode ReceiveMode

The message ReceiveMode receive mode.

timeout TimeSpan

The maximum time before this operation 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 information about the receive operation. This object is passed to the Microsoft.ServiceBus.Messaging.QueueClient.EndCreateReceiver(System.IAsyncResult) delegate when the operation is complete.

Returns

IAsyncResult

An IAsyncResult object that references the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.CreateReceiver.

OnBeginCreateSender(TimeSpan, AsyncCallback, object)

Executes the begin create sender action.

protected abstract IAsyncResult OnBeginCreateSender(TimeSpan timeout, AsyncCallback callback, object state)

Parameters

timeout TimeSpan

The maximum time before this operation 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 information about the receive operation. This object is passed to the Microsoft.ServiceBus.Messaging.QueueClient.EndCreateSender(System.IAsyncResult) delegate when the operation is complete.

Returns

IAsyncResult

An IAsyncResult object that references the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.CreateSender.

OnBeginGetMessageSessions(DateTime, AsyncCallback, object)

Executes the BeginGetMessageSessions action.

protected abstract IAsyncResult OnBeginGetMessageSessions(DateTime lastUpdatedTime, AsyncCallback callback, object state)

Parameters

lastUpdatedTime DateTime

The date and time of the last update.

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 get the message sessions.

OnClose(TimeSpan)

Executes upon calling the Close action.

protected override void OnClose(TimeSpan timeout)

Parameters

timeout TimeSpan

The maximum time before the close operation times out.

OnEndAcceptMessageSession(IAsyncResult)

Executes upon calling the EndAcceptMessageSession operation.

protected abstract MessageSession OnEndAcceptMessageSession(IAsyncResult result)

Parameters

result IAsyncResult

An IAsyncResult that represents the status of the asynchronous accept message session operation.

Returns

MessageSession

The MessageSession that allows grouping of related messages for processing in a single transaction.

OnEndClose(IAsyncResult)

Executes the end close action.

protected override void OnEndClose(IAsyncResult result)

Parameters

result IAsyncResult

The result of the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.AcceptSessionReceiver operation.

OnEndCreateReceiver(IAsyncResult)

Executes the end create receiver action.

protected abstract MessageReceiver OnEndCreateReceiver(IAsyncResult result)

Parameters

result IAsyncResult

The result of the asynchronous Microsoft.ServiceBus.Messaging.QueueClient.EndCreateReceiver(System.IAsyncResult) operation.

Returns

MessageReceiver

A MessageReceiver object.

OnEndCreateSender(IAsyncResult)

Executes the end create sender action.

protected abstract MessageSender OnEndCreateSender(IAsyncResult result)

Parameters

result IAsyncResult

An IAsyncResult object that references the Microsoft.ServiceBus.Messaging.QueueClient.CreateSender.

Returns

MessageSender

A MessageSender object.

OnEndGetMessageSessions(IAsyncResult)

Executes the end get message action.

protected abstract IEnumerable<MessageSession> OnEndGetMessageSessions(IAsyncResult result)

Parameters

result IAsyncResult

The result of the session.

Returns

IEnumerable<MessageSession>

The MessageSession that allows grouping of related messages for processing in a single transaction.

OnMessage(Action<BrokeredMessage>)

Processes a message in an event-driven message pump.

public void OnMessage(Action<BrokeredMessage> callback)

Parameters

callback Action<BrokeredMessage>

The method to invoke when the operation is complete.

OnMessage(Action<BrokeredMessage>, OnMessageOptions)

Processes a message in an event-driven message pump, with the given set of OnMessageOptions options.

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

Parameters

callback Action<BrokeredMessage>

The method to invoke when the operation is complete.

onMessageOptions OnMessageOptions

Specifies the OnMessageOptions options with which to instantiate the message pump.

OnMessageAsync(Func<BrokeredMessage, Task>)

Asynchronously processes a message.

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

Parameters

callback Func<BrokeredMessage, Task>

The method to invoke when the operation is complete.

OnMessageAsync(Func<BrokeredMessage, Task>, OnMessageOptions)

Asynchronously processes a message.

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

Parameters

callback Func<BrokeredMessage, Task>

The method to invoke when the operation is complete.

onMessageOptions OnMessageOptions

Calls a message option.

Peek()

Returns without removing the first message in the queue.

public BrokeredMessage Peek()

Returns

BrokeredMessage

A brokered message. Returns all properties and the message body.

Peek(long)

Returns without removing the first message in the queue.

public BrokeredMessage Peek(long fromSequenceNumber)

Parameters

fromSequenceNumber long

The starting point from which to browse a message.

Returns

BrokeredMessage

The brokered message.

PeekAsync()

Asynchronously returns without removing the first message in the queue.

public Task<BrokeredMessage> PeekAsync()

Returns

Task<BrokeredMessage>

The asynchronous operation.

PeekAsync(long)

Asynchronously returns without removing the first message in the queue.

public Task<BrokeredMessage> PeekAsync(long fromSequenceNumber)

Parameters

fromSequenceNumber long

The sequence number from where to peek a message.

Returns

Task<BrokeredMessage>

The asynchronous operation.

PeekBatch(int)

Peeks a batch of message.

public IEnumerable<BrokeredMessage> PeekBatch(int messageCount)

Parameters

messageCount int

The number of messages.

Returns

IEnumerable<BrokeredMessage>

A batch of messages peeked. Returns all properties and the message body.

PeekBatch(long, int)

Peeks a batch of messages.

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

Parameters

fromSequenceNumber long

The starting point from which to browse a batch of messages.

messageCount int

The number of messages.

Returns

IEnumerable<BrokeredMessage>

A batch of messages peeked.

PeekBatchAsync(int)

Asynchronously peeks a batch of message.

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 peeks a batch of message.

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

Parameters

fromSequenceNumber long

The sequence number from where to peek a batch of message.

messageCount int

The number of message.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

Receive()

Receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public BrokeredMessage Receive()

Returns

BrokeredMessage

The BrokeredMessage that represents the received message. If no message is available to be received, the method returns NULL, and you can retry the operation at a later time.

Exceptions

OperationCanceledException

Thrown if the client entity has been closed or aborted.

TimeoutException

Thrown if the message receive operation times out.

UnauthorizedAccessException

Thrown if an I/O or security error occurs.

MessagingEntityNotFoundException

Thrown if the messaging entity associated with the operation does not exist or it has been deleted.

MessagingException

Thrown if the user code has performed some unexpected operations, or the Service Bus gateway is down. Check the exception message for the actual error.

Receive(long)

Receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public BrokeredMessage Receive(long sequenceNumber)

Parameters

sequenceNumber long

The sequence number of the deferred message to receive.

Returns

BrokeredMessage

The BrokeredMessage that represents the received message. If no message is available to be received, the method returns NULL, and you can retry the operation at a later time.

Exceptions

OperationCanceledException

Thrown if the client entity has been closed or aborted.

Receive(TimeSpan)

Receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public BrokeredMessage Receive(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits for receiving a message before it times out.

Returns

BrokeredMessage

The BrokeredMessage that represents the received message. If no message is available to be received, the method returns NULL, and you can retry the operation at a later time.

Exceptions

ArgumentOutOfRangeException

Thrown if the serverWaitTime is negative.

TimeoutException

Thrown if the message receive operation times out.

OperationCanceledException

Thrown if the client entity has been closed or aborted.

UnauthorizedAccessException

Thrown if an I/O or security error occurs.

MessagingEntityNotFoundException

Thrown if the messaging entity associated with the operation does not exist or it has been deleted.

MessagingException

Thrown if the user code has performed some unexpected operations, or the Service Bus gateway is down. Check the exception message for the actual error.

ReceiveAsync()

Asynchronously receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public Task<BrokeredMessage> ReceiveAsync()

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveAsync(long)

Asynchronously receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public Task<BrokeredMessage> ReceiveAsync(long sequenceNumber)

Parameters

sequenceNumber long

The sequence number of the deferred message to receive.

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveAsync(TimeSpan)

Asynchronously receives a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalReceiver.

public Task<BrokeredMessage> ReceiveAsync(TimeSpan serverWaitTime)

Parameters

serverWaitTime TimeSpan

The time span the server waits for receiving a message before it times out.

Returns

Task<BrokeredMessage>

The asynchronous operation.

ReceiveBatch(IEnumerable<long>)

Receives a message batch.

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

Parameters

sequenceNumbers IEnumerable<long>

The sequence numbers associated with the messages in the batch.

Returns

IEnumerable<BrokeredMessage>

A message batch.

ReceiveBatch(int)

Receives a message batch.

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 message batch.

ReceiveBatch(int, TimeSpan)

Receives a message batch.

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

Parameters

messageCount int

The maximum number of messages to receive in a batch.

serverWaitTime TimeSpan

The time span that the server will wait for the message batch to arrive before it times out.

Returns

IEnumerable<BrokeredMessage>

A message batch.

ReceiveBatchAsync(IEnumerable<long>)

Asynchronously receives a message batch.

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

Parameters

sequenceNumbers IEnumerable<long>

The sequence numbers associated with the messages in the batch.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

ReceiveBatchAsync(int)

Asynchronously receives a message batch.

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 message batch.

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

Parameters

messageCount int

The maximum number of messages to receive in a batch.

serverWaitTime TimeSpan

The time span that the server will wait for the message batch to arrive before it times out.

Returns

Task<IEnumerable<BrokeredMessage>>

The asynchronous operation.

RegisterSessionHandler(Type)

Registers the session handler with specific type.

public void RegisterSessionHandler(Type handlerType)

Parameters

handlerType Type

The handler type.

RegisterSessionHandler(Type, SessionHandlerOptions)

Registers the session handler with specific type and handler options.

public void RegisterSessionHandler(Type handlerType, SessionHandlerOptions options)

Parameters

handlerType Type

The handler type.

options SessionHandlerOptions

The session handler options.

RegisterSessionHandlerAsync(Type)

Asynchronously registers the session handler with specific type.

public Task RegisterSessionHandlerAsync(Type handlerType)

Parameters

handlerType Type

The handler type.

Returns

Task

The task object representing the asynchronous operation.

RegisterSessionHandlerAsync(Type, SessionHandlerOptions)

Asynchronously registers the session handler with specific type and handler options.

public Task RegisterSessionHandlerAsync(Type handlerType, SessionHandlerOptions options)

Parameters

handlerType Type

The handler type.

options SessionHandlerOptions

The session handler options.

Returns

Task

The task object representing the asynchronous operation.

RegisterSessionHandlerFactory(IMessageSessionAsyncHandlerFactory, SessionHandlerOptions)

Registers a message session handler factory with specified options.

public void RegisterSessionHandlerFactory(IMessageSessionAsyncHandlerFactory factory, SessionHandlerOptions options)

Parameters

factory IMessageSessionAsyncHandlerFactory

The handler factory to be registered.

options SessionHandlerOptions

The handler options.

RegisterSessionHandlerFactory(IMessageSessionHandlerFactory, SessionHandlerOptions)

Registers a message session handler factory with specified options.

public void RegisterSessionHandlerFactory(IMessageSessionHandlerFactory factory, SessionHandlerOptions options)

Parameters

factory IMessageSessionHandlerFactory

The handler factory to be registered.

options SessionHandlerOptions

The handler options.

RegisterSessionHandlerFactoryAsync(IMessageSessionAsyncHandlerFactory, SessionHandlerOptions)

Asynchronously registers a message session handler factory.

public Task RegisterSessionHandlerFactoryAsync(IMessageSessionAsyncHandlerFactory factory, SessionHandlerOptions options)

Parameters

factory IMessageSessionAsyncHandlerFactory

The handler factory to be registered.

options SessionHandlerOptions

The handler options.

Returns

Task

The task object representing the asynchronous operation.

RegisterSessionHandlerFactoryAsync(IMessageSessionHandlerFactory, SessionHandlerOptions)

Asynchronously registers a message session handler factory.

public Task RegisterSessionHandlerFactoryAsync(IMessageSessionHandlerFactory factory, SessionHandlerOptions options)

Parameters

factory IMessageSessionHandlerFactory

The handler factory to be registered.

options SessionHandlerOptions

The handler options.

Returns

Task

The task object representing the asynchronous operation.

RenewMessageLock(Guid)

public DateTime RenewMessageLock(Guid lockToken)

Parameters

lockToken Guid

Returns

DateTime

RenewMessageLockAsync(Guid)

public Task<DateTime> RenewMessageLockAsync(Guid lockToken)

Parameters

lockToken Guid

Returns

Task<DateTime>

Send(BrokeredMessage)

Sends a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalSender.

public void Send(BrokeredMessage message)

Parameters

message BrokeredMessage

The message to send.

Exceptions

TimeoutException

Thrown when operation times out. Timeout period is initialized through the MessagingFactorySettings may need to increase the value of OperationTimeout to avoid this exception if timeout value is relatively low.

ArgumentException

Thrown when the BrokeredMessage is null.

InvalidOperationException

Thrown if the message has already been sent by a QueueClient or Microsoft.ConnectedServices.Sdk.Client.MessageSender once already.

InvalidOperationException

Thrown if the topic/subscription pointed to does not support the send operation. That is, Deadletter queue does not support send operations.

OperationCanceledException

Thrown if the client entity has been closed or aborted.

UnauthorizedAccessException

Thrown if there is an I/O or security error.

SerializationException

Thrown when an error occurs during serialization or deserialization.

MessagingEntityNotFoundException

Thrown if the queue does not exist.

MessagingException

Thrown if there is a messaging error.

SendAsync(BrokeredMessage)

Asynchronously sends a message using the Microsoft.ServiceBus.Messaging.QueueClient.InternalSender.

public Task SendAsync(BrokeredMessage message)

Parameters

message BrokeredMessage

The message to send.

Returns

Task

The asynchronous operation.

SendBatch(IEnumerable<BrokeredMessage>)

Sends a set of brokered messages (for batch processing).

public void SendBatch(IEnumerable<BrokeredMessage> messages)

Parameters

messages IEnumerable<BrokeredMessage>

The collection of brokered messages to send.

SendBatchAsync(IEnumerable<BrokeredMessage>)

Asynchronously sends a set of brokered messages (for batch processing).

public Task SendBatchAsync(IEnumerable<BrokeredMessage> messages)

Parameters

messages IEnumerable<BrokeredMessage>

The collection of brokered messages to send.

Returns

Task

The asynchronous operation.