Class EventBatch

java.lang.Object
io.fluxcapacitor.common.api.eventsourcing.EventBatch

public class EventBatch extends Object
Represents a batch of serialized events for a specific aggregate.

An EventBatch groups one or more SerializedMessage instances that belong to the same aggregate. Batches are typically appended atomically to the event store and processed in order.

This class is used within AppendEvents to persist updates to aggregates in event-sourced systems.

Usage

- All events in a batch must refer to the same aggregate ID. - A batch may be marked as storeOnly to indicate that the events should not be published to event handlers.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A compact metric representation of an EventBatch, used in AppendEvents.Metric.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Calculates the total number of bytes in the data across all messages within the batch.
    int
    Returns the number of events in this batch.
    boolean
    Returns true if the batch contains no events.
    Transforms this batch into a lightweight metric representation for logging and monitoring.
    Returns a human-readable representation of this batch, including its aggregate ID and event count.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EventBatch

      public EventBatch()
  • Method Details

    • isEmpty

      public boolean isEmpty()
      Returns true if the batch contains no events.
    • getSize

      public int getSize()
      Returns the number of events in this batch.
    • getBytes

      public long getBytes()
      Calculates the total number of bytes in the data across all messages within the batch.
    • toString

      public String toString()
      Returns a human-readable representation of this batch, including its aggregate ID and event count.
      Overrides:
      toString in class Object
    • toMetric

      public EventBatch.Metric toMetric()
      Transforms this batch into a lightweight metric representation for logging and monitoring.