-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to create Listener Containers with different Kafka consumer properties #1808
Comments
Something is amiss here; each container gets a new Lines 69 to 71 in bd15452
We then copy properties from the factory's properties into the instance properties: Lines 403 to 433 in bd15452
So it's not at all clear how we could get cross-talk between container properties. |
Oh; I see - it's the As a work around, give each container a new /**
* Set the consumer properties that will be merged with the consumer properties
* provided by the consumer factory; properties here will supersede any with the same
* name(s) in the consumer factory.
* {@code group.id} and {@code client.id} are ignored.
* Property keys must be {@link String}s.
* @param kafkaConsumerProperties the properties.
* @see org.apache.kafka.clients.consumer.ConsumerConfig
* @see #setGroupId(String)
* @see #setClientId(String)
*/
public void setKafkaConsumerProperties(Properties kafkaConsumerProperties) {
Assert.notNull(kafkaConsumerProperties, "'kafkaConsumerProperties' cannot be null");
this.kafkaConsumerProperties = kafkaConsumerProperties;
} |
Resolves spring-projects#1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches**
@garyrussell I've also created a PR #1810 |
Resolves #1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches**
Resolves #1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches**
Resolves #1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches**
Resolves #1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches** # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/config/AbstractKafkaListenerContainerFactory.java
Resolves #1808 Each container got a reference to the same `Properties` object in `kafkaConsumerProperties`, unless it was created via a `@KafkaListener` with property overrides. Do not copy the property from the factory's properties. **Cherry-pick to all supported branches** # Conflicts: # spring-kafka/src/main/java/org/springframework/kafka/config/AbstractKafkaListenerContainerFactory.java
Related to #1808 Turns out we also need to ignore a deprecated `setConsumerProperties` when `BeanUtils.copyProperties()` still sets the value by reflection **Cherry-pick to `2.3.x`**
Related to #1808 Turns out we also need to ignore a deprecated `setConsumerProperties` when `BeanUtils.copyProperties()` still sets the value by reflection **Cherry-pick to `2.3.x`**
Affects Version(s): 2.7.0
馃巵 Enhancement
When manually creating a listener container via listener container factory
org.springframework.kafka.config.AbstractKafkaListenerContainerFactory#createContainer(java.lang.String...)
method the listener container is initialized with properties from the factory.The
org.springframework.kafka.config.AbstractKafkaListenerContainerFactory#initializeContainer
method sets listener container'skafkaConsumerProperties
as a reference to the factoryconsumerProperties
.When calling code then changes
kafkaConsumerProperties
of the created listener container the changes affect all other listener containers which is the problem.Because of this it is impossible to create two listener containers with different offset reset policies for example:
Both listeners in the snippet end up with "earliest" offset reset policy.
A way to fix this would be creating a copy of factory
consumerProperties
before setting it for the listener container.The text was updated successfully, but these errors were encountered: