Skip to content

Commit

Permalink
Update message-listener-container.adoc (#3504)
Browse files Browse the repository at this point in the history
* Fix typo in `message-listener-container.adoc`

* Replace deprecated `PartitionAssignor` with `ConsumerPartitionAssignor` in `message-listener-container.adoc`
  • Loading branch information
yhao3 authored Sep 20, 2024
1 parent 10ea5bf commit ccd7215
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ For the first constructor, Kafka distributes the partitions across the consumers
====
When listening to multiple topics, the default partition distribution may not be what you expect.
For example, if you have three topics with five partitions each and you want to use `concurrency=15`, you see only five active consumers, each assigned one partition from each topic, with the other 10 consumers being idle.
This is because the default Kafka `PartitionAssignor` is the `RangeAssignor` (see its Javadoc).
This is because the default Kafka `ConsumerPartitionAssignor` is the `RangeAssignor` (see its Javadoc).
For this scenario, you may want to consider using the `RoundRobinAssignor` instead, which distributes the partitions across all of the consumers.
Then, each consumer is assigned one topic or partition.
To change the `PartitionAssignor`, you can set the `partition.assignment.strategy` consumer property (`ConsumerConfigs.PARTITION_ASSIGNMENT_STRATEGY_CONFIG`) in the properties provided to the `DefaultKafkaConsumerFactory`.
To change the `ConsumerPartitionAssignor`, you can set the `partition.assignment.strategy` consumer property (`ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG`) in the properties provided to the `DefaultKafkaConsumerFactory`.
When using Spring Boot, you can assign set the strategy as follows:
Expand Down

0 comments on commit ccd7215

Please sign in to comment.