Class MessageBatch

java.lang.Object
io.fluxzero.common.api.tracking.MessageBatch

public class MessageBatch extends Object
Represents a batch of messages retrieved from the message store for a specific segment range.

A message batch contains a list of SerializedMessage instances and metadata such as the last known index and the Position of the consumer when this batch was read.

The segment and position fields are especially relevant when the tracker operates with ignoreSegment=true, meaning segment filtering is handled on the client side. In such cases, the Runtime returns all potentially matching messages, and the client uses the Position and segment range to determine which messages are truly relevant for processing.

  • Constructor Details

    • MessageBatch

      public MessageBatch(int[] segment, List<SerializedMessage> messages, Long lastIndex, Position position, boolean caughtUp)
      Creates an ordinary data batch; the optional filter-control flag is handled by the JSON factory.
  • Method Details

    • requireConsumerFilter

      public static MessageBatch requireConsumerFilter()
      Requests a full consumer filter snapshot before this read can be admitted. No segment has been claimed and no position has advanced. Tracking clients absorb this control response and retry with the current full snapshot.
    • isConsumerFilterRequired

      public boolean isConsumerFilterRequired()
      Whether this response requests a full snapshot instead of delivering a message batch.
    • isEmpty

      public boolean isEmpty()
      Indicates whether this message batch is empty.
    • getSize

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

      public long getBytes()
      Calculates the complete serialized size of all messages within the batch.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toMetric

      public MessageBatch.Metric toMetric()
      Converts this batch into a compact, serializable representation for monitoring purposes.
      Returns:
      a MessageBatch.Metric representing key metadata about this batch