Package org.apache.pulsar.client.api.v5
Interface QueueConsumerBuilder<T>
- Type Parameters:
T- the type of message values the consumer will receive
public interface QueueConsumerBuilder<T>
Builder for configuring and creating a
QueueConsumer.-
Method Summary
Modifier and TypeMethodDescriptionacknowledgmentGroupTime(Duration delay) How frequently acknowledgments are flushed to the broker.consumerName(String consumerName) A custom name for this consumer instance.deadLetterPolicy(DeadLetterPolicy policy) Configure the dead letter queue policy.Configure end-to-end message encryption for decryption.maxAcknowledgmentGroupSize(int size) Maximum number of acknowledgments to group before flushing.Subscribe to every scalable topic under a namespace.Subscribe to scalable topics under a namespace whose properties match every key/value pair inpropertyFilters(AND semantics).Backoff strategy for redelivery after negative acknowledgment.priorityLevel(int priorityLevel) Priority level for this consumer (lower values mean higher priority for message dispatch).Optional safety net for slow / stalled consumers: seeProcessingTimeoutPolicyfor the full semantics.properties(Map<String, String> properties) Add multiple properties to the consumer metadata.Add a single property to the consumer metadata.receiverQueueSize(int receiverQueueSize) Size of the receiver queue.replicateSubscriptionState(boolean replicate) Whether the subscription cursor should be replicated to other clusters in a geo-replication setup.Subscribe and create the queue consumer, blocking until ready.Subscribe and create the queue consumer asynchronously.Initial position when the subscription is first created.subscriptionName(String subscriptionName) The subscription name.subscriptionProperties(Map<String, String> properties) Properties to attach to the subscription.Subscribe to a single scalable topic by name.
-
Method Details
-
subscribe
Subscribe and create the queue consumer, blocking until ready.- Returns:
- the created
QueueConsumer - Throws:
PulsarClientException- if the subscription fails or a connection error occurs
-
subscribeAsync
CompletableFuture<QueueConsumer<T>> subscribeAsync()Subscribe and create the queue consumer asynchronously.- Returns:
- a
CompletableFuturethat completes with the createdQueueConsumer
-
topic
Subscribe to a single scalable topic by name.- Parameters:
topicName- the fully-qualified topic name (e.g.topic://tenant/ns/name)- Returns:
- this builder instance for chaining
-
namespace
Subscribe to every scalable topic under a namespace. The matching set follows live: when topics are created in or deleted from the namespace, the consumer attaches / detaches automatically.- Parameters:
namespace- the namespace intenant/namespaceform- Returns:
- this builder instance for chaining
-
namespace
Subscribe to scalable topics under a namespace whose properties match every key/value pair inpropertyFilters(AND semantics). An empty map is equivalent tonamespace(String)— every topic in the namespace. The matching set follows live as topic properties change.- Parameters:
namespace- the namespace intenant/namespaceformpropertyFilters- property name/value pairs that all must match- Returns:
- this builder instance for chaining
-
subscriptionName
The subscription name. Required for managed consumers.- Parameters:
subscriptionName- the subscription name- Returns:
- this builder instance for chaining
-
subscriptionProperties
Properties to attach to the subscription.- Parameters:
properties- the subscription properties- Returns:
- this builder instance for chaining
-
subscriptionInitialPosition
Initial position when the subscription is first created.- Parameters:
position- the initial position- Returns:
- this builder instance for chaining
-
consumerName
A custom name for this consumer instance.- Parameters:
consumerName- the consumer name- Returns:
- this builder instance for chaining
-
receiverQueueSize
Size of the receiver queue. Controls prefetch depth.- Parameters:
receiverQueueSize- the receiver queue size- Returns:
- this builder instance for chaining
-
priorityLevel
Priority level for this consumer (lower values mean higher priority for message dispatch).- Parameters:
priorityLevel- the priority level- Returns:
- this builder instance for chaining
-
processingTimeout
Optional safety net for slow / stalled consumers: seeProcessingTimeoutPolicyfor the full semantics. The policy bundles the timeout itself with an optional redelivery backoff. Disabled by default.- Parameters:
policy- timeout + redelivery-backoff configuration- Returns:
- this builder instance for chaining
- See Also:
-
acknowledgmentGroupTime
How frequently acknowledgments are flushed to the broker.- Parameters:
delay- the acknowledgment group time- Returns:
- this builder instance for chaining
-
maxAcknowledgmentGroupSize
Maximum number of acknowledgments to group before flushing.- Parameters:
size- the maximum acknowledgment group size- Returns:
- this builder instance for chaining
-
negativeAckRedeliveryBackoff
Backoff strategy for redelivery after negative acknowledgment.- Parameters:
backoff- the backoff policy to use for negative ack redelivery- Returns:
- this builder instance for chaining
- See Also:
-
replicateSubscriptionState
Whether the subscription cursor should be replicated to other clusters in a geo-replication setup. Whentrue, the subscription state (acknowledgments) is replicated alongside the topic messages, so a consumer on a different cluster can resume from where this one left off after a failover. Defaults tofalse.- Parameters:
replicate- whether subscription state should be geo-replicated- Returns:
- this builder instance for chaining
-
deadLetterPolicy
Configure the dead letter queue policy.- Parameters:
policy- the dead letter policy- 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
-