Class PulsarTopicBuilder

java.lang.Object
org.springframework.pulsar.core.PulsarTopicBuilder

public class PulsarTopicBuilder extends Object
Builder class to create PulsarTopic instances.
Author:
Alexander Preuß, Chris Bono
  • Constructor Details

    • PulsarTopicBuilder

      public PulsarTopicBuilder()
      Create a builder instance that uses the following defaults.
       - domain -> 'persistent'
       - tenant -> 'public'
       - namespace -> 'default'
       
    • PulsarTopicBuilder

      public PulsarTopicBuilder(org.apache.pulsar.common.naming.TopicDomain defaultDomain, @Nullable String defaultTenant, @Nullable String defaultNamespace)
      Create a builder instance that uses the specified defaults.
      Parameters:
      defaultDomain - domain to use when topic name is not fully-qualified
      defaultTenant - tenant to use when topic name is not fully-qualified or null to use the Pulsar default tenant of 'public'
      defaultNamespace - namespace to use when topic name is not fully-qualified or null to use the Pulsar default namespace of 'namespace'
  • Method Details

    • getFullyQualifiedNameForTopic

      public String getFullyQualifiedNameForTopic(String topicName)
      Get the fully-qualified name of the specified topic in the format domain://tenant/namespace/name.
      Parameters:
      topicName - the topic name to fully qualify
      Returns:
      the fully-qualified topic name
    • name

      public PulsarTopicBuilder name(String name)
      Set the name of the topic under construction. The following formats are accepted:
       - 'name'
       - 'tenant/namespace/name'
       - 'domain://tenant/namespace/name'
       
      When the name is not fully-qualified the missing components are populated with the corresponding default configured on the builder.
      Parameters:
      name - the topic name
      Returns:
      this builder
    • numberOfPartitions

      public PulsarTopicBuilder numberOfPartitions(int numberOfPartitions)
      Sets the number of topic partitions for the topic under construction.
      Parameters:
      numberOfPartitions - the number of topic partitions
      Returns:
      this builder
    • build

      public PulsarTopic build()
      Constructs the PulsarTopic with the properties configured in this builder.
      Returns:
      PulsarTopic