How does spring kafka achieve the designated partition of consumer consumption?

The native API of

kafka can use consumer.assign (partitions) to subscribe to the API of the specified partition, spring kafka. Is there a corresponding method? I only found @ KafkaListener (topicPartitions = {@ TopicPartition (topic = "topic1", partitions = {"0", "1"})} annotation, but when implemented in this way, the values of topic and partitions must be constant, but in fact, I need to determine that @ KafkaListener cannot be used according to the user"s id (get in operation). Is there any solution?

another: if you use the consumer.assign (partitions) method, is it true that the partition.assignment.strategy attribute will not take effect?

Sep.18,2021
How to solve

I also want to know


you can configure unified configuration partition rules among producers


encountered the same problem, but fortunately you have solved it and come back to share it.

you can write expressions from https://docs.spring.io/spring-kafka/docs/current/reference/html/-sharptip-assign-all-parts


with

@KafkaListener(topics = "-sharp{'${spring.kafka.topics}'.split(' ')}")
Menu