共用方式為


ServiceBusMessageBatch Class

  • java.lang.Object
    • com.azure.messaging.servicebus.ServiceBusMessageBatch

public final class ServiceBusMessageBatch

A class for aggregating ServiceBusMessage into a single, size-limited, batch. It is treated as a single AMQP message when sent to the Azure Service Bus service.

Method Summary

Modifier and Type Method and Description
int getCount()

Gets the number of ServiceBusMessage in the batch.

int getMaxSizeInBytes()

Gets the maximum size, in bytes, of the ServiceBusMessageBatch.

int getSizeInBytes()

Gets the size of the ServiceBusMessageBatch in bytes.

boolean tryAddMessage(ServiceBusMessage serviceBusMessage)

Tries to add a ServiceBusMessage to the batch.

Methods inherited from java.lang.Object

Method Details

getCount

public int getCount()

Gets the number of ServiceBusMessage in the batch.

Returns:

The number of ServiceBusMessage in the batch.

getMaxSizeInBytes

public int getMaxSizeInBytes()

Gets the maximum size, in bytes, of the ServiceBusMessageBatch.

Returns:

The maximum size, in bytes, of the ServiceBusMessageBatch.

getSizeInBytes

public int getSizeInBytes()

Gets the size of the ServiceBusMessageBatch in bytes.

Returns:

The size of the ServiceBusMessageBatch in bytes.

tryAddMessage

public boolean tryAddMessage(ServiceBusMessage serviceBusMessage)

Tries to add a ServiceBusMessage to the batch.

This method is not thread-safe; make sure to synchronize the method access when using multiple threads to add messages.

Parameters:

serviceBusMessage - The ServiceBusMessage to add to the batch.

Returns:

true if the message could be added to the batch; false if the event was too large to fit in the batch.

Applies to