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.-
Method Summary
Modifier and TypeMethodDescriptionint
getCount()
Gets the number ofevents
in the batch.int
Gets the maximum size, in bytes, of theEventDataBatch
.int
Gets the size of theEventDataBatch
in bytes.boolean
Tries to add anevent
to the batch.
-
Method Details
-
getCount
public int getCount()Gets the number ofevents
in the batch.- Returns:
- The number of
events
in 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 theEventDataBatch
in bytes.- Returns:
- the size of the
EventDataBatch
in bytes.
-
tryAdd
Tries to add anevent
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
- TheEventData
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.- Throws:
IllegalArgumentException
- ifeventData
isnull
.AmqpException
- ifeventData
is larger than the maximum size of theEventDataBatch
.
-