MessageSender MessageSender MessageSender Class


The MessageSender can be used to send messages to Queues or Topics.

public class MessageSender : Microsoft.Azure.ServiceBus.ClientEntity, Microsoft.Azure.ServiceBus.Core.IMessageSender
type MessageSender = class
    inherit ClientEntity
    interface IMessageSender
    interface ISenderClient
    interface IClientEntity
Public Class MessageSender
Inherits ClientEntity
Implements IMessageSender


Create a new MessageSender to send to a Queue

 IMessageSender messageSender = new MessageSender(

Send message

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


This uses AMQP protocol to communicate with service.


MessageSender(ServiceBusConnectionStringBuilder, RetryPolicy) MessageSender(ServiceBusConnectionStringBuilder, RetryPolicy) MessageSender(ServiceBusConnectionStringBuilder, RetryPolicy)

Creates a new AMQP MessageSender.

MessageSender(String, String, RetryPolicy) MessageSender(String, String, RetryPolicy) MessageSender(String, String, RetryPolicy)

Creates a new AMQP MessageSender.


ClientId ClientId ClientId

Gets the ID to identify this client. This can be used to correlate logs and exceptions.

(Inherited from ClientEntity)
IsClosedOrClosing IsClosedOrClosing IsClosedOrClosing

Returns true if the client is closed or closing.

(Inherited from ClientEntity)
OperationTimeout OperationTimeout OperationTimeout

Duration after which individual operations will timeout.

Path Path Path

Gets the entity path of the MessageSender.

RegisteredPlugins RegisteredPlugins RegisteredPlugins

Gets a list of currently registered plugins for this sender.

RetryPolicy RetryPolicy RetryPolicy

Gets the RetryPolicy defined on the client.

(Inherited from ClientEntity)


CancelScheduledMessageAsync(Int64) CancelScheduledMessageAsync(Int64) CancelScheduledMessageAsync(Int64)

Cancels a message that was scheduled.

CloseAsync() CloseAsync() CloseAsync()

Closes the Client. Closes the connections opened by it.

(Inherited from ClientEntity)
OnClosingAsync() OnClosingAsync() OnClosingAsync()

Closes the connection.

RegisterPlugin(ServiceBusPlugin) RegisterPlugin(ServiceBusPlugin) RegisterPlugin(ServiceBusPlugin)

Registers a ServiceBusPlugin to be used with this sender.

ScheduleMessageAsync(Message, DateTimeOffset) ScheduleMessageAsync(Message, DateTimeOffset) ScheduleMessageAsync(Message, DateTimeOffset)

Schedules a message to appear on Service Bus at a later time.

SendAsync(IList<Message>) SendAsync(IList<Message>) SendAsync(IList<Message>)

Sends a list of messages to the entity as described by Path.

SendAsync(Message) SendAsync(Message) SendAsync(Message)

Sends a message to the entity as described by Path.

ThrowIfClosed() ThrowIfClosed() ThrowIfClosed()

Throw an OperationCanceledException if the object is Closing.

(Inherited from ClientEntity)
UnregisterPlugin(String) UnregisterPlugin(String) UnregisterPlugin(String)

Unregisters a ServiceBusPlugin.

Extension Methods

IsDefined(Object) IsDefined(Object) IsDefined(Object)

Determines if a certain property is defined or not.

IsNull(Object) IsNull(Object) IsNull(Object)

Determines if a certain property is null or not.

IsPrimitive(Object) IsPrimitive(Object) IsPrimitive(Object)

Determines if a certain property is of premitive JSON type.

Applies to