ServiceBusMessageBatch Class

Definition

A set of ServiceBusMessage with size constraints known up-front, intended to be sent to the Queue/Topic as a single batch. A ServiceBusMessageBatch can be created using CreateMessageBatchAsync(CancellationToken). Messages can be added to the batch using the TryAddMessage(ServiceBusMessage) method on the batch.

public sealed class ServiceBusMessageBatch : IDisposable
type ServiceBusMessageBatch = class
    interface IDisposable
Public NotInheritable Class ServiceBusMessageBatch
Implements IDisposable
Inheritance
ServiceBusMessageBatch
Implements

Properties

Count

The count of messages contained in the batch.

MaxSizeInBytes

The maximum size allowed for the batch, in bytes. This includes the messages in the batch as well as any overhead for the batch itself when sent to the Queue/Topic.

SizeInBytes

The size of the batch, in bytes, as it will be sent to the Queue/Topic.

Methods

Dispose()

Performs the task needed to clean up resources used by the ServiceBusMessageBatch.

TryAddMessage(ServiceBusMessage)

Attempts to add a message to the batch, ensuring that the size of the batch does not exceed its maximum. If the message is modified after being added to the batch, the batch will fail to send if the modification caused the batch to exceed the maximum allowable size. Therefore it is best to not modify a message after adding it to the batch.

Applies to