Interface StreamConsumerBuilder<T>

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

public interface StreamConsumerBuilder<T>
Builder for configuring and creating a StreamConsumer.
  • Method Details

    • subscribe

      Subscribe and create the stream consumer, blocking until ready.
      Returns:
      the created StreamConsumer
      Throws:
      PulsarClientException - if the subscription fails or a connection error occurs
    • subscribeAsync

      CompletableFuture<StreamConsumer<T>> subscribeAsync()
      Subscribe and create the stream consumer asynchronously.
      Returns:
      a CompletableFuture that completes with the created StreamConsumer
    • topic

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

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

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

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

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

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

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

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

      StreamConsumerBuilder<T> readCompacted(boolean readCompacted)
      Whether to read from the compacted topic (only latest value per key).
      Parameters:
      readCompacted - true to read from the compacted topic
      Returns:
      this builder instance for chaining
    • replicateSubscriptionState

      StreamConsumerBuilder<T> replicateSubscriptionState(boolean replicate)
      Enable replication of subscription state across geo-replicated clusters.
      Parameters:
      replicate - true to replicate subscription state
      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

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

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