Bagikan melalui


MessageSender Class

Definition

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
Inheritance
MessageSender
Implements

Examples

Create a new MessageSender to send to a Queue

IMessageSender messageSender = new MessageSender(
    namespaceConnectionString,
    queueName)

Send message

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

Remarks

This uses AMQP protocol to communicate with service.

Constructors

MessageSender(ServiceBusConnection, String, RetryPolicy)

Creates a new AMQP MessageSender on a given ServiceBusConnection

MessageSender(ServiceBusConnection, String, String, RetryPolicy)

Creates a ViaMessageSender. This can be used to send messages to a destination entity via another another entity.

MessageSender(ServiceBusConnectionStringBuilder, RetryPolicy)

Creates a new AMQP MessageSender.

MessageSender(String, String, ITokenProvider, TransportType, RetryPolicy)

Creates a new MessageSender

MessageSender(String, String, RetryPolicy)

Creates a new AMQP MessageSender.

Properties

ClientId

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

(Inherited from ClientEntity)
IsClosedOrClosing

Returns true if the client is closed or closing.

(Inherited from ClientEntity)
OperationTimeout

Duration after which individual operations will timeout.

OwnsConnection

Returns true if connection is owned and false if connection is shared.

(Inherited from ClientEntity)
Path

Gets the entity path of the MessageSender. In the case of a via-sender, this returns the path of the via entity.

RegisteredPlugins

Gets a list of currently registered plugins for this sender.

RetryPolicy

Gets the RetryPolicy defined on the client.

(Inherited from ClientEntity)
ServiceBusConnection

Connection object to the service bus namespace.

TransferDestinationPath

In the case of a via-sender, gets the final destination path of the messages; null otherwise.

ViaEntityPath

In the case of a via-sender, the message is sent to TransferDestinationPath via ViaEntityPath; null otherwise.

Methods

CancelScheduledMessageAsync(Int64)

Cancels a message that was scheduled.

CloseAsync()

Closes the Client. Closes the connections opened by it.

(Inherited from ClientEntity)
OnClosingAsync()

Closes the connection.

RegisterPlugin(ServiceBusPlugin)

Registers a ServiceBusPlugin to be used with this sender.

ScheduleMessageAsync(Message, DateTimeOffset)

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

SendAsync(IList<Message>)

Sends a list of messages to the entity as described by Path. When called on partitioned entities, messages meant for different partitions cannot be batched together.

SendAsync(Message)

Sends a message to the entity as described by Path.

ThrowIfClosed()

Throw an OperationCanceledException if the object is Closing.

(Inherited from ClientEntity)
UnregisterPlugin(String)

Unregisters a ServiceBusPlugin.

Applies to