Default Tenant / Namespace

Pulsar has built-in support for multi-tenancy. When producing or consuming messages in Pulsar, the specified topic is actually a topic URL of the following format:spring-doc.cn

(persistent|non-persistent)://tenant/namespace/topic

The URL dictates which tenant and namespace the operation is targeted against. However, when not fully-qualified (i.e. only topic name is specified), the default tenant of public and namespace of default is used.spring-doc.cn

Spring for Apache Pulsar allows you to specify a default tenant and/or namespace to use when producing or consuming messages against a non-fully-qualified topic URL.spring-doc.cn

Configuration

With Spring Boot

When using the Spring Boot you can simply set the spring.pulsar.defaults.topic.tenant and spring.pulsar.defaults.topic.namespace application properties to specify these defaults.spring-doc.cn

If you want to disable this feature, simply set the spring.pulsar.defaults.topic.enabled property to false.spring-doc.cn

Without Spring Boot

However, if you are instead manually configuring the components, you will have to provide a PulsarTopicBuilder configured with the desired default topic and namespace when constructing the corresponding producer or consumer factory. All default consumer/reader/producer factory implementations (imperative and reactive) allow a topic builder to be specified.spring-doc.cn

You will need to specify the topic builder on each manually configured factory that you want to use the default tenant/namespace