![](/img/trans.png)
[英]How to check for the existence of a Pulsar topic programmatically in Java?
[英]java, apache pulsar Topic partition
如果我有一个名为var test = "test"
的主题并且我创建了一个 bean:
@Bean(name = "test")
public Producer<Test> testProducer(PulsarClient pulsarClient){
return pulsarClient.newProducer()
.topic(test)
.create();
}
主题创建好了我要分区,怎么办?
要创建带有分区的主题,您可以为 Pulsar Broker 配置以下设置(如果您依赖于自动创建主题)
allowAutoTopicCreationType = partitioned
defaultNumPartitions = <N>
或者,您可以使用 Pulsar Admin 并使用createPartitionedTopic
https://github.com/apache/pulsar/blob/a165bda1d03e370f5efe1173134fb94e12b584b5/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/主题.java#L473-L475
但是,一旦创建了一个主题(我假设未分区),就无法对其进行分区。 它必须在主题创建时进行分区。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.