java, apache pulsar Topic partition

276 Views Asked by At

If I have a topic called var test = "test" and I create a bean:

@Bean(name = "test")
public Producer<Test> testProducer(PulsarClient pulsarClient){
    return pulsarClient.newProducer()
            .topic(test)
            .create();
}

The topic is created I want to partition, how?

1

There are 1 best solutions below

0
On

To create a topic with partitions you can either configure the following settings for the Pulsar Broker (if you are relying on automatic topic creation)

allowAutoTopicCreationType = partitioned
defaultNumPartitions = <N>

Alternatively you can use the Pulsar Admin and use createPartitionedTopic https://github.com/apache/pulsar/blob/a165bda1d03e370f5efe1173134fb94e12b584b5/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Topics.java#L473-L475

However once a topic has been created (I assume non-partitioned) then there is no way to make it partitioned. It has to be partitioned at topic creation time.