Package com.azure.messaging.eventhubs
Class EventDataBatch
java.lang.Object
com.azure.messaging.eventhubs.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 TypeMethodDescriptionintgetCount()Gets the number ofeventsin the batch.intGets the maximum size, in bytes, of theEventDataBatch.intGets the size of theEventDataBatchin bytes.booleanTries to add aneventto the batch.
-
Method Details
-
getCount
public int getCount()Gets the number ofeventsin the batch.- Returns:
- The number of
eventsin the batch.
-
getMaxSizeInBytes
public int getMaxSizeInBytes()Gets the maximum size, in bytes, of theEventDataBatch.- Returns:
- The maximum size, in bytes, of the
EventDataBatch.
-
getSizeInBytes
public int getSizeInBytes()Gets the size of theEventDataBatchin bytes.- Returns:
- the size of the
EventDataBatchin bytes.
-
tryAdd
Tries to add aneventto the batch.This method is not thread-safe; make sure to synchronize the method access when using multiple threads to add events.
- Parameters:
eventData- TheEventDatato add to the batch.- Returns:
trueif the event could be added to the batch;falseif the event was too large to fit in the batch, to accommodate the event, the application should obtain a newEventDataBatchobject and add event to it.- Throws:
IllegalArgumentException- ifeventDataisnull.AmqpException- ifeventDatais larger than the maximum size of theEventDataBatch.
-