Interface CheckpointConsumerBuilder<T>

Type Parameters:
T - the type of message values the consumer will receive

public interface CheckpointConsumerBuilder<T>
Builder for configuring and creating a CheckpointConsumer.

Since this is an unmanaged consumer (no subscription), the terminal method is create() rather than subscribe().

  • Method Details

    • create

      Create the checkpoint consumer, blocking until it is ready.
      Returns:
      the created CheckpointConsumer
      Throws:
      PulsarClientException - if the creation fails or a connection error occurs
    • createAsync

      Create the checkpoint consumer asynchronously.
      Returns:
      a CompletableFuture that completes with the created CheckpointConsumer
    • topic

      CheckpointConsumerBuilder<T> topic(String topicName)
      The topic to consume from.
      Parameters:
      topicName - the topic name
      Returns:
      this builder instance for chaining
    • startPosition

      CheckpointConsumerBuilder<T> startPosition(Checkpoint checkpoint)
      Set the initial position for this consumer.

      Use Checkpoint.earliest(), Checkpoint.latest(), or Checkpoint.fromByteArray(byte[]) to create the appropriate starting position.

      Defaults to Checkpoint.latest() if not specified.

      Parameters:
      checkpoint - the checkpoint representing the desired start position
      Returns:
      this builder instance for chaining
    • consumerName

      CheckpointConsumerBuilder<T> consumerName(String name)
      A custom name for this consumer instance.
      Parameters:
      name - the consumer name
      Returns:
      this builder instance for chaining
    • consumerGroup

      CheckpointConsumerBuilder<T> consumerGroup(String group)
      Join a named consumer group on this scalable topic. All consumers that pass the same group share the topic's segments via the broker's subscription coordinator: each segment is assigned to exactly one consumer in the group at a time, and segments rebalance automatically as consumers join or leave.

      When unset (the default), the consumer is unmanaged: it independently reads every segment from the configured start position, unaffected by any other consumer. This matches the original reader-style behavior of CheckpointConsumer.

      Unlike StreamConsumerBuilder's subscription, joining a group does not cause the broker to persist a cursor: each consumer still resumes from the startPosition (or a checkpoint deserialized from a previous run) it provides at create time. The group only affects how segments are distributed across the live consumer set; once every member of the group goes away, no broker-side state remains for it.

      Parameters:
      group - the consumer group name
      Returns:
      this builder instance for chaining
    • encryptionPolicy

      Configure end-to-end message encryption for decryption.
      Parameters:
      policy - the encryption policy to use
      Returns:
      this builder instance for chaining
      See Also:
    • property

      CheckpointConsumerBuilder<T> property(String key, String value)
      Add a single property to the consumer metadata.
      Parameters:
      key - the property key
      value - the property value
      Returns:
      this builder instance for chaining
    • properties

      CheckpointConsumerBuilder<T> properties(Map<String,String> properties)
      Add multiple properties to the consumer metadata.
      Parameters:
      properties - the properties to add
      Returns:
      this builder instance for chaining