-
Notifications
You must be signed in to change notification settings - Fork 41.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
KafkaAutoConfiguration should back off when a bean of type ConcurrentKafkaListenerContainerFactory is found #19221
Comments
Thanks for the issue report. Can you please share a minimal example that reproduces the failure? Looking at the auto-configuration and your description, I cannot see why there's no bean of type Lines 82 to 86 in 2c9cf65
|
Please see the test case at https://gist.github.com/manderson23/bed77497cd556f24bf77d758ae781455 If fails with the error message I mentioned. If I remove the |
Thank you. The definition of your own |
I am not entirely sure I agree with that although there is clearly an issue. The current back-off arrangement is meant to make sure a default factory can be created automatically even if the user provides additional factories. Backing off when a bean of that type is present will remove that feature so we shouldn't do that. The main problem I think is that we expect a Flagging for team attention to double check if I've missed something from Andy's comment. |
@manderson23 renaming one of your two factories there to |
@snicoll renaming if fine as a workaround but the surprising part to me was that a specific bean name for the factory was required for the auto-configuration to back-off. Requiring a specific bean name doesn't make sense when there are multiple factories and auto-configurations back off more elegantly. |
The issue you’ve reported is legit and we’re going to fix it. The point I was trying to make was that this feature uses a default factory with a specific bean and its absence from the context may lead to a failure unless you specify a custom factory for each endpoint. The workaround consists at electing one of the two you have to be the default. In this particular case, the bean name is a feature of the underlying library, not spring boot so it makes sense to require it. |
Was there anything in particular that you didn't agree with? My comment was attempting to describe the current behaviour rather than suggesting a solution. |
Yes, I read your comment that way. I think I was disagreeing with "The definition of your own ConsumerFactory beans was the missing piece" but I don't see why now so please ignore me :-) |
:-) That was just the missing piece for me to understand the reported behaviour. |
We've discussed this and we think that a condition on the generic type can be avoided by creating the |
We have a Spring Boot app configured with
@EnableKafka
and multiple instances ofConcurrentKafkaListenerContainerFactory
to consume from different topics that require different deserializers.With this configuration application startup fails with message
KafkaAutoConfiguration
attempts to create aConcurrentKafkaListenerContainerFactory
bean due to the condition@ConditionalOnMissingBean(name = "kafkaListenerContainerFactory")
. Our configuration does not have a bean with this name hence the error.Should the condition not check a bean exists with type
ConcurrentKafkaListenerContainerFactory
rather than a specific bean name? It would then backoff in a scenario like ours where we have multiple beans of this type defined?The text was updated successfully, but these errors were encountered: