Compartilhar via


ServiceBusSender.SendMessagesAsync Method

Definition

Overloads

SendMessagesAsync(ServiceBusMessageBatch, CancellationToken)

Sends a ServiceBusMessageBatch containing a set of ServiceBusMessage to the associated Service Bus entity.

SendMessagesAsync(IEnumerable<ServiceBusMessage>, CancellationToken)

Sends a set of messages to the associated Service Bus entity using a batched approach. If the size of the messages exceed the maximum size of a single batch, an exception will be triggered and the send will fail. In order to ensure that the messages being sent will fit in a batch, use SendMessagesAsync(ServiceBusMessageBatch, CancellationToken) instead.

SendMessagesAsync(ServiceBusMessageBatch, CancellationToken)

Source:
ServiceBusSender.cs
Source:
ServiceBusSender.cs

Sends a ServiceBusMessageBatch containing a set of ServiceBusMessage to the associated Service Bus entity.

public virtual System.Threading.Tasks.Task SendMessagesAsync (Azure.Messaging.ServiceBus.ServiceBusMessageBatch messageBatch, System.Threading.CancellationToken cancellationToken = default);
abstract member SendMessagesAsync : Azure.Messaging.ServiceBus.ServiceBusMessageBatch * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.SendMessagesAsync : Azure.Messaging.ServiceBus.ServiceBusMessageBatch * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function SendMessagesAsync (messageBatch As ServiceBusMessageBatch, Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

messageBatch
ServiceBusMessageBatch

The batch of messages to send. A batch may be created using CreateMessageBatchAsync(CancellationToken).

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

A task to be resolved on when the operation has completed.

Remarks

When sending, the result is atomic; either all messages that belong to the batch were successful or all have failed. Partial success is not possible.

Applies to

SendMessagesAsync(IEnumerable<ServiceBusMessage>, CancellationToken)

Source:
ServiceBusSender.cs
Source:
ServiceBusSender.cs

Sends a set of messages to the associated Service Bus entity using a batched approach. If the size of the messages exceed the maximum size of a single batch, an exception will be triggered and the send will fail. In order to ensure that the messages being sent will fit in a batch, use SendMessagesAsync(ServiceBusMessageBatch, CancellationToken) instead.

public virtual System.Threading.Tasks.Task SendMessagesAsync (System.Collections.Generic.IEnumerable<Azure.Messaging.ServiceBus.ServiceBusMessage> messages, System.Threading.CancellationToken cancellationToken = default);
abstract member SendMessagesAsync : seq<Azure.Messaging.ServiceBus.ServiceBusMessage> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.SendMessagesAsync : seq<Azure.Messaging.ServiceBus.ServiceBusMessage> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function SendMessagesAsync (messages As IEnumerable(Of ServiceBusMessage), Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

messages
IEnumerable<ServiceBusMessage>

The set of messages to send.

cancellationToken
CancellationToken

An optional CancellationToken instance to signal the request to cancel the operation.

Returns

A task to be resolved on when the operation has completed.

Exceptions

The set of messages exceeds the maximum size allowed in a single batch, as determined by the Service Bus service. The Reason will be set to MessageSizeExceeded in this case. For more information on service limits, see https://learn.microsoft.com/azure/service-bus-messaging/service-bus-quotas#messaging-quotas.

Occurs when one of the messages has a member in its ApplicationProperties collection that is an unsupported type for serialization. See the ApplicationProperties remarks for details.

Remarks

When sending, the result is atomic; either all messages that belong to the set were successful or all have failed. Partial success is not possible.

Applies to