0

I'm using Kafka Spring to create some listeners for kafka topics. The topics are created automatically when app starts.

That's how a listener looks like:

 @KafkaListener(topics = "${kafka.topics.message.readFormatForMessageFromProfile.in}") 

The problem is that i want to increase the number of partitions to 3 and i have no clue how to do that.

2 Answers 2

1

You can use topicPartitions attribute of @KafkaListner annotation.

@KafkaListener(id = "someId", topicPartitions = { @TopicPartition(topic = "${kafka.topics.message.readFormatForMessageFromProfile.in}", partitionOffsets = @PartitionOffset(partition = "0", initialOffset = "0"))}) 

You can add multiple @TopicPartition

Sign up to request clarification or add additional context in comments.

1 Comment

This doesn't create the partitions, it just tells the consumer which partitions to listen on.
0

I'm not an expert of Kafka Spring but I know how it's possible to do that using the official Admin Client API. By the way I see the following in the Kafka Spring documentation :

https://docs.spring.io/spring-kafka/reference/htmlsingle/#_configuring_topics

Reading this note :

If the broker supports it (1.0.0 or higher), the admin will increase the number of partitions if it is found that an existing topic has fewer partitions than the NewTopic.numPartitions.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.