Interface CheckpointConsumerBuilder<T>
- Type Parameters:
T- the type of message values the consumer will receive
CheckpointConsumer.
Since this is an unmanaged consumer (no subscription), the terminal method is
create() rather than subscribe().
-
Method Summary
Modifier and TypeMethodDescriptionconsumerGroup(String group) Join a named consumer group on this scalable topic.consumerName(String name) A custom name for this consumer instance.create()Create the checkpoint consumer, blocking until it is ready.Create the checkpoint consumer asynchronously.Configure end-to-end message encryption for decryption.properties(Map<String, String> properties) Add multiple properties to the consumer metadata.Add a single property to the consumer metadata.startPosition(Checkpoint checkpoint) Set the initial position for this consumer.The topic to consume from.
-
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
CompletableFuture<CheckpointConsumer<T>> createAsync()Create the checkpoint consumer asynchronously.- Returns:
- a
CompletableFuturethat completes with the createdCheckpointConsumer
-
topic
The topic to consume from.- Parameters:
topicName- the topic name- Returns:
- this builder instance for chaining
-
startPosition
Set the initial position for this consumer.Use
Checkpoint.earliest(),Checkpoint.latest(), orCheckpoint.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
A custom name for this consumer instance.- Parameters:
name- the consumer name- Returns:
- this builder instance for chaining
-
consumerGroup
Join a named consumer group on this scalable topic. All consumers that pass the samegroupshare 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 ofCheckpointConsumer.Unlike
StreamConsumerBuilder's subscription, joining a group does not cause the broker to persist a cursor: each consumer still resumes from thestartPosition(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
Add a single property to the consumer metadata.- Parameters:
key- the property keyvalue- the property value- Returns:
- this builder instance for chaining
-
properties
Add multiple properties to the consumer metadata.- Parameters:
properties- the properties to add- Returns:
- this builder instance for chaining
-