Class BatchingPolicy.Builder

java.lang.Object
org.apache.pulsar.client.api.v5.config.BatchingPolicy.Builder
Enclosing class:
BatchingPolicy

public static final class BatchingPolicy.Builder extends Object
Builder for BatchingPolicy.
  • Method Details

    • enabled

      public BatchingPolicy.Builder enabled(boolean enabled)
      Whether batching is enabled. Default is true.
      Parameters:
      enabled - whether to batch outgoing messages
      Returns:
      this builder
    • maxPublishDelay

      public BatchingPolicy.Builder maxPublishDelay(Duration maxPublishDelay)
      Maximum time the producer waits before flushing a partial batch.
      Parameters:
      maxPublishDelay - the upper bound on per-message latency added by batching
      Returns:
      this builder
    • maxMessages

      public BatchingPolicy.Builder maxMessages(int maxMessages)
      Maximum number of messages per batch.
      Parameters:
      maxMessages - the message-count flush threshold
      Returns:
      this builder
    • maxSize

      public BatchingPolicy.Builder maxSize(MemorySize maxSize)
      Maximum payload size per batch.
      Parameters:
      maxSize - the size flush threshold
      Returns:
      this builder
    • build

      public BatchingPolicy build()
      Returns:
      a new BatchingPolicy instance