Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ConcurrentMessageListenerContainer section of reference doc is a bit confusing #3733

Open
jourteen opened this issue Feb 9, 2025 · 1 comment

Comments

@jourteen
Copy link

jourteen commented Feb 9, 2025

Using ConcurrentMessageListenerContainer section starts with:

The single constructor is similar to the KafkaListenerContainer constructor.

Then just below:

For the first constructor, Kafka distributes the partitions across the consumers using its group management capabilities.

Probably there were multiple constructors in older versions, but there is a single constructor now.

@artembilan
Copy link
Member

Yes, we have only one constructor there at the moment:

	/**
	 * Construct an instance with the supplied configuration properties.
	 * The topic partitions are distributed evenly across the delegate
	 * {@link KafkaMessageListenerContainer}s.
	 * @param consumerFactory the consumer factory.
	 * @param containerProperties the container properties.
	 */
	public ConcurrentMessageListenerContainer(ConsumerFactory<? super K, ? super V> consumerFactory,
			ContainerProperties containerProperties) {

The rest of the logic is done against that ContainerProperties:

	private KafkaMessageListenerContainer<K, V> constructContainer(ContainerProperties containerProperties,
			@Nullable TopicPartitionOffset[] topicPartitions, int i) {

		KafkaMessageListenerContainer<K, V> container;
		if (topicPartitions == null) {
			container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, containerProperties); // NOSONAR
		}
		else {
			container = new KafkaMessageListenerContainer<>(this, this.consumerFactory, // NOSONAR
					containerProperties, partitionSubset(containerProperties, i));
		}
		return container;
	}

I believe indeed in some old version we had different constructor with those assigned partitions.

Now the doc has to be fixed.

I guess that For the first constructor, sentence could be changed to:

If the container properties are configured for topics (or topic pattern),  Kafka distributes the partitions across the consumers using its group management capabilities.

Feel free to contribute the fix: https://github.com/spring-projects/spring-kafka/blob/main/CONTRIBUTING.adoc

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants