IQueueClient Interface

Definition

QueueClient can be used for all basic interactions with a Service Bus Queue.

public interface IQueueClient : Microsoft.Azure.ServiceBus.Core.IReceiverClient, Microsoft.Azure.ServiceBus.Core.ISenderClient
type IQueueClient = interface
    interface IReceiverClient
    interface IClientEntity
    interface ISenderClient
Public Interface IQueueClient
Implements IReceiverClient, ISenderClient
Derived
Implements

Examples

Create a new QueueClient

IQueueClient queueClient = new QueueClient(
    namespaceConnectionString,
    queueName,
    ReceiveMode.PeekLock,
    RetryExponential);

Send a message to the queue:

byte[] data = GetData();
await queueClient.SendAsync(data);

Register a message handler which will be invoked every time a message is received.

queueClient.RegisterMessageHandler(
       async (message, token) =>
       {
           // Process the message
           Console.WriteLine($"Received message: SequenceNumber:{message.SystemProperties.SequenceNumber} Body:{Encoding.UTF8.GetString(message.Body)}");

           // Complete the message so that it is not received again.
           // This can be done only if the queueClient is opened in ReceiveMode.PeekLock mode.
           await queueClient.CompleteAsync(message.SystemProperties.LockToken);
       },
       async (exceptionEvent) =>
       {
           // Process the exception
           Console.WriteLine("Exception = " + exceptionEvent.Exception);
           return Task.CompletedTask;
       });

Remarks

Use IMessageSender or IMessageReceiver for advanced set of functionality.

Properties

Path

Gets the path of the IReceiverClient. This is either the name of the queue, or the full path of the subscription.

(Inherited from IReceiverClient)
PrefetchCount

Prefetch speeds up the message flow by aiming to have a message readily available for local retrieval when and before the application asks for one using Receive. Setting a non-zero value prefetches PrefetchCount number of messages. Setting the value to zero turns prefetch off. Defaults to 0.

(Inherited from IReceiverClient)
QueueName

Gets the name of the queue.

ReceiveMode

Gets the ReceiveMode of the current receiver.

(Inherited from IReceiverClient)

Methods

AbandonAsync(String, IDictionary<String,Object>)

Abandons a Message using a lock token. This will make the message available again for processing.

(Inherited from IReceiverClient)
CancelScheduledMessageAsync(Int64)

Cancels a message that was scheduled.

(Inherited from ISenderClient)
CompleteAsync(String)

Completes a Message using its lock token. This will delete the message from the queue.

(Inherited from IReceiverClient)
DeadLetterAsync(String, IDictionary<String,Object>)

Moves a message to the deadletter sub-queue.

(Inherited from IReceiverClient)
DeadLetterAsync(String, String, String)

Moves a message to the deadletter sub-queue.

(Inherited from IReceiverClient)
RegisterMessageHandler(Func<Message,CancellationToken,Task>, Func<ExceptionReceivedEventArgs,Task>)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. This handler(Func<T1, T2, TResult>) is awaited on every time a new message is received by the receiver.

(Inherited from IReceiverClient)
RegisterMessageHandler(Func<Message,CancellationToken,Task>, MessageHandlerOptions)

Receive messages continuously from the entity. Registers a message handler and begins a new thread to receive messages. This handler(Func<T1, T2, TResult>) is awaited on every time a new message is received by the receiver.

(Inherited from IReceiverClient)
RegisterSessionHandler(Func<IMessageSession,Message,CancellationToken,Task>, Func<ExceptionReceivedEventArgs,Task>)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. This handler(Func<T1, T2, T3, TResult>) is awaited on every time a new message is received by the queue client.

RegisterSessionHandler(Func<IMessageSession,Message,CancellationToken,Task>, SessionHandlerOptions)

Receive session messages continuously from the queue. Registers a message handler and begins a new thread to receive session-messages. This handler(Func<T1, T2, T3, TResult>) is awaited on every time a new message is received by the queue client.

ScheduleMessageAsync(Message, DateTimeOffset)

Schedules a message to appear on Service Bus.

(Inherited from ISenderClient)
SendAsync(IList<Message>)

Sends a list of messages to Service Bus.

(Inherited from ISenderClient)
SendAsync(Message)

Sends a message to Service Bus.

(Inherited from ISenderClient)

Applies to

See also