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 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 CompletableFuture that completes with the created QueueConsumer
    • topic

      QueueConsumerBuilder<T> topic(String topicName)
      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

      QueueConsumerBuilder<T> namespace(String 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 in tenant/namespace form
      Returns:
      this builder instance for chaining
    • namespace

      QueueConsumerBuilder<T> namespace(String namespace, Map<String,String> propertyFilters)
      Subscribe to scalable topics under a namespace whose properties match every key/value pair in propertyFilters (AND semantics). An empty map is equivalent to namespace(String) — every topic in the namespace. The matching set follows live as topic properties change.
      Parameters:
      namespace - the namespace in tenant/namespace form
      propertyFilters - property name/value pairs that all must match
      Returns:
      this builder instance for chaining
    • subscriptionName

      QueueConsumerBuilder<T> subscriptionName(String subscriptionName)
      The subscription name. Required for managed consumers.
      Parameters:
      subscriptionName - the subscription name
      Returns:
      this builder instance for chaining
    • subscriptionProperties

      QueueConsumerBuilder<T> subscriptionProperties(Map<String,String> properties)
      Properties to attach to the subscription.
      Parameters:
      properties - the subscription properties
      Returns:
      this builder instance for chaining
    • subscriptionInitialPosition

      QueueConsumerBuilder<T> subscriptionInitialPosition(SubscriptionInitialPosition position)
      Initial position when the subscription is first created.
      Parameters:
      position - the initial position
      Returns:
      this builder instance for chaining
    • consumerName

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

      QueueConsumerBuilder<T> receiverQueueSize(int receiverQueueSize)
      Size of the receiver queue. Controls prefetch depth.
      Parameters:
      receiverQueueSize - the receiver queue size
      Returns:
      this builder instance for chaining
    • priorityLevel

      QueueConsumerBuilder<T> priorityLevel(int 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

      QueueConsumerBuilder<T> processingTimeout(ProcessingTimeoutPolicy policy)
      Optional safety net for slow / stalled consumers: see ProcessingTimeoutPolicy for 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

      QueueConsumerBuilder<T> acknowledgmentGroupTime(Duration delay)
      How frequently acknowledgments are flushed to the broker.
      Parameters:
      delay - the acknowledgment group time
      Returns:
      this builder instance for chaining
    • maxAcknowledgmentGroupSize

      QueueConsumerBuilder<T> maxAcknowledgmentGroupSize(int size)
      Maximum number of acknowledgments to group before flushing.
      Parameters:
      size - the maximum acknowledgment group size
      Returns:
      this builder instance for chaining
    • negativeAckRedeliveryBackoff

      QueueConsumerBuilder<T> negativeAckRedeliveryBackoff(BackoffPolicy backoff)
      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

      QueueConsumerBuilder<T> replicateSubscriptionState(boolean replicate)
      Whether the subscription cursor should be replicated to other clusters in a geo-replication setup. When true, 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 to false.
      Parameters:
      replicate - whether subscription state should be geo-replicated
      Returns:
      this builder instance for chaining
    • deadLetterPolicy

      QueueConsumerBuilder<T> deadLetterPolicy(DeadLetterPolicy policy)
      Configure the dead letter queue policy.
      Parameters:
      policy - the dead letter policy
      Returns:
      this builder instance for chaining
    • encryptionPolicy

      QueueConsumerBuilder<T> encryptionPolicy(ConsumerEncryptionPolicy policy)
      Configure end-to-end message encryption for decryption.
      Parameters:
      policy - the encryption policy to use
      Returns:
      this builder instance for chaining
      See Also:
    • property

      QueueConsumerBuilder<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

      QueueConsumerBuilder<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