Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
* @author Tomaz Fernandes
* @author Wang Zhiyang
* @author Lokesh Alamuri
* @author Su Ko
*/
public class ConcurrentMessageListenerContainer<K, V> extends AbstractMessageListenerContainer<K, V> {

Expand Down Expand Up @@ -320,26 +321,24 @@ private KafkaMessageListenerContainer<K, V> constructContainer(ContainerProperti
if (topicPartitions == null) {
return null;
}

if (this.concurrency == 1) {
return topicPartitions;
}
else {
int numPartitions = topicPartitions.length;
if (numPartitions == this.concurrency) {
return new TopicPartitionOffset[] { topicPartitions[index] };
}
else {
int perContainer = numPartitions / this.concurrency;
TopicPartitionOffset[] subset;
if (index == this.concurrency - 1) {
subset = Arrays.copyOfRange(topicPartitions, index * perContainer, topicPartitions.length);
}
else {
subset = Arrays.copyOfRange(topicPartitions, index * perContainer, (index + 1) * perContainer);
}
return subset;
}

int numPartitions = topicPartitions.length;

if (numPartitions == this.concurrency) {
return new TopicPartitionOffset[] { topicPartitions[index] };
}

int perContainer = numPartitions / this.concurrency;
int start = index * perContainer;
int end = (index == this.concurrency - 1)
? numPartitions
: start + perContainer;

return Arrays.copyOfRange(topicPartitions, start, end);
}

/*
Expand Down