1

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?

Youcef LAIDANI
  • 55,661
  • 15
  • 90
  • 140

1 Answers1

1

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.

kellyfj
  • 6,586
  • 12
  • 45
  • 66