Class EventDataBatch

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

public final class EventDataBatch extends Object
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.
See Also:
  • Method Details

    • getCount

      public int getCount()
      Gets the number of events in the batch.
      Returns:
      The number of events 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 event 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.
      Throws:
      IllegalArgumentException - if eventData is null.
      AmqpException - if eventData is larger than the maximum size of the EventDataBatch.