ServiceBusMessageBatch Class
- java.
lang. Object - com.
azure. messaging. servicebus. ServiceBusMessageBatch
- com.
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:
getMaxSizeInBytes
public int getMaxSizeInBytes()
Gets the maximum size, in bytes, of the ServiceBusMessageBatch.
Returns:
getSizeInBytes
public int getSizeInBytes()
Gets the size of the ServiceBusMessageBatch in bytes.
Returns:
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:
Returns:
true
if the message could be added to the batch; false
if the event was too large to fit
in the batch.