EventDataBatch Class

  • java.lang.Object
    • com.azure.messaging.eventhubs.EventDataBatch

public final class EventDataBatch

A class for aggregating EventData into a single, size-limited, batch. It is treated as a single message when sent to the Azure Event Hubs service. EventDataBatch is recommended in scenarios requiring high throughput for publishing events.

Method Summary

Modifier and Type Method and Description
int getCount()

Gets the number of EventData in the batch.

int getMaxSizeInBytes()

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

int getSizeInBytes()

Gets the size of the EventDataBatch in bytes.

boolean tryAdd(EventData eventData)

Tries to add an EventData to the batch.

Methods inherited from java.lang.Object

Method Details

getCount

public int getCount()

Gets the number of EventData in the batch.

Returns:

The number of EventData in the batch.

getMaxSizeInBytes

public int getMaxSizeInBytes()

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

Returns:

The maximum size, in bytes, of the EventDataBatch.

getSizeInBytes

public int getSizeInBytes()

Gets the size of the EventDataBatch in bytes.

Returns:

the size of the EventDataBatch in bytes.

tryAdd

public boolean tryAdd(EventData eventData)

Tries to add an EventData to the batch.

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

Parameters:

eventData - The EventData to add to the batch.

Returns:

true if the event could be added to the batch; false if the event was too large to fit in the batch, to accommodate the event, the application should obtain a new EventDataBatch object and add event to it.

Applies to